示例#1
0
        public MacDebuggerObjectNameView(MacObjectValueTreeView treeView) : base(treeView, "name")
        {
            ImageView = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            TextField = new MacDebuggerTextField(this)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                MaximumNumberOfLines = 1,
                DrawsBackground      = false,
                Bordered             = false,
                Editable             = false
            };

            AddSubview(ImageView);
            AddSubview(TextField);

            AddNewExpressionButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AccessibilityTitle = GettextCatalog.GetString("Add new expression"),
                Image      = GetImage("gtk-add", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            AddNewExpressionButton.Activated += OnAddNewExpressionButtonClicked;

            PreviewButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image      = GetImage("md-empty", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            PreviewButton.Activated += OnPreviewButtonClicked;
        }
示例#2
0
        public MacDebuggerObjectPinView(MacObjectValueTreeView treeView) : base(treeView, "pin")
        {
            PinButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BezelStyle = NSBezelStyle.Inline,
                Image      = none,
                Bordered   = false,
            };
            PinButton.AccessibilityTitle = GettextCatalog.GetString("Pin to the editor");
            PinButton.Activated         += OnPinButtonClicked;
            AddSubview(PinButton);

            LiveUpdateButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BezelStyle = NSBezelStyle.Inline,
                Image      = liveUpdateOffImage,
                Bordered   = false
            };
            LiveUpdateButton.AccessibilityTitle = GettextCatalog.GetString("Refresh value");
            LiveUpdateButton.Activated         += OnLiveUpdateButtonClicked;
            AddSubview(LiveUpdateButton);

            PinButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active             = true;
            PinButton.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, MarginSize).Active = true;
            PinButton.WidthAnchor.ConstraintEqualToConstant(ImageSize).Active  = true;
            PinButton.HeightAnchor.ConstraintEqualToConstant(ImageSize).Active = true;

            LiveUpdateButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active = true;
            LiveUpdateButton.LeadingAnchor.ConstraintEqualToAnchor(PinButton.TrailingAnchor, RowCellSpacing).Active = true;
            LiveUpdateButton.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize).Active             = true;
            LiveUpdateButton.WidthAnchor.ConstraintEqualToConstant(ImageSize).Active  = true;
            LiveUpdateButton.HeightAnchor.ConstraintEqualToConstant(ImageSize).Active = true;
        }
        public MacDebuggerObjectNameView(MacObjectValueTreeView treeView) : base(treeView, "name")
        {
            ImageView = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            TextField = new EditableTextField(this)
            {
                AutoresizingMask = NSViewResizingMask.WidthSizable,
                TranslatesAutoresizingMaskIntoConstraints = false,
                DrawsBackground = false,
                Bordered        = false,
                Editable        = false
            };
            TextField.Cell.UsesSingleLineMode = true;
            TextField.Cell.Wraps = false;

            AddSubview(ImageView);
            AddSubview(TextField);

            PreviewButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Image      = GetImage("md-empty", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            PreviewButton.Activated += OnPreviewButtonClicked;
        }
示例#4
0
        public void Measure(MacObjectValueTreeView treeView)
        {
            if (OptimalXOffset < 0)
            {
                nfloat offset = 17.0f;
                var    node   = Target;

                while (!(node.Parent is RootObjectValueNode))
                {
                    node    = node.Parent;
                    offset += 16.0f;
                }

                OptimalXOffset = offset;
            }

            if (OptimalNameFont != treeView.CustomFont || OptimalNameWidth < 0)
            {
                OptimalNameWidth = MacDebuggerObjectNameView.GetOptimalWidth(treeView, Target);
                OptimalNameFont  = treeView.CustomFont;
            }

            if (OptimalValueFont != treeView.CustomFont || OptimalValueWidth < 0)
            {
                OptimalValueWidth = MacDebuggerObjectValueView.GetOptimalWidth(treeView, Target, HideValueButton);
                OptimalValueFont  = treeView.CustomFont;
            }
        }
        public MacDebuggerObjectValueView(MacObjectValueTreeView treeView) : base(treeView, "value")
        {
            spinner = new NSProgressIndicator(new CGRect(0, 0, ImageSize, ImageSize))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Style         = NSProgressIndicatorStyle.Spinning,
                Indeterminate = true
            };

            statusIcon = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            colorPreview = new NSView(new CGRect(0, 0, ImageSize, ImageSize))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                WantsLayer = true
            };

            valueButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Title      = GettextCatalog.GetString("Show More"),
                BezelStyle = NSBezelStyle.Inline
            };
            valueButton.Cell.UsesSingleLineMode = true;
            UpdateFont(valueButton, -3);
            valueButton.Activated += OnValueButtonActivated;

            int imageSize = treeView.CompactView ? CompactImageSize : ImageSize;

            viewerButton = new NSButton {
                AccessibilityTitle = GettextCatalog.GetString("Open Value Visualizer"),
                Image = GetImage(Gtk.Stock.Edit, imageSize, imageSize),
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            viewerButton.BezelStyle = NSBezelStyle.Inline;
            viewerButton.Bordered   = false;
            viewerButton.Activated += OnViewerButtonActivated;

            TextField = new MacDebuggerTextField(this)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LineBreakMode        = NSLineBreakMode.Clipping,
                MaximumNumberOfLines = 1,
                DrawsBackground      = false,
                Bordered             = false,
                Editable             = false
            };

            AddSubview(TextField);
        }
