示例#1
0
        internal void UpdateToolBar()
        {
            if (NSApplication.SharedApplication.MainWindow == null)
            {
                return;
            }

            if (_navigation == null)
            {
                if (_toolbar != null)
                {
                    _toolbar.Visible = false;
                }
                _toolbar = null;
                return;
            }

            var currentPage = _navigation.Peek(0);

            if (NavigationPage.GetHasNavigationBar(currentPage))
            {
                if (_toolbar == null)
                {
                    _toolbar = ConfigureToolbar();
                    NSApplication.SharedApplication.MainWindow.Toolbar = _toolbar;

                    _toolbar.InsertItem(NavigationGroupIdentifier, 0);
                    _toolbar.InsertItem(
                        HasTabs ? NSToolbar.NSToolbarSpaceItemIdentifier : NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, 1);
                    _toolbar.InsertItem(HasTabs ? TabbedGroupIdentifier : TitleGroupIdentifier, 2);
                    _toolbar.InsertItem(NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, 3);
                    _toolbar.InsertItem(ToolbarItemsGroupIdentifier, 4);
                }

                _toolbar.Visible = true;
                UpdateToolbarItems();
                UpdateTitle();
                UpdateNavigationItems();
                if (HasTabs)
                {
                    UpdateTabbedItems();
                }
                UpdateBarBackgroundColor();
            }
            else
            {
                if (_toolbar != null)
                {
                    _toolbar.Visible = false;
                }
            }
        }
示例#2
0
        internal void Initialize()
        {
            int total = -1;

            widget.InsertItem(RunButtonId, runButtonIdx           = ++total);
            widget.InsertItem(SelectorId, selectorIdx             = ++total);
            widget.InsertItem(CenteringSpaceId, buttonBarStartIdx = ++total);
            widget.InsertItem(StatusBarId, statusBarIdx           = ++total);
            widget.InsertItem(NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, ++total);
            widget.InsertItem(SearchBarId, searchEntryIdx = ++total);
        }
示例#3
0
        internal void Initialize()
        {
            int total = -1;

            widget.InsertItem(RunButtonId, runButtonIdx           = ++total);
            widget.InsertItem(SelectorId, selectorIdx             = ++total);
            widget.InsertItem(CenteringSpaceId, buttonBarStartIdx = ++total);
            widget.InsertItem(StatusBarId, statusBarIdx           = ++total);
            widget.InsertItem(NSToolbar.NSToolbarFlexibleSpaceItemIdentifier, ++total);
            widget.InsertItem(SearchBarId, searchEntryIdx = ++total);

            // NSButton -> NSToolbarItemViewer -> _NSToolbarClipView -> NSToolbarView -> NSToolbarClippedItemsIndicator
            viewCache.Add(runButton.Superview.Superview.Superview);
        }
示例#4
0
        /// <summary>
        /// Adds an item to a toolbar.
        /// </summary>
        /// <param name="toolbar">The <see cref=">NSToolbar"/> to which an item is to be added.</param>
        /// <param name="toolbarItem">The <see cref="NSToolbarItem"/> to be added to the toolbar.</param>
        /// <param name="itemIdentifier">The item's unique identifier.</param>
        /// <param name="insertLocation">The location in the toolbar at which the item is to be inserted.</param>
        public static void AddToolbarItem(this NSToolbar toolbar, NSToolbarItem toolbarItem, string itemIdentifier, int insertLocation)
        {
            if (toolbar.DefaultItemIdentifiers == null)
            {
                toolbar.DefaultItemIdentifiers = NSToolbarIdentifiers;
            }
            if (toolbar.AllowedItemIdentifiers == null)
            {
                toolbar.AllowedItemIdentifiers = NSToolbarIdentifiers;
            }
            if (toolbar.SelectableItemIdentifiers == null)
            {
                // HACK WORKAROUND for bug https://bugzilla.xamarin.com/show_bug.cgi?id=21680
                toolbar.SelectableItemIdentifiers = BugWorkaround;
            }
            var prevWillAdd = toolbar.WillInsertItem;

            toolbar.WillInsertItem = (t, i, b) => toolbarItem;
            toolbar.InsertItem(itemIdentifier, insertLocation);
            toolbar.WillInsertItem = prevWillAdd;
        }
