Example #1
0
        NSToolbarItem CreateSelectorToolbarItem()
        {
            var selector = new SelectorView();

            viewCache.Add(selector);
            var item = new NSToolbarItem(SelectorId)
            {
                View    = selector,
                MinSize = new CGSize(150, 25),
                MaxSize = new CGSize(150, 25),
            };

            selector.ResizeRequested += (o, e) => {
                item.MinSize = item.MaxSize = e.Size;
                centeringSpace.UpdateWidth();
            };

            var pathSelector = (SelectorView.PathSelectorView)selector.Subviews [0];

            pathSelector.ConfigurationChanged += (sender, e) => {
                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(sender, e);
                }
            };
            pathSelector.RuntimeChanged += (sender, ea) => {
                if (RuntimeChanged != null)
                {
                    RuntimeChanged(sender, ea);
                }
            };
            return(item);
        }
Example #2
0
        public AwesomeBar()
        {
            RunButton = new RunButton();
            AddSubview(RunButton);

            SelectorView              = new SelectorView();
            SelectorView.SizeChanged += (object sender, EventArgs e) => UpdateLayout();
            AddSubview(SelectorView);

            ButtonBarContainer              = new ButtonBarContainer();
            ButtonBarContainer.SizeChanged += (object sender, EventArgs e) => UpdateLayout();
            AddSubview(ButtonBarContainer);

            StatusBar = new StatusBar();
            AddSubview(StatusBar);

            SearchBar = new SearchBar();
            AddSubview(SearchBar);

            StatusBar.SearchBar = SearchBar;

            RunButton.NextKeyView          = SelectorView;
            SelectorView.NextKeyView       = ButtonBarContainer;
            ButtonBarContainer.NextKeyView = StatusBar;
            StatusBar.NextKeyView          = SearchBar;

            Ide.Gui.Styles.Changed += (o, e) => UpdateLayout();
        }
Example #3
0
        void UpdateLayout()
        {
            RunButton.Frame = new CGRect(toolbarPadding, 0, runButtonWidth, ToolbarWidgetHeight);
            var statusbarWidth = Math.Max(Math.Min(Frame.Width * 0.3, maxStatusBarWidth), minStatusBarWidth);
            var searchbarWidth = maxSearchBarWidth;

            if (statusbarWidth < searchbarWidth)
            {
                searchbarWidth = minSearchBarWidth;
            }

            // We only need to work out the width on the left side of the window because the statusbar is centred
            // Gap + RunButton.Width + Gap + ButtonBar.Width + Gap + Half of StatusBar.Width
            var spaceLeft = (Frame.Width / 2) - (toolbarPadding + runButtonWidth + toolbarPadding + ButtonBarContainer.Frame.Width + toolbarPadding + (statusbarWidth / 2));

            StatusBar.Frame = new CGRect((Frame.Width - statusbarWidth) / 2, 0, statusbarWidth, ToolbarWidgetHeight);
            SearchBar.Frame = new CGRect(Frame.Width - searchbarWidth - 10, 0, searchbarWidth, ToolbarWidgetHeight);

            var selectorSize = SelectorView.SizeThatFits(new CGSize(spaceLeft, ToolbarWidgetHeight));

            SelectorView.Frame = new CGRect(toolbarPadding + runButtonWidth + toolbarPadding, 0, selectorSize.Width, ToolbarWidgetHeight);

            ButtonBarContainer.SetFrameOrigin(new CGPoint(SelectorView.Frame.GetMaxX() + toolbarPadding, 0));

            // Finally check if the StatusBar overlaps the ButtonBarContainer (and its padding) and adjust is accordingly
            if (StatusBar.Frame.IntersectsWith(ButtonBarContainer.Frame.Inset(-toolbarPadding, 0)))
            {
                StatusBar.SetFrameOrigin(new CGPoint(ButtonBarContainer.Frame.GetMaxX() + toolbarPadding, StatusBar.Frame.Y));
            }
        }