示例#6
0
        public MacDebuggerObjectTypeView(MacObjectValueTreeView treeView) : base(treeView, "type")
        {
            TextField = new NSTextField {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor      = NSColor.Clear,
                MaximumNumberOfLines = 1,
                Bordered             = false,
                Editable             = false
            };

            AddSubview(TextField);

            TextField.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active                = true;
            TextField.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, MarginSize).Active    = true;
            TextField.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize).Active = true;
        }
        public static nfloat GetOptimalWidth(MacObjectValueTreeView treeView, ObjectValueNode node)
        {
            nfloat optimalWidth = MarginSize;

            var editable    = treeView.AllowWatchExpressions && node.Parent is RootObjectValueNode;
            var placeholder = string.Empty;
            var name        = node.Name;

            if (node.IsUnknown)
            {
            }
            else if (node.IsError || node.IsNotSupported)
            {
            }
            else if (node.IsImplicitNotSupported)
            {
            }
            else if (node.IsEvaluating)
            {
            }
            else if (node.IsEnumerable)
            {
            }
            else if (node is AddNewExpressionObjectValueNode)
            {
                placeholder = GettextCatalog.GetString("Add new expression");
                name        = string.Empty;
                editable    = true;
            }

            optimalWidth += ImageSize;
            optimalWidth += RowCellSpacing;

            var value = editable && string.IsNullOrEmpty(name) ? placeholder : name;

            optimalWidth += GetWidthForString(treeView.CustomFont, value);

            if (MacObjectValueTreeView.ValidObjectForPreviewIcon(node))
            {
                optimalWidth += RowCellSpacing;
                optimalWidth += ImageSize;
            }

            optimalWidth += MarginSize;

            return(optimalWidth);
        }
        public MacObjectValueTreeViewDataSource(MacObjectValueTreeView treeView, ObjectValueNode root, bool allowWatchExpressions)
        {
            AllowWatchExpressions = allowWatchExpressions;
            this.treeView         = treeView;

            Root = new MacObjectValueNode(null, root);
            mapping.Add(root, Root);

            foreach (var child in root.Children)
            {
                Add(Root, child);
            }

            if (allowWatchExpressions)
            {
                Add(Root, new AddNewExpressionObjectValueNode());
            }
        }
        public MacDebuggerObjectTypeView(MacObjectValueTreeView treeView) : base(treeView, "type")
        {
            TextField = new NSTextField {
                AutoresizingMask = NSViewResizingMask.WidthSizable,
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = NSColor.Clear,
                Bordered        = false,
                Editable        = false
            };
            TextField.Cell.UsesSingleLineMode = true;
            TextField.Cell.Wraps = false;

            AddSubview(TextField);

            TextField.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active                = true;
            TextField.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, MarginSize).Active    = true;
            TextField.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize).Active = true;
        }
        void OnPreviewButtonClicked(object sender, EventArgs e)
        {
            if (!TreeView.DebuggerService.CanQueryDebugger || PreviewWindowManager.IsVisible)
            {
                return;
            }

            if (!MacObjectValueTreeView.ValidObjectForPreviewIcon(Node))
            {
                return;
            }

            // convert the buttons frame to window coords
            var buttonLocation = PreviewButton.ConvertPointToView(CoreGraphics.CGPoint.Empty, null);

            // now convert the frame to absolute screen coordinates
            buttonLocation = PreviewButton.Window.ConvertPointToScreen(buttonLocation);

            var nativeRoot = MacInterop.GtkQuartz.GetWindow(IdeApp.Workbench.RootWindow);

            // convert to root window coordinates
            buttonLocation = nativeRoot.ConvertPointFromScreen(buttonLocation);
            // the Cocoa Y axis is flipped, convert to Gtk
            buttonLocation.Y = nativeRoot.Frame.Height - buttonLocation.Y;
            // Gtk coords don't include the toolbar and decorations ofsset, so substract it
            buttonLocation.Y -= nativeRoot.Frame.Height - nativeRoot.ContentView.Frame.Height;

            int width  = (int)PreviewButton.Frame.Width;
            int height = (int)PreviewButton.Frame.Height;

            var buttonArea = new Gdk.Rectangle((int)buttonLocation.X, (int)buttonLocation.Y, width, height);
            var val        = Node.GetDebuggerObjectValue();

            SetPreviewButtonIcon(PreviewButtonIcon.Active);

            DebuggingService.ShowPreviewVisualizer(val, IdeApp.Workbench.RootWindow, buttonArea);

            var metadata = new Dictionary <string, object> ();

            metadata["UIElementName"]    = TreeView.UIElementName;
            metadata["ObjectValue.Type"] = val.TypeName;

            Counters.OpenedPreviewer.Inc(1, null, metadata);
        }
        public MacDebuggerTooltipWindow(PinnedWatchLocation location, StackFrame frame, ObjectValue value, PinnedWatch watch)
        {
            Animates = false;
            Behavior = NSPopoverBehavior.Semitransient;

            controller = new ObjectValueTreeViewController();
            controller.SetStackFrame(frame);
            controller.AllowEditing        = true;
            controller.PinnedWatch         = watch;
            controller.PinnedWatchLocation = location;

            treeView = controller.GetMacControl(ObjectValueTreeViewFlags.TooltipFlags);
            treeView.UIElementName = "Tooltip";
            treeView.NodePinned   += OnPinStatusChanged;
            treeView.StartEditing += OnStartEditing;
            treeView.EndEditing   += OnEndEditing;
            controller.AddValue(value);

            scrollView = new NSScrollView {
                HasVerticalScroller = true,
                AutohidesScrollers  = true,
                DocumentView        = treeView,
                Frame = treeView.Frame
            };

            ContentViewController = new NSViewController {
                View = scrollView
            };

            widthConstraint        = scrollView.WidthAnchor.ConstraintEqualToConstant(treeView.Frame.Width);
            widthConstraint.Active = true;

            heightConstraint        = scrollView.HeightAnchor.ConstraintEqualToConstant(treeView.Frame.Height);
            heightConstraint.Active = true;

            treeView.Resized += OnTreeViewResized;
        }
        protected override void UpdateContents()
        {
            if (Node == null)
            {
                return;
            }

            foreach (var constraint in constraints)
            {
                constraint.Active = false;
                constraint.Dispose();
            }
            constraints.Clear();

            OptimalWidth = MarginSize;

            bool selected = Superview is NSTableRowView rowView && rowView.Selected;
            var  iconName = ObjectValueTreeViewController.GetIcon(Node.Flags);

            ImageView.Image = GetImage(iconName, Gtk.IconSize.Menu, selected);
            constraints.Add(ImageView.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
            constraints.Add(ImageView.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, MarginSize));
            constraints.Add(ImageView.WidthAnchor.ConstraintEqualToConstant(ImageSize));
            constraints.Add(ImageView.HeightAnchor.ConstraintEqualToConstant(ImageSize));

            OptimalWidth += ImageView.Image.Size.Width;
            OptimalWidth += RowCellSpacing;

            var editable    = TreeView.AllowWatchExpressions && Node.Parent is RootObjectValueNode;
            var textColor   = NSColor.ControlText;
            var placeholder = string.Empty;
            var name        = Node.Name;

            if (Node.IsUnknown)
            {
                if (TreeView.DebuggerService.Frame != null)
                {
                    textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
                }
            }
            else if (Node.IsError || Node.IsNotSupported)
            {
            }
            else if (Node.IsImplicitNotSupported)
            {
            }
            else if (Node.IsEvaluating)
            {
                if (Node.GetIsEvaluatingGroup())
                {
                    textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
                }
            }
            else if (Node.IsEnumerable)
            {
            }
            else if (Node is AddNewExpressionObjectValueNode)
            {
                placeholder = GettextCatalog.GetString("Add new expression");
                name        = string.Empty;
                editable    = true;
            }
            else if (TreeView.Controller.GetNodeHasChangedSinceLastCheckpoint(Node))
            {
                textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueModifiedText));
            }

            TextField.PlaceholderAttributedString = GetAttributedPlaceholderString(placeholder);
            TextField.AttributedStringValue       = GetAttributedString(name);
            TextField.TextColor = textColor;
            TextField.Editable  = editable;
            UpdateFont(TextField);
            TextField.SizeToFit();

            OptimalWidth += TextField.Frame.Width;

            constraints.Add(TextField.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
            constraints.Add(TextField.LeadingAnchor.ConstraintEqualToAnchor(ImageView.TrailingAnchor, RowCellSpacing));

            if (MacObjectValueTreeView.ValidObjectForPreviewIcon(Node))
            {
                SetPreviewButtonIcon(PreviewButtonIcon.Hidden);

                if (!previewIconVisible)
                {
                    AddSubview(PreviewButton);
                    previewIconVisible = true;
                }

                constraints.Add(TextField.WidthAnchor.ConstraintGreaterThanOrEqualToConstant(TextField.Frame.Width));
                constraints.Add(PreviewButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(PreviewButton.LeadingAnchor.ConstraintEqualToAnchor(TextField.TrailingAnchor, RowCellSpacing));
                constraints.Add(PreviewButton.WidthAnchor.ConstraintEqualToConstant(ImageSize));
                constraints.Add(PreviewButton.HeightAnchor.ConstraintEqualToConstant(ImageSize));

                OptimalWidth += RowCellSpacing;
                OptimalWidth += PreviewButton.Frame.Width;
            }
            else
            {
                if (previewIconVisible)
                {
                    PreviewButton.RemoveFromSuperview();
                    previewIconVisible = false;
                }

                constraints.Add(TextField.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize));
            }

            foreach (var constraint in constraints)
            {
                constraint.Active = true;
            }

            OptimalWidth += MarginSize;
        }
        public static nfloat GetOptimalWidth(MacObjectValueTreeView treeView, ObjectValueNode node, bool hideValueButton)
        {
            nfloat optimalWidth       = MarginSize;
            string evaluateStatusIcon = null;
            string valueButtonText    = null;
            var    showViewerButton   = false;
            Color? previewColor       = null;
            bool   showSpinner        = false;
            string strval;

            if (node.IsUnknown)
            {
                if (treeView.DebuggerService.Frame != null)
                {
                    strval = GettextCatalog.GetString("The name '{0}' does not exist in the current context.", node.Name);
                }
                else
                {
                    strval = string.Empty;
                }
                evaluateStatusIcon = Ide.Gui.Stock.Warning;
            }
            else if (node.IsError || node.IsNotSupported)
            {
                evaluateStatusIcon = Ide.Gui.Stock.Warning;
                strval             = node.Value ?? string.Empty;
                int i = strval.IndexOf('\n');
                if (i != -1)
                {
                    strval = strval.Substring(0, i);
                }
            }
            else if (node.IsImplicitNotSupported)
            {
                strval = string.Empty;                //val.Value; with new "Show Value" button we don't want to display message "Implicit evaluation is disabled"
                if (node.CanRefresh)
                {
                    valueButtonText = GettextCatalog.GetString("Show Value");
                }
            }
            else if (node.IsEvaluating)
            {
                strval      = GettextCatalog.GetString("Evaluating\u2026");
                showSpinner = true;
            }
            else if (node.IsEnumerable)
            {
                if (node is ShowMoreValuesObjectValueNode)
                {
                    valueButtonText = GettextCatalog.GetString("Show More");
                }
                else
                {
                    valueButtonText = GettextCatalog.GetString("Show Values");
                }
                strval = string.Empty;
            }
            else if (node is AddNewExpressionObjectValueNode)
            {
                strval = string.Empty;
            }
            else
            {
                strval = treeView.Controller.GetDisplayValueWithVisualisers(node, out showViewerButton);

                var val = node.GetDebuggerObjectValue();
                if (val != null && !val.IsNull && DebuggingService.HasGetConverter <Color> (val))
                {
                    try {
                        previewColor = DebuggingService.GetGetConverter <Color> (val).GetValue(val);
                    } catch {
                        previewColor = null;
                    }
                }
            }

            strval = strval.Replace("\r\n", " ").Replace("\n", " ");

            // First item: Status Icon -or- Spinner
            if (evaluateStatusIcon != null)
            {
                optimalWidth += ImageSize;
                optimalWidth += RowCellSpacing;
            }

            if (showSpinner)
            {
                optimalWidth += ImageSize;
                optimalWidth += RowCellSpacing;
            }

            // Second Item: Color Preview
            if (previewColor.HasValue)
            {
                optimalWidth += ImageSize;
                optimalWidth += RowCellSpacing;
            }

            // Third Item: Value Button
            if (valueButtonText != null && !hideValueButton)
            {
                optimalWidth += GetWidthForString(treeView.CustomFont, valueButtonText, -3);
                optimalWidth += RowCellSpacing;
            }

            // Fourth Item: Viewer Button
            if (showViewerButton)
            {
                optimalWidth += treeView.CompactView ? CompactImageSize : ImageSize;
                optimalWidth += RowCellSpacing;
            }

            // Fifth Item: Text Value
            optimalWidth += GetWidthForString(treeView.CustomFont, strval);
            optimalWidth += MarginSize;

            return(optimalWidth);
        }
