Esempio n. 1
0
    protected virtual void DrawItemRow(int i, ListItem item, GUIStyle itemStyle)
    {
        var cat = _listData.categories [item.categoryId];

        Texture2D tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);

        tex.SetPixel(0, 0, ColorWithAlpha(cat.color, 0.5f));
        tex.Apply();

        GUIStyle s = new GUIStyle();

        if (cat.trackTime && !item.isComplete)
        {
            s.normal.background = tex;
        }

        EditorGUILayout.BeginVertical(s);
        {
            EditorGUILayout.BeginHorizontal();
            {
                // CHECKMARK
                if (EditorGUILayout.Toggle(item.isComplete, GUILayout.Width(20)))
                {
                    if (!item.isComplete)
                    {
                        _listData.CompleteTask(item);
                    }
                }
                else
                {
                    if (item.isComplete)
                    {
                        _listData.ReactivateTask(item);
                    }
                }

                // TEXT
                if (!cat.trackTime)
                {
                    itemStyle.normal.textColor = cat.color;
                }
                item.task = EditorGUILayout.TextArea(item.task, itemStyle);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.Space();

                // CATEGORY
                item.categoryId = EditorGUILayout.Popup(item.categoryId, _listData.categoryStrings, GUILayout.Width(60));

                // TYPE
                item.tagId = EditorGUILayout.Popup(item.tagId, _listData.tagStrings, GUILayout.Width(60));

                // PERSON
                item.personId = EditorGUILayout.Popup(item.personId, _listData.peopleStrings, GUILayout.Width(60));

                // TIME ESTIMATE
                item.timeEstimate = EditorGUILayout.FloatField(item.timeEstimate, GUILayout.Width(32));
                item.timeEstimate = Mathf.Clamp(item.timeEstimate, 0f, 8f);

                // ARCHIVE
                if (item.isComplete)                // || true) // LOL remove the "true" if you only want archive options when complete.
                {
                    if (!item.isArchived && GUILayout.Button("archive", GUILayout.Width(68)))
                    {
                        _listData.ArchiveTask(item);
                    }
                    else if (item.isArchived && GUILayout.Button("unarchive", GUILayout.Width(68)))
                    {
                        _listData.tasks [i].isArchived = false;
                    }
                }

                // DELETE
                if (GUILayout.Button("x", GUILayout.Width(23)))
                {
                    _listData.tasks.RemoveAt(i);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
    }