Beispiel #1
0
        protected override void OnDestroyed()
        {
            LogEnter();
            try {
                view?.RemoveFromSuperview();
                view      = null;
                superview = null;

                base.OnDestroyed();
            } finally {
                LogExit();
            }
        }
Beispiel #2
0
 private void Faddout(NSView view)
 {
     NSAnimationContext.BeginGrouping();
     NSAnimationContext.CurrentContext.Duration = 2;
     view.RemoveFromSuperview();
     NSAnimationContext.EndGrouping();
 }
Beispiel #3
0
        private void SwitchSettings(NSView newSettings)
        {
            UnfocusElement(); // update bindings

            bool firstTime = __CurrentSettingsView == null;

            if (__CurrentSettingsView != null)
            {
                __CurrentSettingsView.RemoveFromSuperview();
            }

            CGRect newFrame = new CGRect(
                newSettings.Frame.X,
                SettingsView.Frame.Height - newSettings.Frame.Height,
                newSettings.Frame.Width,
                newSettings.Frame.Height);

            newSettings.Frame = newFrame;

            SettingsView.AddSubview(newSettings);

            __CurrentSettingsView = newSettings;

            // Set new window height
            var newHeight = newSettings.Frame.Height + (Window.Frame.Height - SettingsView.Frame.Bottom);

            CGRect newRect = UIUtils.UpdateHeight(Window.Frame, (float)newHeight);

            Window.SetFrame(newRect, true, !firstTime);
        }
Beispiel #4
0
        private void DisplaySubview(NSViewController controller, SubviewType type)
        {
            // Is this view already displayed?
            if (ViewType == type)
            {
                return;
            }

            // Is there a view already being displayed?
            if (Subview != null)
            {
                // Yes, remove it from the view
                Subview.RemoveFromSuperview();

                // Release memory
                Subview           = null;
                SubviewController = null;
            }

            // Save values
            ViewType          = type;
            SubviewController = controller;
            Subview           = controller.View;

            // Define frame and display
            Subview.Frame = new CGRect(0, 0, ViewContainer.Frame.Width, ViewContainer.Frame.Height);
            ViewContainer.AddSubview(Subview);
        }
Beispiel #5
0
 public void RemoveVoutSubview(NSView view)
 {
     logger.Info("removeVoutSubview:");
     //
     view.RemoveFromSuperview();
     subView = null;
 }
Beispiel #6
0
        // Methods
        protected override void OnRealized()
        {
            WidgetFlags |= WidgetFlags.Realized;
            WindowAttr attributes = default(WindowAttr);

            attributes.X          = Allocation.X;
            attributes.Y          = Allocation.Y;
            attributes.Height     = Allocation.Height;
            attributes.Width      = Allocation.Width;
            attributes.WindowType = Gdk.WindowType.Child;
            attributes.Wclass     = WindowClass.InputOutput;
            attributes.Visual     = Visual;
            attributes.TypeHint   = (WindowTypeHint)100;
            attributes.Colormap   = Colormap;
            attributes.EventMask  = (int)(Events | EventMask.ExposureMask | EventMask.Button1MotionMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.KeyPressMask | EventMask.KeyReleaseMask);
            WindowAttributesType attributes_mask = WindowAttributesType.X | WindowAttributesType.Y | WindowAttributesType.Colormap | WindowAttributesType.Visual;

            GdkWindow          = new Gdk.Window(ParentWindow, attributes, (int)attributes_mask);
            GdkWindow.UserData = Handle;
            Style = Style.Attach(GdkWindow);
            Style.SetBackground(GdkWindow, State);
            WidgetFlags &= ~WidgetFlags.NoWindow;
            NSView nSView = GtkMacInterop.GetNSView(this);

            nSView.RemoveFromSuperview();
            embedParent.AddSubview(nSView);
            nSView.Frame = new CGRect(0, 0, embedParent.Frame.Width, embedParent.Frame.Height);
        }
		public static void BringSubviewToFront(this NSView superView, NSView theView)
		{
			if(theView == null || !superView.Subviews.Contains(theView))
				return;
			theView.RemoveFromSuperview();
			superView.AddSubview(theView);
		}
        public void SetView(View view)
        {
            var oldView        = _virtualView;
            var isFromThisCell = oldView?.ToView() == _nativeView;

            //Apple bug, somehow the view be a weird recycle... So only re-use if the view still matches
            if (isFromThisCell && _virtualView != null && !_virtualView.IsDisposed)
            {
                view = view.Diff(_virtualView, false);
            }

            _virtualView = view;
            var newView = view.ToView();

            if (_nativeView != null && _nativeView != newView)
            {
                _nativeView.RemoveFromSuperview();
            }

            _nativeView = newView;
            if (_nativeView != null && _nativeView.Superview != this)
            {
                AddSubview(_nativeView);
            }
        }