示例#14
0
        Widget CreateExceptionValueTreeView()
        {
            Widget scrolledWidget = null;

            if (useNewTreeView)
            {
                controller = new ObjectValueTreeViewController();
                controller.SetStackFrame(DebuggingService.CurrentFrame);
                controller.AllowExpanding = true;

                if (Platform.IsMac)
                {
                    macExceptionValueTreeView = controller.GetMacControl(ObjectValueTreeViewFlags.ObjectValuePadFlags);
                    macExceptionValueTreeView.UIElementName = "ExceptionCaughtDialog";
                }
                else
                {
                    exceptionValueTreeView = controller.GetGtkControl(ObjectValueTreeViewFlags.ExceptionCaughtFlags);
                }
            }
            else
            {
                var objValueTreeView = new ObjectValueTreeView();
                objValueTreeView.Frame          = DebuggingService.CurrentFrame;
                objValueTreeView.AllowPopupMenu = false;
                objValueTreeView.AllowExpanding = true;
                objValueTreeView.AllowPinning   = false;
                objValueTreeView.AllowEditing   = false;
                objValueTreeView.AllowAdding    = false;

                exceptionValueTreeView = objValueTreeView;
            }

            if (useNewTreeView && Platform.IsMac)
            {
                var scrolled = new AppKit.NSScrollView {
                    DocumentView          = macExceptionValueTreeView,
                    AutohidesScrollers    = true,
                    HasVerticalScroller   = true,
                    HasHorizontalScroller = true,
                };

                // disable implicit animations
                scrolled.WantsLayer    = true;
                scrolled.Layer.Actions = new NSDictionary(
                    "actions", NSNull.Null,
                    "contents", NSNull.Null,
                    "hidden", NSNull.Null,
                    "onLayout", NSNull.Null,
                    "onOrderIn", NSNull.Null,
                    "onOrderOut", NSNull.Null,
                    "position", NSNull.Null,
                    "sublayers", NSNull.Null,
                    "transform", NSNull.Null,
                    "bounds", NSNull.Null);

                var host = new GtkNSViewHost(scrolled);
                host.ShowAll();
                scrolledWidget = host;
            }
            else
            {
                exceptionValueTreeView.ModifyBase(StateType.Normal, Styles.ExceptionCaughtDialog.ValueTreeBackgroundColor.ToGdkColor());
                exceptionValueTreeView.ModifyBase(StateType.Active, Styles.ObjectValueTreeActiveBackgroundColor.ToGdkColor());
                exceptionValueTreeView.ModifyFont(Pango.FontDescription.FromString(Platform.IsWindows ? "9" : "11"));
                exceptionValueTreeView.RulesHint = false;
                exceptionValueTreeView.CanFocus  = true;
                exceptionValueTreeView.Show();

                var scrolled = new ScrolledWindow {
                    CanFocus         = true,
                    HscrollbarPolicy = PolicyType.Automatic,
                    VscrollbarPolicy = PolicyType.Automatic
                };

                scrolled.ShadowType = ShadowType.None;
                scrolled.Add(exceptionValueTreeView);
                scrolled.Show();
                scrolledWidget = scrolled;
            }

            var label = new Label();

            label.Markup = "<b>" + GettextCatalog.GetString("Properties") + "</b>";
            label.Xalign = 0;
            label.Xpad   = 10;

            if (exceptionValueTreeView != null)
            {
                exceptionValueTreeView.SetCommonAccessibilityAttributes("ExceptionCaughtDialog.ExceptionValueTreeView", label, null);
            }
            else
            {
                macExceptionValueTreeView.AccessibilityTitle = new NSString(label.Text);
            }

            var vbox = new VBox();

            vbox.PackStart(label, false, false, 12);
            vbox.PackStart(scrolledWidget, true, true, 0);
            vbox.ShowAll();

            return(vbox);
        }