示例#5
0
 internal void Initialize()
 {
     widget.InsertItem(AwesomeBarId, 0);
 }
示例#6
0
        public SessionToolbarDelegate(
            ClientSession clientSession,
            MacClientSessionViewControllers viewControllers,
            NSToolbar toolbar)
        {
            if (clientSession == null)
            {
                throw new ArgumentNullException(nameof(clientSession));
            }

            if (viewControllers == null)
            {
                throw new ArgumentNullException(nameof(viewControllers));
            }

            if (toolbar == null)
            {
                throw new ArgumentNullException(nameof(toolbar));
            }

            allowedItemIdentifiers = clientSession.SessionKind == ClientSessionKind.LiveInspection
                ? Identifiers.InspectorDefault
                : Identifiers.WorkbooksDefault;

            this.toolbar = toolbar;

            toolbar.Delegate = this;

            runAllItem = CreateButton(
                Identifiers.RunAll,
                "runAllSubmissions:",
                Catalog.GetString("Run All"),
                Catalog.GetString("Run the whole workbook from top to bottom"),
                "ToolbarRunTemplate");

            refreshItem = CreateButton(
                Identifiers.Refresh,
                "refreshVisualTree:",
                Catalog.GetString("Refresh"),
                Catalog.GetString("Refresh the application's visual tree in Inspector"),
                "ToolbarRefreshTemplate");

            inspectItem = CreateButton(
                Identifiers.Inspect,
                "inspectView:",
                Catalog.GetString("Inspect"),
                Catalog.GetString("Select a UI element to inspect in the running application"),
                "ToolbarInspectTemplate");

            var targetSelector = new WorkbookTargetSelector(
                clientSession.ViewControllers.WorkbookTargets)
            {
                Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize)
            };

            var targetSelectorItemMenu = new NSMenuItem(Catalog.GetString("Target"));

            targetSelectorItemMenu.Submenu = targetSelector.Menu;

            targetSelectorItem = new NSToolbarItem(Identifiers.TargetSelector)
            {
                View                   = targetSelector,
                MinSize                = targetSelector.Frame.Size,
                MaxSize                = targetSelector.Frame.Size,
                VisibilityPriority     = -1000,
                MenuFormRepresentation = targetSelectorItemMenu
            };

            targetSelector.Activated += (sender, e) => {
                var size = targetSelector.GetToolbarSize();
                targetSelectorItem.MinSize = size;
                targetSelectorItem.MaxSize = size;
                centeringItem.UpdateWidth();
                viewControllers.WindowTabs.SelectedTabViewItemIndex = 0;
            };

            centeringItem = new CenteringToolbarItem(Identifiers.CenteringSpacer);

            statusItem = new StatusToolbarItem {
                View = viewControllers.Status.View
            };

            tabViewItem = new NSToolbarItem(Identifiers.TabView)
            {
                PaletteLabel = Catalog.GetString("Views")
            };

            tabViewItem.View = viewControllers.WindowTabs.ToolbarSegmentedControl;

            viewControllers.WindowTabs.ItemSelected += (sender, e) => {
                switch (viewControllers.WindowTabs.SelectedTabViewItemIndex)
                {
                case 0:
                    RemoveItem(Identifiers.Inspect);
                    RemoveItem(Identifiers.Refresh);
                    if (clientSession.SessionKind != ClientSessionKind.LiveInspection)
                    {
                        toolbar.InsertItem(Identifiers.RunAll, 0);
                    }
                    ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = false;
                    break;

                case 1:
                    RemoveItem(Identifiers.RunAll);
                    toolbar.InsertItem(Identifiers.Inspect, 0);
                    toolbar.InsertItem(Identifiers.Refresh, 0);
                    ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = true;
                    break;
                }

                centeringItem.UpdateWidth();
            };

            NSWindow.Notifications.ObserveDidResize((sender, e) => {
                statusItem.UpdateSize(e.Notification.Object as NSWindow);
                centeringItem.UpdateWidth();
            });
        }