Beispiel #9
0
        public override void Layout()
        {
            const int padding            = 10;
            nfloat    availableHeight    = Frame.Height;
            nfloat    availableWidth     = Frame.Width - padding * 2;
            nfloat    imageWidth         = 0;
            nfloat    accessoryViewWidth = 0;

            if (ImageView != null)
            {
                nfloat imageHeight = imageWidth = availableHeight;
                ImageView.Frame = new CGRect(padding, 0, imageWidth, imageHeight);
            }

            if (AccessoryView != null)
            {
                accessoryViewWidth  = _style == NSTableViewCellStyle.Value1 ? 50 : availableWidth - 100;
                AccessoryView.Frame = new CGRect(availableWidth - accessoryViewWidth + padding, 0, accessoryViewWidth,
                                                 availableHeight);
                foreach (var subView in AccessoryView.Subviews)
                {
                    //try to find the size the control wants, if no width use default width
                    var size = subView.FittingSize;
                    if (size.Width == 0)
                    {
                        size.Width = accessoryViewWidth;
                    }

                    var x = AccessoryView.Bounds.Width - size.Width;
                    var y = (AccessoryView.Bounds.Height - size.Height) / 2;
                    subView.Frame = new CGRect(new CGPoint(x, y), size);
                }
            }

            nfloat labelHeights = availableHeight;
            nfloat labelWidth   = availableWidth - imageWidth - accessoryViewWidth;

            if (DetailTextLabel != null)
            {
                if (!string.IsNullOrEmpty(DetailTextLabel?.StringValue))
                {
                    labelHeights = availableHeight / 2;
                    DetailTextLabel.CenterTextVertically(new CGRect(imageWidth + padding, 0, labelWidth, labelHeights));
                }
            }

            TextLabel?.CenterTextVertically(new CGRect(imageWidth + padding, availableHeight - labelHeights, labelWidth,
                                                       labelHeights));

            var topNSView = Subviews.LastOrDefault();

            if (_contexActionsTrackingView != topNSView)
            {
                _contexActionsTrackingView.RemoveFromSuperview();
                _contexActionsTrackingView.Frame = Frame;
                AddSubview(_contexActionsTrackingView, NSWindowOrderingMode.Above, Subviews.LastOrDefault());
            }
            base.Layout();
        }
Beispiel #10
0
 public static void BringSubviewToFront(this NSView superView, NSView theView)
 {
     if (theView == null || !superView.Subviews.Contains(theView))
     {
         return;
     }
     theView.RemoveFromSuperview();
     superView.AddSubview(theView);
 }
Beispiel #11
0
        protected override void OnDestroyed()
        {
            LogEnter();
            try {
                view?.RemoveFromSuperview();

                if (disposeViewOnGtkDestroy)
                {
                    view?.Dispose();
                }

                view      = null;
                superview = null;

                base.OnDestroyed();
            } finally {
                LogExit();
            }
        }
Beispiel #12
0
 public void SetView(View view)
 {
     //TODO:We should do View Compare
     //view.Diff (view);
     currentContent?.RemoveFromSuperview();
     currentContent = view.ToView();
     currentView    = view;
     Console.WriteLine(currentContent.FittingSize);
     this.AddSubview(currentContent);
 }
Beispiel #13
0
 void SetNativeView(NSView aView)
 {
     if (innerView != null)
     {
         innerView.RemoveFromSuperview();
     }
     innerView       = aView;
     innerView.Frame = Widget.Bounds;
     Widget.AddSubview(innerView);
 }
Beispiel #14
0
 public void RemovePanel(int panel)
 {
     if (panel == 1)
     {
         if (view1 != null)
         {
             view1.RemoveFromSuperview();
             RemoveChildPlacement(view1);
             view1 = null;
         }
     }
     else
     {
         if (view2 != null)
         {
             view2.RemoveFromSuperview();
             RemoveChildPlacement(view2);
             view2 = null;
         }
     }
 }