示例#15
0
 public MacObjectValueTreeViewDelegate(MacObjectValueTreeView treeView)
 {
     this.treeView = treeView;
 }
        protected override void UpdateContents()
        {
            if (Node == null)
            {
                return;
            }

            foreach (var constraint in constraints)
            {
                constraint.Active = false;
                constraint.Dispose();
            }
            constraints.Clear();

            OptimalWidth = MarginSize;

            var editable             = TreeView.AllowWatchExpressions && Node.Parent is RootObjectValueNode;
            var selected             = Superview is NSTableRowView rowView && rowView.Selected;
            var iconName             = ObjectValueTreeViewController.GetIcon(Node.Flags);
            var wrapper              = (MacObjectValueNode)ObjectValue;
            var textColor            = NSColor.ControlText;
            var showAddNewExpression = false;
            var placeholder          = string.Empty;
            var name = Node.Name;

            if (Node.IsUnknown)
            {
                if (!selected && TreeView.DebuggerService.Frame != null)
                {
                    textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
                }
            }
            else if (Node.IsError || Node.IsNotSupported)
            {
            }
            else if (Node.IsImplicitNotSupported)
            {
            }
            else if (Node.IsEvaluating)
            {
                if (!selected && Node.GetIsEvaluatingGroup())
                {
                    textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueDisabledText));
                }
            }
            else if (Node.IsEnumerable)
            {
            }
            else if (Node is AddNewExpressionObjectValueNode)
            {
                placeholder          = GettextCatalog.GetString("Add item to watch");
                showAddNewExpression = true;
                name     = string.Empty;
                editable = true;
            }
            else if (!selected && TreeView.Controller.GetNodeHasChangedSinceLastCheckpoint(Node))
            {
                textColor = NSColor.FromCGColor(GetCGColor(Styles.ObjectValueTreeValueModifiedText));
            }

            NSView firstView;

            if (showAddNewExpression)
            {
                AddNewExpressionButton.Image = GetImage("gtk-add", Gtk.IconSize.Menu, selected);
                firstView = AddNewExpressionButton;

                if (!addNewExpressionVisible)
                {
                    ImageView.RemoveFromSuperview();
                    AddSubview(AddNewExpressionButton);
                    addNewExpressionVisible = true;
                }
            }
            else
            {
                ImageView.Image = GetImage(iconName, Gtk.IconSize.Menu, selected);
                firstView       = ImageView;

                if (addNewExpressionVisible)
                {
                    AddNewExpressionButton.RemoveFromSuperview();
                    addNewExpressionVisible = false;
                    AddSubview(ImageView);
                }
            }

            constraints.Add(firstView.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
            constraints.Add(firstView.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, MarginSize));
            constraints.Add(firstView.WidthAnchor.ConstraintEqualToConstant(ImageSize));
            constraints.Add(firstView.HeightAnchor.ConstraintEqualToConstant(ImageSize));

            OptimalWidth += ImageSize;
            OptimalWidth += RowCellSpacing;

            TextField.PlaceholderAttributedString = GetAttributedPlaceholderString(placeholder);
            TextField.StringValue = name;
            TextField.TextColor   = textColor;
            TextField.Editable    = editable;
            UpdateFont(TextField);
            TextField.SizeToFit();
            ImageView.AccessibilityTitle = ObjectValueTreeViewController.GetAccessibilityTitleForIcon(
                Node.Flags,
                GettextCatalog.GetString("Object Name"));

            var value     = editable && string.IsNullOrEmpty(name) ? placeholder : name;
            var textWidth = GetWidthForString(TextField.Font, value);

            OptimalWidth += textWidth;

            NSView textView;

            if (editing)
            {
                textView = editorTextView;

                var span = editor.TextBuffer.CurrentSnapshot.GetEntireSpan();
                editor.TextBuffer.Replace(span, name);

                if (!editorTextViewVisible)
                {
                    TextField.RemoveFromSuperview();
                    editorTextViewVisible = true;
                    AddSubview(textView);
                }

                constraints.Add(textView.TopAnchor.ConstraintEqualToAnchor(TopAnchor, (nfloat)editor.FormattedLineSource.BaseIndentation));
                constraints.Add(textView.BottomAnchor.ConstraintEqualToAnchor(BottomAnchor, (nfloat)editor.FormattedLineSource.BaseIndentation));
            }
            else
            {
                textView = TextField;

                if (editorTextViewVisible)
                {
                    editorTextView.RemoveFromSuperview();
                    editorTextViewVisible = false;
                    AddSubview(TextField);
                }

                constraints.Add(TextField.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
            }

            constraints.Add(textView.LeadingAnchor.ConstraintEqualToAnchor(firstView.TrailingAnchor, RowCellSpacing));

            if (!editing && MacObjectValueTreeView.ValidObjectForPreviewIcon(Node))
            {
                SetPreviewButtonIcon(PreviewButtonIcon.Hidden);

                if (!previewIconVisible)
                {
                    AddSubview(PreviewButton);
                    previewIconVisible = true;
                }

                constraints.Add(TextField.WidthAnchor.ConstraintGreaterThanOrEqualToConstant(textWidth));
                constraints.Add(PreviewButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor));
                constraints.Add(PreviewButton.LeadingAnchor.ConstraintEqualToAnchor(TextField.TrailingAnchor, RowCellSpacing));
                constraints.Add(PreviewButton.WidthAnchor.ConstraintEqualToConstant(ImageSize));
                constraints.Add(PreviewButton.HeightAnchor.ConstraintEqualToConstant(ImageSize));

                OptimalWidth += RowCellSpacing;
                OptimalWidth += ImageSize;
            }
            else
            {
                if (previewIconVisible)
                {
                    PreviewButton.RemoveFromSuperview();
                    previewIconVisible = false;
                }

                constraints.Add(textView.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -MarginSize));
            }

            foreach (var constraint in constraints)
            {
                constraint.Active = true;
            }

            OptimalWidth += MarginSize;

            wrapper.OptimalNameFont  = TreeView.CustomFont;
            wrapper.OptimalNameWidth = OptimalWidth;
            wrapper.OptimalXOffset   = Frame.X;
        }
