Example #1
0
 public void Clear()
 {
     buttons.Clear();
     visibleButtons = null;
     pushedButton   = null;
     QueueResize();
 }
Example #2
0
 protected override bool OnButtonReleaseEvent(EventButton evnt)
 {
     if (State == StateType.Selected && pushedButton != null)
     {
         IdeApp.CommandService.DispatchCommand(pushedButton.CommandId, null, lastCommandTarget, CommandSource.MainToolbar);
     }
     State        = StateType.Prelight;
     leaveState   = StateType.Normal;
     pushedButton = null;
     return(true);
 }
Example #3
0
 protected override bool OnButtonPressEvent(EventButton evnt)
 {
     if (evnt.Button == 1)
     {
         pushedButton = VisibleButtons.FirstOrDefault(b => b.Allocation.Contains(Allocation.X + (int)evnt.X, Allocation.Y + (int)evnt.Y));
         if (pushedButton != null && pushedButton.Enabled)
         {
             State = StateType.Selected;
         }
     }
     return(true);
 }
Example #4
0
        public void Add(string commandId)
        {
            ButtonBarButton b  = new ButtonBarButton(commandId);
            var             ci = IdeApp.CommandService.GetCommandInfo(commandId, new CommandTargetRoute(lastCommandTarget));

            if (ci != null)
            {
                UpdateButton(b, ci);
            }
            buttons.Add(b);
            visibleButtons = null;
            QueueResize();
        }
Example #5
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            ScaleImages(Allocation.Height);

            using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                double x = Allocation.X, y = Allocation.Y;
                for (int i = 0; i < VisibleButtons.Length; i++)
                {
                    bool            nextIsSeparator  = (i < VisibleButtons.Length - 1 && VisibleButtons[i + 1].IsSeparator) || i == visibleButtons.Length - 1;
                    bool            lastWasSeparator = (i > 0 && VisibleButtons[i - 1].IsSeparator) || i == 0;
                    ButtonBarButton button           = VisibleButtons [i];
                    if (button.IsSeparator)
                    {
                        if (!lastWasSeparator)
                        {
                            x += SeparatorSpacing;
                        }
                        continue;
                    }
                    Gdk.Pixbuf[] images = State == StateType.Selected && pushedButton == button ? btnPressed : btnNormal;
                    Gdk.Pixbuf   img    = images [lastWasSeparator ? 0 : nextIsSeparator ? 2 : 1];
                    Gdk.CairoHelper.SetSourcePixbuf(context, img, x, y);
                    context.Paint();

                    button.Allocation = new Gdk.Rectangle((int)x, (int)y, img.Width, img.Height);

                    var icon     = ImageService.GetPixbuf(button.Image, IconSize.Menu);
                    var iconCopy = icon;
                    if (!Sensitive || !button.Enabled)
                    {
                        iconCopy = ImageService.MakeTransparent(icon, 0.4);
                    }
                    Gdk.CairoHelper.SetSourcePixbuf(context, iconCopy, x + (img.Width - icon.Width) / 2, y + (img.Height - icon.Height) / 2);
                    context.Paint();
                    if (iconCopy != icon)
                    {
                        iconCopy.Dispose();
                    }
                    x += img.Width;
                }
            }
            return(base.OnExposeEvent(evnt));
        }
        void RebuildToolbar()
        {
            var bars = AddinManager.GetExtensionNodes<ItemSetCodon> (ToolbarExtensionPath)
                .Where (n => visibleBars.Contains (n.Id))
                .Select (b => new { Label = b.Label, Buttons = b.ChildNodes.OfType<CommandItemCodon> ().Select (n => n.Id) });

            var buttonGroups = new List<ButtonBarGroup> ();
            buttonBarButtons.Clear ();
            foreach (var bar in bars) {
                var group = new ButtonBarGroup (bar.Label);

                buttonGroups.Add (group);
                foreach (string commandId in bar.Buttons) {
                    var button = new ButtonBarButton (this, commandId);
                    group.Buttons.Add (button);
                    buttonBarButtons.Add (button);
                }
            }

            ToolbarView.RebuildToolbar (buttonGroups);
        }