Beispiel #15
0
        private void DisplaySubview(NSViewController controller, SubviewType type)
        {
            // Is this view already displayed?
            if (ViewType == type)
            {
                return;
            }

            // Is there a view already being displayed?
            if (Subview != null)
            {
                // Yes, remove it from the view
                Subview.RemoveFromSuperview();

                // Release memory
                Subview           = null;
                SubviewController = null;
            }

            // Save values
            ViewType          = type;
            SubviewController = controller;
            Subview           = controller.View;

            // Define frame and display
            Subview.Frame = new CGRect(0, 0, ViewContainer.Frame.Width, ViewContainer.Frame.Height);
            ViewContainer.AddSubview(Subview);

            // Take action on type
            switch (type)
            {
            case SubviewType.TableBinding:
                AddButton.Active    = true;
                EditButton.Active   = true;
                DeleteButton.Active = true;
                Search.Enabled      = true;
                break;

            case SubviewType.CollectionView:
                AddButton.Active    = true;
                EditButton.Active   = true;
                DeleteButton.Active = true;
                Search.Enabled      = true;
                break;

            default:
                AddButton.Active    = false;
                EditButton.Active   = false;
                DeleteButton.Active = false;
                Search.Enabled      = false;
                break;
            }
        }
        public override void Remove(View view)
        {
            if (VirtualView?.View != null)
            {
                VirtualView.View.NeedsLayout -= HandleViewNeedsLayout;
            }

            _content?.RemoveFromSuperview();
            _content = null;

            base.Remove(view);
        }
Beispiel #17
0
        /// <summary>
        /// Tears down.
        /// </summary>
        public void TearDown()
        {
            if (mContentView != null)
            {
                mContentView.RemoveFromSuperview();
            }

            mContentView = null;
            mGridView    = null;
            mRowView     = null;
            Formatter    = null;
        }
Beispiel #18
0
 public static void ReplaceChild(NSView cont, NSView oldView, NSView newView)
 {
     if (cont is IViewContainer)
     {
         ((IViewContainer)cont).ReplaceChild(oldView, newView);
     }
     else if (cont is NSView)
     {
         newView.Frame = oldView.Frame;
         oldView.RemoveFromSuperview();
         newView.AddSubview(newView);
     }
 }
        private void PlatformStop()
        {
            var movieView = _currentVideo.Player;

            movieView.Pause();
            movieView.Seek(CoreMedia.CMTime.Zero);

            nsWindow.ContentView.WillRemoveSubview(view);
            view.RemoveFromSuperview();
            view.Dispose();
            view = null;
            layer.Dispose();
            layer = null;
        }
Beispiel #20
0
        void SetNativeView(NSView aView)
        {
            if (innerView != null)
            {
                innerView.RemoveFromSuperview();
            }
            innerView       = aView;
            innerView.Frame = Widget.Bounds;

            innerView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
            innerView.TranslatesAutoresizingMaskIntoConstraints = true;
            Widget.AutoresizesSubviews = true;

            Widget.AddSubview(innerView);
        }
Beispiel #21
0
        public void SetContent(NSView view)
        {
            var life = currentView as ILifeCycleView;

            life?.ViewWillDissapear();
            currentView?.RemoveFromSuperview();
            view.Frame            = contentView.Bounds;
            currentView           = view;
            view.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;


            life = view as ILifeCycleView;
            life?.ViewWillAppear();

            contentView.AddSubview(view);
        }
Beispiel #22
0
 public void ShowToolkit(bool value)
 {
     if (!value)
     {
         toolkitButton.RemoveFromSuperview();
         rescanSeparator.RemoveFromSuperview();
     }
     else
     {
         if (!stackView.Subviews.Contains(toolkitButton))
         {
             stackView.AddArrangedSubview(toolkitButton);
             stackView.AddArrangedSubview(rescanSeparator);
         }
     }
 }
Beispiel #23
0
        public static void ShowInWindow(this NSView view)
        {
            var window = new NSWindow(
                new CGRect(0, 0, 200, 200),
                NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable,
                NSBackingStore.Buffered,
                false
                );

            if (view.Superview != null)
            {
                view.RemoveFromSuperview();
            }

            window.ContentView.AddSubview(view);

            window.ContentView.AddConstraints(FillHorizontal(view, false));
            window.ContentView.AddConstraints(FillVertical(view, false));

            window.MakeKeyAndOrderFront(view);
        }