Example #4
0
        void UpdateLayout()
        {
            RunButton.Frame = new CGRect(toolbarPadding, 0, runButtonWidth, ToolbarWidgetHeight);
            var statusbarWidth = Math.Max(Math.Min(Math.Round(Frame.Width * 0.3), maxStatusBarWidth), minStatusBarWidth);
            var searchbarWidth = maxSearchBarWidth;

            if (statusbarWidth < searchbarWidth)
            {
                searchbarWidth = minSearchBarWidth;
            }

            // We only need to work out the width on the left side of the window because the statusbar is centred
            // Gap + RunButton.Width + Gap + ButtonBar.Width + Gap + Half of StatusBar.Width
            var spaceLeft = (Frame.Width / 2) - (toolbarPadding + runButtonWidth + toolbarPadding + ButtonBarContainer.Frame.Width + toolbarPadding + (statusbarWidth / 2));

            StatusBar.Frame = new CGRect(Math.Round((Frame.Width - statusbarWidth) / 2), 0, statusbarWidth - 2, ToolbarWidgetHeight);

            if (IdeApp.Preferences.UserInterfaceTheme == Theme.Dark)
            {
                SearchBar.Frame = new CGRect(Frame.Width - searchbarWidth, 0, searchbarWidth, ToolbarWidgetHeight);
            }
            else
            {
                nfloat elcapYOffset = 0;
                nfloat elcapHOffset = 0;

                if (MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan)
                {
                    nfloat scaleFactor = 1;

                    if (Window != null && Window.Screen != null)
                    {
                        scaleFactor = Window.Screen.BackingScaleFactor;
                    }
                    elcapYOffset = scaleFactor == 2 ? -0.5f : -1;
                    elcapHOffset = 1.0f;
                }
                SearchBar.Frame = new CGRect(Frame.Width - searchbarWidth, 0 + elcapYOffset, searchbarWidth, ToolbarWidgetHeight + elcapHOffset);
            }

            var selectorSize = SelectorView.SizeThatFits(new CGSize(spaceLeft, ToolbarWidgetHeight));

            SelectorView.Frame = new CGRect(toolbarPadding + runButtonWidth + toolbarPadding, 0, Math.Round(selectorSize.Width), ToolbarWidgetHeight);
            ButtonBarContainer.SetFrameOrigin(new CGPoint(SelectorView.Frame.GetMaxX() + toolbarPadding, -2));

            // Finally check if the StatusBar overlaps the ButtonBarContainer (and its padding) and adjust is accordingly
            if (StatusBar.Frame.IntersectsWith(ButtonBarContainer.Frame.Inset(-toolbarPadding, 0)))
            {
                StatusBar.SetFrameOrigin(new CGPoint(ButtonBarContainer.Frame.GetMaxX() + toolbarPadding, StatusBar.Frame.Y));
            }
        }
Example #5
0
		public AwesomeBar ()
		{
			RunButton = new RunButton ();
			AddSubview (RunButton);

			SelectorView = new SelectorView ();
			SelectorView.SizeChanged += (object sender, EventArgs e) => UpdateLayout ();
			AddSubview (SelectorView);

			ButtonBarContainer = new ButtonBarContainer ();
			ButtonBarContainer.SizeChanged += (object sender, EventArgs e) => UpdateLayout ();
			AddSubview (ButtonBarContainer);

			StatusBar = new StatusBar ();
			AddSubview (StatusBar);

			SearchBar = new SearchBar ();
			AddSubview (SearchBar);
		}
Example #6
0
        public AwesomeBar()
        {
            RunButton = new RunButton();
            AddSubview(RunButton);

            SelectorView              = new SelectorView();
            SelectorView.SizeChanged += (object sender, EventArgs e) => UpdateLayout();
            AddSubview(SelectorView);

            ButtonBarContainer              = new ButtonBarContainer();
            ButtonBarContainer.SizeChanged += (object sender, EventArgs e) => UpdateLayout();
            AddSubview(ButtonBarContainer);

            StatusBar = new StatusBar();
            AddSubview(StatusBar);

            SearchBar = new SearchBar();
            AddSubview(SearchBar);
        }