示例#17
0
        public ObjectValuePad(bool allowWatchExpressions = false)
        {
            if (UseNewTreeView)
            {
                controller = new ObjectValueTreeViewController(allowWatchExpressions);
                controller.AllowEditing = true;

                if (Platform.IsMac)
                {
                    LoggingService.LogInfo("Using MacObjectValueTreeView for {0}", allowWatchExpressions ? "Watch Pad" : "Locals Pad");
                    var treeView = controller.GetMacControl(ObjectValueTreeViewFlags.ObjectValuePadFlags);
                    _treeview = treeView;

                    fontChanger = new PadFontChanger(treeView, treeView.SetCustomFont, treeView.QueueResize);

                    var scrolled = new AppKit.NSScrollView {
                        DocumentView          = treeView,
                        AutohidesScrollers    = false,
                        HasVerticalScroller   = true,
                        HasHorizontalScroller = true,
                    };

                    // disable implicit animations
                    scrolled.WantsLayer    = true;
                    scrolled.Layer.Actions = new NSDictionary(
                        "actions", NSNull.Null,
                        "contents", NSNull.Null,
                        "hidden", NSNull.Null,
                        "onLayout", NSNull.Null,
                        "onOrderIn", NSNull.Null,
                        "onOrderOut", NSNull.Null,
                        "position", NSNull.Null,
                        "sublayers", NSNull.Null,
                        "transform", NSNull.Null,
                        "bounds", NSNull.Null);

                    var host = new GtkNSViewHost(scrolled);
                    host.ShowAll();

                    control = host;
                }
                else
                {
                    LoggingService.LogInfo("Using GtkObjectValueTreeView for {0}", allowWatchExpressions ? "Watch Pad" : "Locals Pad");
                    var treeView = controller.GetGtkControl(ObjectValueTreeViewFlags.ObjectValuePadFlags);
                    treeView.Show();

                    fontChanger = new PadFontChanger(treeView, treeView.SetCustomFont, treeView.QueueResize);

                    var scrolled = new ScrolledWindow {
                        HscrollbarPolicy = PolicyType.Automatic,
                        VscrollbarPolicy = PolicyType.Automatic
                    };
                    scrolled.Add(treeView);
                    scrolled.Show();

                    control = scrolled;
                }
            }
            else
            {
                LoggingService.LogInfo("Using old ObjectValueTreeView for {0}", allowWatchExpressions ? "Watch Pad" : "Locals Pad");
                tree              = new ObjectValueTreeView();
                tree.AllowAdding  = allowWatchExpressions;
                tree.AllowEditing = true;
                tree.Show();

                fontChanger = new PadFontChanger(tree, tree.SetCustomFont, tree.QueueResize);

                var scrolled = new ScrolledWindow {
                    HscrollbarPolicy = PolicyType.Automatic,
                    VscrollbarPolicy = PolicyType.Automatic
                };
                scrolled.Add(tree);
                scrolled.Show();

                control = scrolled;
            }

            DebuggingService.CurrentFrameChanged      += OnFrameChanged;
            DebuggingService.PausedEvent              += OnDebuggerPaused;
            DebuggingService.ResumedEvent             += OnDebuggerResumed;
            DebuggingService.StoppedEvent             += OnDebuggerStopped;
            DebuggingService.EvaluationOptionsChanged += OnEvaluationOptionsChanged;
            DebuggingService.VariableChanged          += OnVariableChanged;

            needsUpdateValues = false;
            needsUpdateFrame  = true;

            //If pad is created/opened while debugging...
            IsInitialResume = !DebuggingService.IsDebugging;
        }