Beispiel #24
0
        public void SetContent(IWidgetBackend child)
        {
            if (currentChild != null)
            {
                currentChild.RemoveFromSuperview();
                currentChild = null;
            }
            if (child == null)
            {
                return;
            }

            var childBackend = (ViewBackend)child;

            childBackend.SizeToFit();

            currentChild = childBackend.Widget;

            Widget.AddSubview(currentChild);
            ResetFittingSize();
        }
        private void ShowPanel(NSViewController controller)
        {
            // Is there a view already being displayed?
            if (_subview != null)
            {
                // Yes, remove it from the view
                _subview.RemoveFromSuperview();

                // Release memory
                _subview           = null;
                _subviewController = null;
            }

            // Save values
            _subviewController = controller;
            _subview           = controller.View;

            // Define frame and display
            _subview.Frame = new CGRect(0, 0, panelContainer.Frame.Width, panelContainer.Frame.Height);
            panelContainer.AddSubview(_subview);
        }
Beispiel #26
0
        public void SetContent(IWidgetBackend child)
        {
            if (currentChild != null)
            {
                currentChild.RemoveFromSuperview();
                currentChild = null;
            }
            if (child == null)
            {
                return;
            }

            var childBackend = (ViewBackend)child;

            currentChild = GetWidget(childBackend);

            var contentView = (NSView)Widget.ContentView;

            contentView.AddSubview(currentChild);
            ResetFittingSize();
        }
Beispiel #27
0
        bool IViewHierarchyHandler.TryGetHighlightedView(double x, double y, bool clear, out IInspectView highlightedView)
        {
            highlightedView = null;

            MacInspectView view = null;

            foreach (var window in NSApplication.SharedApplication.Windows)
            {
                var position = window.ConvertRectFromScreen(new CGRect(x, y, 1, 1)).Location;
                position = window.ContentView.ConvertPointFromView(position, null);
                view     = HitTestHarder(window.ContentView, position);
                if (view != null)
                {
                    break;
                }
            }

            if (clear || view == null)
            {
                if (selectionLayer != null)
                {
                    selectionLayer.RemoveFromSuperview();
                    selectionLayer.Dispose();
                    selectionLayer = null;
                }

                if (view == null)
                {
                    return(false);
                }

                highlightedView = view;
                return(true);
            }

            selectionLayer  = view.UpdateSelection(selectionLayer ?? new SelectionLayer());
            highlightedView = view;
            return(true);
        }
Beispiel #28
0
        public NSView UpdateSelection(NSView selectionLayerView)
        {
            if (selectionLayerView.Superview != view)
            {
                if (selectionLayerView.Superview != null)
                {
                    selectionLayerView.RemoveFromSuperview();
                }

                view.AddSubview(selectionLayerView);
            }

            var bounds = new CGRect(CGPoint.Empty, view.Bounds.Size);

            selectionLayerView.Frame = bounds;
            var transform      = CATransform3D.Identity;
            var selectionLayer = selectionLayerView.Layer.Sublayers [0];

            var targetLayer = layer;

            if (targetLayer != null)
            {
                var hostLayer = view.Layer;
                bounds    = targetLayer.Bounds;
                transform = targetLayer.TransformToAncestor(hostLayer);
                if (!hostLayer.SublayerTransform.IsIdentity)
                {
                    transform = transform.Concat(
                        hostLayer.GetChildTransform().Invert());
                }
            }

            selectionLayer.Transform   = transform;
            selectionLayer.Bounds      = bounds;
            selectionLayer.AnchorPoint = CGPoint.Empty;
            selectionLayer.Position    = CGPoint.Empty;
            return(selectionLayerView);
        }
Beispiel #29
0
        void SetCurrentView(Element element)
        {
            var menuElement = element as MenuElement;

            if (menuElement == null || menuElement.NavigateView == null)
            {
                return;
            }

            var life = currentView as ILifeCycleView;

            life?.ViewWillDissapear();
            currentView?.RemoveFromSuperview();

            var view = menuElement.NavigateView;

            view.Frame = _mainContentView.Bounds;
            life       = view as ILifeCycleView;
            life?.ViewWillAppear();
            currentView           = view;
            view.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
            _mainContentView.AddSubview(view);
        }
        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;
        }
Beispiel #31
0
 public override void Remove(View view)
 {
     _content?.RemoveFromSuperview();
     base.Remove(view);
 }