Example #7
0
		NSToolbarItem CreateSelectorToolbarItem ()
		{
			var selector = new SelectorView ();
			viewCache.Add (selector);
			var item = new NSToolbarItem (SelectorId) {
				View = selector,
				MinSize = new CGSize (150, 25),
				MaxSize = new CGSize (150, 25),
			};
			selector.ResizeRequested += (o, e) => {
				item.MinSize = item.MaxSize = e.Size;
				centeringSpace.UpdateWidth ();
			};
			selector.OverflowInfoRequested += (o, e) => {
				FillOverflowInfo (e);
			};

			IDisposable resizeTimer = null;
			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.WillStartLiveResizeNotification, notif => DispatchService.GuiDispatch (() => {
				if (!IsCorrectNotification (selector, notif.Object))
					return;

				if (resizeTimer != null)
					resizeTimer.Dispose ();

				resizeTimer = Application.TimeoutInvoke (100, () => {
					if (widget.Items.Length != widget.VisibleItems.Length)
						selector.RequestResize ();
					return true;
				});
			}));

			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidResizeNotification, notif => DispatchService.GuiDispatch (() => {
				if (!IsCorrectNotification (selector, notif.Object))
					return;

				// Don't check difference in overflow menus. This could cause issues since we're doing resizing of widgets and the views might go in front
				// or behind while we're doing the resize request.
				selector.RequestResize ();
			}));

			NSNotificationCenter.DefaultCenter.AddObserver (NSWindow.DidEndLiveResizeNotification, notif => DispatchService.GuiDispatch (() => {
				if (!IsCorrectNotification (selector, notif.Object))
					return;

				if (resizeTimer != null)
					resizeTimer.Dispose ();

				resizeTimer = Application.TimeoutInvoke (300, selector.RequestResize);
			}));

			var pathSelector = (SelectorView.PathSelectorView)selector.Subviews [0];
			pathSelector.ConfigurationChanged += (sender, e) => {
				if (ConfigurationChanged != null)
					ConfigurationChanged (sender, e);
			};
			pathSelector.RuntimeChanged += (sender, ea) => {
				if (RuntimeChanged != null)
					RuntimeChanged (sender, ea);
			};
			return item;
		}
Example #8
0
        NSToolbarItem CreateSelectorToolbarItem()
        {
            var selector = new SelectorView();

            viewCache.Add(selector);
            var item = new NSToolbarItem(SelectorId)
            {
                View    = selector,
                MinSize = new CGSize(150, 25),
                MaxSize = new CGSize(150, 25),
            };

            selector.ResizeRequested += (o, e) => {
                item.MinSize = item.MaxSize = e.Size;
                centeringSpace.UpdateWidth();
            };
            selector.OverflowInfoRequested += (o, e) => {
                FillOverflowInfo(e);
            };

            IDisposable resizeTimer = null;

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.WillStartLiveResizeNotification, notif => DispatchService.GuiDispatch(() => {
                if (!IsCorrectNotification(selector, notif.Object))
                {
                    return;
                }

                if (resizeTimer != null)
                {
                    resizeTimer.Dispose();
                }

                resizeTimer = Application.TimeoutInvoke(100, () => {
                    if (widget.Items.Length != widget.VisibleItems.Length)
                    {
                        selector.RequestResize();
                    }
                    return(true);
                });
            }));

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidResizeNotification, notif => DispatchService.GuiDispatch(() => {
                if (!IsCorrectNotification(selector, notif.Object))
                {
                    return;
                }

                // Don't check difference in overflow menus. This could cause issues since we're doing resizing of widgets and the views might go in front
                // or behind while we're doing the resize request.
                selector.RequestResize();
            }));

            NSNotificationCenter.DefaultCenter.AddObserver(NSWindow.DidEndLiveResizeNotification, notif => DispatchService.GuiDispatch(() => {
                if (!IsCorrectNotification(selector, notif.Object))
                {
                    return;
                }

                if (resizeTimer != null)
                {
                    resizeTimer.Dispose();
                }

                resizeTimer = Application.TimeoutInvoke(300, selector.RequestResize);
            }));

            var pathSelector = (SelectorView.PathSelectorView)selector.Subviews [0];

            pathSelector.ConfigurationChanged += (sender, e) => {
                if (ConfigurationChanged != null)
                {
                    ConfigurationChanged(sender, e);
                }
            };
            pathSelector.RuntimeChanged += (sender, ea) => {
                if (RuntimeChanged != null)
                {
                    RuntimeChanged(sender, ea);
                }
            };
            return(item);
        }
Example #9
0
		NSToolbarItem CreateSelectorToolbarItem ()
		{
			var selector = new SelectorView ();
			viewCache.Add (selector);
			var item = new NSToolbarItem (SelectorId) {
				View = selector,
				MinSize = new CGSize (150, 25),
				MaxSize = new CGSize (150, 25),
			};
			selector.ResizeRequested += (o, e) => {
				item.MinSize = item.MaxSize = e.Size;
				centeringSpace.UpdateWidth ();
			};

			var pathSelector = (SelectorView.PathSelectorView)selector.Subviews [0];
			pathSelector.ConfigurationChanged += (sender, e) => {
				if (ConfigurationChanged != null)
					ConfigurationChanged (sender, e);
			};
			pathSelector.RuntimeChanged += (sender, ea) => {
				if (RuntimeChanged != null)
					RuntimeChanged (sender, ea);
			};
			return item;
		}