示例#18
0
 protected MacDebuggerObjectCellViewBase(MacObjectValueTreeView treeView, string identifier)
 {
     Identifier = identifier;
     TreeView   = treeView;
 }
        public MacDebuggerObjectNameView(MacObjectValueTreeView treeView) : base(treeView, "name")
        {
            ImageView = new NSImageView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            TextField = new MacDebuggerTextField(this)
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LineBreakMode        = NSLineBreakMode.Clipping,
                MaximumNumberOfLines = 1,
                DrawsBackground      = false,
                Bordered             = false,
                Editable             = false
            };

            AddSubview(ImageView);
            AddSubview(TextField);

            AddNewExpressionButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AccessibilityTitle = GettextCatalog.GetString("Add item to watch"),
                Image      = GetImage("gtk-add", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            AddNewExpressionButton.Activated += OnAddNewExpressionButtonClicked;

            PreviewButton = new NSButton {
                TranslatesAutoresizingMaskIntoConstraints = false,
                AccessibilityTitle = GettextCatalog.GetString("Open Preview Visualizer"),
                Image      = GetImage("md-empty", Gtk.IconSize.Menu),
                BezelStyle = NSBezelStyle.Inline,
                Bordered   = false
            };
            PreviewButton.Activated += OnPreviewButtonClicked;

            var contentTypeRegistry = CompositionManager.Instance.GetExportedValue <IContentTypeRegistryService> ();

            textBufferFactory = CompositionManager.Instance.GetExportedValue <ITextBufferFactoryService> ();
            var factory = CompositionManager.Instance.GetExportedValue <ICocoaTextEditorFactoryService> ();

            contentType = contentTypeRegistry.GetContentType(DebuggerCompletion.ContentType);
            var editorFormatMapService = CompositionManager.Instance.GetExportedValue <IEditorFormatMapService> ();
            var appearanceCategory     = Guid.NewGuid().ToString();
            var editorFormat           = editorFormatMapService.GetEditorFormatMap(appearanceCategory);

            var resourceDictionary = editorFormat.GetProperties("Plain Text");

            resourceDictionary [ClassificationFormatDefinition.TypefaceId]          = TextField.Font;
            resourceDictionary [ClassificationFormatDefinition.FontRenderingSizeId] = TextField.Font.PointSize - 1;
            editorFormat.SetProperties("Plain Text", resourceDictionary);

            var textBuffer = textBufferFactory.CreateTextBuffer("", contentType);

            editor = factory.CreateTextView(textBuffer);
            editor.Options.SetOptionValue(DefaultTextViewOptions.UseVisibleWhitespaceId, false);
            editor.Options.SetOptionValue(DefaultTextViewOptions.AppearanceCategory, appearanceCategory);
            editor.VisualElement.TranslatesAutoresizingMaskIntoConstraints = false;
            editorTextView = new NSView {
                TranslatesAutoresizingMaskIntoConstraints = false, WantsLayer = true
            };
            editorTextView.Layer.BackgroundColor = NSColor.White.CGColor;
            editorTextView.AddSubview(editor.VisualElement);

            editor.VisualElement.TopAnchor.ConstraintEqualToAnchor(editorTextView.TopAnchor).Active       = true;
            editor.VisualElement.LeftAnchor.ConstraintEqualToAnchor(editorTextView.LeftAnchor).Active     = true;
            editor.VisualElement.RightAnchor.ConstraintEqualToAnchor(editorTextView.RightAnchor).Active   = true;
            editor.VisualElement.BottomAnchor.ConstraintEqualToAnchor(editorTextView.BottomAnchor).Active = true;

            editor.LostAggregateFocus += OnEditorLostFocus;
        }