Exemple #1
0
        ToolboxWidgetItem GetNextItem(ToolboxWidgetItem currentItem)
        {
            ToolboxWidgetItem result = currentItem;
            ToolboxWidgetItem lastItem = null;
            int xpos = 0, ypos = 0;

            Iterate(ref xpos, ref ypos, (category, itemDimension) => {
                if (lastItem == currentItem)
                {
                    result = category;
                    return(false);
                }
                lastItem = category;
                return(true);
            }, (curCategory, item, itemDimension) => {
                if (lastItem == currentItem)
                {
                    result = item;
                    return(false);
                }
                lastItem = item;
                return(true);
            });
            return(result);
        }
Exemple #2
0
 public void Remove(ToolboxWidgetItem item)
 {
     this.items.Remove(item);
     if (IsSorted)
     {
         items.Sort();
     }
 }
Exemple #3
0
 public void Add(ToolboxWidgetItem item)
 {
     this.items.Add(item);
     if (IsSorted)
     {
         items.Sort();
     }
 }
Exemple #4
0
 void ClearMouseOverItem()
 {
     if (mouseOverItem != null)
     {
         mouseOverItem = null;
     }
     HideTooltipWindow();
     this.QueueDraw();
 }
Exemple #5
0
        public void ShowTooltip(ToolboxWidgetItem item, uint timer, int x, int y)
        {
            HideTooltipWindow();

            if (!string.IsNullOrEmpty(item.Tooltip) || (item.Node is ICustomTooltipToolboxNode custom && custom.HasTooltip))
            {
                tipItem      = item;
                tipX         = x;
                tipY         = y;
                tipTimeoutId = GLib.Timeout.Add(timer, ShowTooltip);
            }
        }
Exemple #6
0
        ToolboxWidgetCategory GetCategory(ToolboxWidgetItem item)
        {
            ToolboxWidgetCategory result = null;
            int xpos = 0, ypos = 0;

            Iterate(ref xpos, ref ypos, null, (curCategory, innerItem, itemDimension) => {
                if (innerItem == item)
                {
                    result = curCategory;
                    return(false);
                }
                return(true);
            });
            return(result);
        }
Exemple #7
0
        ToolboxWidgetItem GetItemLeft(ToolboxWidgetItem item)
        {
            ToolboxWidgetItem result = item;

            Gdk.Rectangle rect = GetItemExtends(item);
            int           xpos = 0, ypos = 0;

            Iterate(ref xpos, ref ypos, null, (curCategory, curItem, itemDimension) => {
                if (xpos < rect.X && ypos == rect.Y)
                {
                    result = curItem;
                    return(false);
                }
                return(true);
            });
            return(result);
        }
Exemple #8
0
        ToolboxWidgetItem GetItemBelow(ToolboxWidgetItem item)
        {
            ToolboxWidgetCategory itemCategory = GetCategory(item);

            ToolboxWidgetItem result = item;

            Gdk.Rectangle rect = GetItemExtends(item);
            int           xpos = 0, ypos = 0;

            Iterate(ref xpos, ref ypos, null, (curCategory, curItem, itemDimension) => {
                if (ypos > rect.Y && xpos == rect.X && result == item && curCategory == itemCategory)
                {
                    result = curItem;
                    return(false);
                }
                return(true);
            });
            return(result);
        }
Exemple #9
0
        Gdk.Rectangle GetItemExtends(ToolboxWidgetItem item)
        {
            var result = new Gdk.Rectangle(0, 0, 0, 0);
            int xpos = 0, ypos = 0;

            Iterate(ref xpos, ref ypos, (category, itemDimension) => {
                if (item == category)
                {
                    result = new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                    return(false);
                }
                return(true);
            }, (curCategory, curItem, itemDimension) => {
                if (item == curItem)
                {
                    result = new Gdk.Rectangle(xpos, ypos, itemDimension.Width, itemDimension.Height);
                    return(false);
                }
                return(true);
            });
            return(result);
        }
Exemple #10
0
 void AddItems(IEnumerable <ItemToolboxNode> nodes)
 {
     foreach (ItemToolboxNode itbn in nodes)
     {
         var newItem = new ToolboxWidgetItem(itbn);
         if (!categories.ContainsKey(itbn.Category))
         {
             var cat = new ToolboxWidgetCategory(itbn.Category);
             int prio;
             if (!categoryPriorities.TryGetValue(itbn.Category, out prio))
             {
                 prio = -1;
             }
             cat.Priority = prio;
             categories[itbn.Category] = cat;
         }
         if (newItem.Text != null)
         {
             categories[itbn.Category].Add(newItem);
         }
     }
 }
Exemple #11
0
        void Refilter(bool isNewData)
        {
            ToolboxWidgetItem selectedItem = null;

            //if there is a search our index of the selected item will change and we want get the new one
            if (!isNewData)
            {
                selectedItem = toolboxWidget.SelectedItem;
            }

            var cats = categories.Values.ToList();

            cats.Sort((a, b) => a.Priority != b.Priority ? b.Priority.CompareTo(a.Priority) : b.Text.CompareTo(a.Text));

            toolboxWidget.CategoryVisibilities.Clear();
            foreach (var category in cats)
            {
                bool hasVisibleChild = false;

                foreach (var child in category.Items)
                {
                    if (toolboxWidget.ShowCategories)
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue) && category.IsExpanded;
                    }
                    else
                    {
                        child.IsVisible = ((ItemToolboxNode)child.Tag).Filter(filterEntry.StringValue);
                    }
                    hasVisibleChild |= child.IsVisible;
                }

                category.IsVisible = hasVisibleChild;
                toolboxWidget.AddCategory(category);
            }

            toolboxWidget.RedrawItems(true, true, isNewData, selectedItem);
        }