Example #7
0
 void UpdateButton(ButtonBarButton b, CommandInfo ci)
 {
     if (ci.Icon != b.Image)
     {
         b.Image = ci.Icon;
         QueueDraw();
     }
     if (ci.Visible != b.Visible)
     {
         b.Visible      = ci.Visible;
         visibleButtons = null;
         QueueResize();
     }
     if (ci.Enabled != b.Enabled)
     {
         b.Enabled = ci.Enabled;
         QueueDraw();
     }
     if (ci.Description != b.Tooltip)
     {
         b.Tooltip = ci.Description;
     }
 }
Example #8
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            ScaleImages(Allocation.Height);

            using (var context = Gdk.CairoHelper.Create(evnt.Window)) {
                double x = Allocation.X, y = Allocation.Y;
                for (int i = 0; i < VisibleButtons.Length; i++)
                {
                    bool            nextIsSeparator  = (i < VisibleButtons.Length - 1 && VisibleButtons[i + 1].IsSeparator) || i == visibleButtons.Length - 1;
                    bool            lastWasSeparator = (i > 0 && VisibleButtons[i - 1].IsSeparator) || i == 0;
                    ButtonBarButton button           = VisibleButtons [i];
                    if (button.IsSeparator)
                    {
                        if (!lastWasSeparator)
                        {
                            x += SeparatorSpacing;
                        }
                        continue;
                    }
                    Xwt.Drawing.Image[] images = State == StateType.Selected && pushedButton == button ? btnPressed : btnNormal;
                    Xwt.Drawing.Image   img    = images [lastWasSeparator ? 0 : nextIsSeparator ? 2 : 1];
                    context.DrawImage(this, img, x, y);

                    button.Allocation = new Gdk.Rectangle((int)x, (int)y, (int)img.Width, (int)img.Height);

                    var icon = ImageService.GetIcon(button.Image, IconSize.Menu);
                    if (!Sensitive || !button.Enabled)
                    {
                        icon = icon.WithAlpha(0.4);
                    }
                    context.DrawImage(this, icon, Math.Truncate(x + (img.Width - icon.Width) / 2), Math.Truncate(y + (img.Height - icon.Height) / 2));
                    x += img.Width;
                }
            }
            return(base.OnExposeEvent(evnt));
        }
Example #9
0
 void UpdateButton(ButtonBarButton b, CommandInfo ci)
 {
     if (ci.Icon != b.Image) {
         b.Image = ci.Icon;
         QueueDraw ();
     }
     if (ci.Visible != b.Visible) {
         b.Visible = ci.Visible;
         visibleButtons = null;
         QueueResize ();
     }
     if (ci.Enabled != b.Enabled) {
         b.Enabled = ci.Enabled;
         QueueDraw ();
     }
     if (ci.Description != b.Tooltip)
         b.Tooltip = ci.Description;
 }
Example #10
0
 protected override bool OnButtonReleaseEvent(EventButton evnt)
 {
     if (State == StateType.Selected && pushedButton != null)
         IdeApp.CommandService.DispatchCommand (pushedButton.CommandId, null, lastCommandTarget, CommandSource.MainToolbar);
     State = StateType.Prelight;
     leaveState = StateType.Normal;
     pushedButton = null;
     return true;
 }
Example #11
0
 protected override bool OnButtonPressEvent(EventButton evnt)
 {
     if (evnt.Button == 1) {
         pushedButton = VisibleButtons.FirstOrDefault (b => b.Allocation.Contains (Allocation.X + (int)evnt.X, Allocation.Y + (int)evnt.Y));
         if (pushedButton != null && pushedButton.Enabled)
             State = StateType.Selected;
     }
     return true;
 }
Example #12
0
 public void Clear()
 {
     buttons.Clear ();
     visibleButtons = null;
     pushedButton = null;
     QueueResize ();
 }
Example #13
0
 public void Add(string commandId)
 {
     ButtonBarButton b = new ButtonBarButton (commandId);
     var ci = IdeApp.CommandService.GetCommandInfo (commandId, new CommandTargetRoute (lastCommandTarget));
     if (ci != null)
         UpdateButton (b, ci);
     buttons.Add (b);
     visibleButtons = null;
     QueueResize ();
 }