Exemple #1
0
 private void LogArrange(View view, CGRect frame)
 {
     if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
     {
         LogArrange(view, (Rect)frame);
     }
 }
Exemple #2
0
 private void LogArrange(View view, CGRect frame)
 {
     if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
     {
         LogArrange(view, (Rect)frame);
     }
 }
Exemple #3
0
        /// <summary>
        /// Handle the native <see cref="View.Transform"/> in the (rare) case that this is a non-IFrameworkElement view with a
        /// non-identity transform.
        /// </summary>
        private IDisposable SettingFrame(View view)
        {
            if (view is IFrameworkElement)
            {
                // This is handled directly in IFrameworkElement.Frame setter
                return(null);
            }

            if (view.Layer?.Transform.IsIdentity ?? true)
            {
                // Transform is identity anyway, or Layer is null
                return(null);
            }

            // If NSView.Transform is not identity, then modifying the frame will give undefined behavior. (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/occ/instp/NSView/transform)
            // We have either already applied the transform to the new frame, or we will reset the transform straight after.
            var transform = view.Layer.Transform;

            view.Layer.Transform = CATransform3D.Identity;
            return(Disposable.Create(reapplyTransform));

            void reapplyTransform()
            {
                view.Layer.Transform = transform;
            }
        }
        public void PrintViewHierarchy(AppKit.NSView vg, System.Text.StringBuilder sb, int level = 0)
        {
            for (int i = 0; i < vg.Subviews.Length; i++)
            {
                var v        = vg.Subviews[i];
                var vElement = v as IFrameworkElement;
                var desc     = string.Concat(Enumerable.Repeat("    |", level)) + $" [{i + 1}/{vg.Subviews.Length}] {v.Class.Name}";
                if (vElement != null)
                {
                    desc += $" -- ActualHeight:{vElement.ActualHeight}, ActualWidth:{vElement.ActualWidth}, Height:{vElement.Height}, Width:{vElement.Width}, DataContext:{(vElement as IDataContextProvider)?.DataContext?.GetType().FullName}";
                    var vTextBlock = vElement as TextBlock;
                    if (vTextBlock != null)
                    {
                        desc += $", Text: {vTextBlock.Text}";
                    }
                }

                sb.AppendLine(desc);
                var childViewGroup = v as AppKit.NSView;
                if (childViewGroup != null)
                {
                    PrintViewHierarchy(childViewGroup, sb, level + 1);
                }
            }
        }
Exemple #5
0
        protected Size DesiredChildSize(View view)
        {
            var uiElement = view as UIElement;

            if (uiElement != null)
            {
                return(uiElement.DesiredSize);
            }
            else
            {
                return(_layoutProperties.GetValue(view, "desiredSize", () => default(Size)));
            }
        }
Exemple #6
0
        partial void SetDesiredChildSize(View view, Size desiredSize)
        {
            var uiElement = view as UIElement;

            if (uiElement != null)
            {
                uiElement.DesiredSize = desiredSize;
            }
            else
            {
                _layoutProperties.SetValue(view, "desiredSize", desiredSize);
            }
        }
Exemple #7
0
        protected Size MeasureChildOverride(View view, Size slotSize)
        {
            var ret = view
                      .SizeThatFits(slotSize.LogicalToPhysicalPixels())
                      .PhysicalToLogicalPixels()
                      .ToFoundationSize();

            // With iOS, a child may return a size that fits that is larger than the suggested size.
            // We don't want that with respects to the Xaml model, so we cap the size to the input constraints.
            ret.Width  = double.IsNaN(ret.Width) ? double.PositiveInfinity : Math.Min(slotSize.Width, ret.Width);
            ret.Height = double.IsNaN(ret.Height) ? double.PositiveInfinity : Math.Min(slotSize.Height, ret.Height);

            return(ret);
        }
Exemple #8
0
        private static void UpdateClip(View view)
        {
            // TODO

            //if (!FeatureConfiguration.UIElement.UseLegacyClipping)
            //{
            //	UIElement.UpdateMask(view, view.Superview);

            //	foreach (var child in view.GetChildren())
            //	{
            //		UIElement.UpdateMask(child, view);
            //	}
            //}
        }
Exemple #9
0
        protected void ArrangeChildOverride(View view, Rect frame)
        {
            var nativeFrame = ViewHelper.LogicalToPhysicalPixels(frame);

            if (nativeFrame != view.Frame)
            {
                LogArrange(view, nativeFrame);

                using (SettingFrame(view))
                {
                    view.Frame = nativeFrame;

                    UpdateClip(view);
                }
            }
        }
Exemple #10
0
        public void ObserverTest()
        {
            bool observed = false;

            using (var o = new UIView()) {
                using (var observer = o.AddObserver("frame", NSKeyValueObservingOptions.OldNew, change => {
                    var old = ((NSValue)change.OldValue).CGRectValue;
                    var @new = ((NSValue)change.NewValue).CGRectValue;
                    Assert.AreEqual("{X=0,Y=0,Width=0,Height=0}", old.ToString(), "#old");
                    Assert.AreEqual("{X=0,Y=0,Width=123,Height=234}", @new.ToString(), "#new");
                    observed = true;
                })) {
                    o.Frame = new RectangleF(0, 0, 123, 234);
                }
            }
            Assert.IsTrue(observed, "observed");
        }
        private UIView SwapViews(UIView oldView, Func <UIView> newViewProvider)
        {
            var currentPosition = oldView?.Superview?.Subviews.IndexOf(oldView) ?? -1;

            if (currentPosition != -1)
            {
                var newContent = newViewProvider();

                var currentSuperview = oldView?.Superview;
                oldView?.RemoveFromSuperview();

                RaiseMaterializing();

#if __IOS__
                currentSuperview?.InsertSubview(newContent, currentPosition);
                return(newContent);
#elif __MACOS__
                if (currentSuperview is {})
Exemple #12
0
        private UIView SwapViews(UIView oldView, Func <UIView> newViewProvider)
        {
            var currentPosition = oldView?.Superview?.Subviews.IndexOf(oldView) ?? -1;

            if (currentPosition != -1)
            {
                var newContent = newViewProvider();

                var currentSuperview = oldView?.Superview;
                oldView?.RemoveFromSuperview();

#if __IOS__
                currentSuperview?.InsertSubview(newContent, currentPosition);
                return(newContent);
#elif __MACOS__
                currentSuperview.AddSubview(newContent, NSWindowOrderingMode.Above, currentSuperview.Subviews[Math.Max(0, currentPosition - 1)]);
                return(newContent);
#endif
            }

            return(null);
        }
Exemple #13
0
 public bool CanCollapse(AppKit.NSSplitView splitView, AppKit.NSView subview)
 {
     return(false);
 }
 public static CGPoint GetPointInView(NSView parentView, CGPoint point)
 {
     return(NSAccessibilityPointInView(parentView, point));
 }
 static extern CGPoint NSAccessibilityPointInView(NSView parentView, CGPoint point);
Exemple #16
0
 public NSSet TouchesMatchingPhaseinView(NSTouchPhase phase, NSView view)
 {
     return(TouchesMatchingPhase(phase, view));
 }
Exemple #17
0
 /// <summary>
 /// Provides the desired size of the element, from the last measure phase.
 /// </summary>
 /// <param name="view">The element to get the measured with</param>
 /// <returns>The measured size</returns>
 Size ILayouter.GetDesiredSize(View view)
 {
     return(DesiredChildSize(view));
 }
        public void EnumerateDraggingItems(NSDraggingItemEnumerationOptions enumOpts, NSView view, NSPasteboardReading [] classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)
        {
            var nsa_classArray = NSArray.FromNSObjects(classArray);

            EnumerateDraggingItems(enumOpts, view, nsa_classArray.Handle, searchOptions, enumerator);
            nsa_classArray.Dispose();
        }
 public void EnumerateDraggingItems(NSDraggingItemEnumerationOptions enumOpts, NSView view, NSArray classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)
 {
     EnumerateDraggingItems(enumOpts, view, classArray.Handle, searchOptions, enumerator);
 }
Exemple #20
0
 public override void LoadView()
 {
     View = new AppKit.NSView(new CGRect(100, 100, 300, 300));
 }
Exemple #21
0
 static void SortSubviews(NSView view, IntPtr function_pointer, IntPtr context)
 {
     MonoDevelop.Components.Mac.Messaging.void_objc_msgSend_IntPtr_IntPtr(view.Handle, sel_sortSubviewsUsingFunction_context_, function_pointer, context);
 }
Exemple #22
0
 public bool TrackMouseinRectofViewuntilMouseUp(NSEvent theEvent, CGRect cellFrame, NSView controlView, bool untilMouseUp)
 {
     return(TrackMouse(theEvent, cellFrame, controlView, untilMouseUp));
 }
Exemple #23
0
 public static void EnumerateDraggingItems(this INSDraggingInfo self, NSDraggingItemEnumerationOptions enumOpts, NSView view, NSArray classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)
 {
     self.EnumerateDraggingItems(enumOpts, view, classArray.Handle, searchOptions, enumerator);
 }
Exemple #24
0
 public static void EnumerateDraggingItems(this INSDraggingInfo self, NSDraggingItemEnumerationOptions enumOpts, NSView view, INSPasteboardReading [] classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)
 {
     using var nsa_classArray = NSArray.FromNSObjects(classArray);
     self.EnumerateDraggingItems(enumOpts, view, nsa_classArray.Handle, searchOptions, enumerator);
 }
 public static CGRect GetFrameInView(NSView parentView, CGRect frame)
 {
     return(NSAccessibilityFrameInView(parentView, frame));
 }
Exemple #26
0
        private void InitializeComponent()
        {
            this.Title      = "Add Figma Package";
            this.StyleMask |= NSWindowStyle.Resizable;
            this.StyleMask |= NSWindowStyle.Closable;
            this.StandardWindowButton(NSWindowButton.ZoomButton).Enabled = false;

            var frame = Frame;

            frame.Size = new CoreGraphics.CGSize(481f, 380f);
            this.SetFrame(frame, true);
            this.ContentMinSize = this.ContentView.Frame.Size;

            // View:     bundleButton
            // NodeName: "bundleButton"
            // NodeType: INSTANCE
            // NodeId:   38:696
            bundleButton                    = new AppKit.NSButton();
            bundleButton.WantsLayer         = true;
            bundleButton.BezelStyle         = NSBezelStyle.Rounded;
            bundleButton.ControlSize        = NSControlSize.Regular;
            bundleButton.Font               = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            bundleButton.Title              = "Add Package";
            bundleButton.KeyEquivalent      = "\r";
            bundleButton.AccessibilityTitle = "Bundle";
            bundleButton.AccessibilityHelp  = "Starts bundling the document";


            this.ContentView.AddSubview(bundleButton);
            bundleButton.Frame = bundleButton.GetFrameForAlignmentRect(new CoreGraphics.CGRect(354f, 20f, 108f, 21f));;

            // View:     cancelButton
            // NodeName: "cancelButton"
            // NodeType: INSTANCE
            // NodeId:   38:697
            cancelButton                    = new AppKit.NSButton();
            cancelButton.WantsLayer         = true;
            cancelButton.BezelStyle         = NSBezelStyle.Rounded;
            cancelButton.ControlSize        = NSControlSize.Regular;
            cancelButton.Font               = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            cancelButton.Title              = "Cancel";
            cancelButton.AccessibilityTitle = "Cancel";
            cancelButton.AccessibilityHelp  = "Cancel bundling";


            this.ContentView.AddSubview(cancelButton);
            cancelButton.Frame = cancelButton.GetFrameForAlignmentRect(new CoreGraphics.CGRect(19f, 20f, 84f, 21f));;

            // View:     lineView
            // NodeName: sep
            // NodeType: VECTOR
            // NodeId:   38:698
            var lineView = new AppKit.NSBox();

            lineView.WantsLayer = true;
            lineView.BoxType    = NSBoxType.NSBoxSeparator;

            this.ContentView.AddSubview(lineView);
            lineView.Frame = lineView.GetFrameForAlignmentRect(new CoreGraphics.CGRect(0f, 59.5f, 481f, 0f));;

            // View:     translationsCheckbox
            // NodeName: "translationsCheckbox"
            // NodeType: INSTANCE
            // NodeId:   38:699
            translationsCheckbox            = new AppKit.NSButton();
            translationsCheckbox.WantsLayer = true;
            translationsCheckbox.BezelStyle = NSBezelStyle.Rounded;
            translationsCheckbox.SetButtonType(NSButtonType.Switch);
            translationsCheckbox.ControlSize = NSControlSize.Regular;
            translationsCheckbox.Font        = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            translationsCheckbox.Title       = "Make strings translatable";
            translationsCheckbox.State       = NSCellStateValue.Off;

            this.ContentView.AddSubview(translationsCheckbox);
            translationsCheckbox.Frame = translationsCheckbox.GetFrameForAlignmentRect(new CoreGraphics.CGRect(169f, 104f, 238f, 14f));;

            // View:     includeOriginalCheckbox
            // NodeName: "includeOriginalCheckbox"
            // NodeType: INSTANCE
            // NodeId:   38:700
            includeOriginalCheckbox            = new AppKit.NSButton();
            includeOriginalCheckbox.WantsLayer = true;
            includeOriginalCheckbox.BezelStyle = NSBezelStyle.Rounded;
            includeOriginalCheckbox.SetButtonType(NSButtonType.Switch);
            includeOriginalCheckbox.ControlSize = NSControlSize.Regular;
            includeOriginalCheckbox.Font        = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            includeOriginalCheckbox.Title       = "Include original Figma document";
            includeOriginalCheckbox.State       = NSCellStateValue.On;

            this.ContentView.AddSubview(includeOriginalCheckbox);
            includeOriginalCheckbox.Frame = includeOriginalCheckbox.GetFrameForAlignmentRect(new CoreGraphics.CGRect(169f, 82f, 238f, 14f));;

            // View:     generateRadios
            // NodeName: "generateRadios"
            // NodeType: FRAME
            // NodeId:   38:701
            generateRadios            = new AppKit.NSView();
            generateRadios.WantsLayer = true;

            this.ContentView.AddSubview(generateRadios);
            generateRadios.Frame = generateRadios.GetFrameForAlignmentRect(new CoreGraphics.CGRect(169f, 135f, 220f, 60f));;

            // View:     nothingRadio
            // NodeName: radio "nothingRadio"
            // NodeType: INSTANCE
            // NodeId:   38:702
            nothingRadio            = new AppKit.NSButton();
            nothingRadio.WantsLayer = true;
            nothingRadio.BezelStyle = NSBezelStyle.Rounded;
            nothingRadio.SetButtonType(NSButtonType.Radio);
            nothingRadio.ControlSize        = NSControlSize.Regular;
            nothingRadio.Font               = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            nothingRadio.Title              = "Nothing";
            nothingRadio.AccessibilityTitle = "Nothing";
            nothingRadio.AccessibilityHelp  = "Select to not output anything";


            generateRadios.AddSubview(nothingRadio);
            nothingRadio.Frame = nothingRadio.GetFrameForAlignmentRect(new CoreGraphics.CGRect(0f, 0f, 89f, 16f));;

            // View:     templateRadio
            // NodeName: radio "templateRadio"
            // NodeType: INSTANCE
            // NodeId:   38:703
            templateRadio            = new AppKit.NSButton();
            templateRadio.WantsLayer = true;
            templateRadio.BezelStyle = NSBezelStyle.Rounded;
            templateRadio.SetButtonType(NSButtonType.Radio);
            templateRadio.ControlSize        = NSControlSize.Regular;
            templateRadio.Font               = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            templateRadio.Title              = "Template";
            templateRadio.AccessibilityTitle = "Template";
            templateRadio.AccessibilityHelp  = "Select to output a template";


            generateRadios.AddSubview(templateRadio);
            templateRadio.Frame = templateRadio.GetFrameForAlignmentRect(new CoreGraphics.CGRect(0f, 22f, 89f, 16f));;

            // View:     codeRadio
            // NodeName: radio "codeRadio"
            // NodeType: INSTANCE
            // NodeId:   38:704
            codeRadio            = new AppKit.NSButton();
            codeRadio.WantsLayer = true;
            codeRadio.BezelStyle = NSBezelStyle.Rounded;
            codeRadio.SetButtonType(NSButtonType.Radio);
            codeRadio.ControlSize = NSControlSize.Regular;
            codeRadio.Font        = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            codeRadio.Title       = "Code";
            codeRadio.State       = NSCellStateValue.On;

            generateRadios.AddSubview(codeRadio);
            codeRadio.Frame = codeRadio.GetFrameForAlignmentRect(new CoreGraphics.CGRect(0f, 44f, 54f, 16f));;

            // View:     labelView
            // NodeName: Generate:
            // NodeType: INSTANCE
            // NodeId:   38:705
            var labelView = new AppKit.NSTextField();

            labelView.Editable        = false;
            labelView.Bordered        = false;
            labelView.Bezeled         = false;
            labelView.DrawsBackground = false;
            labelView.StringValue     = "Generate:";
            labelView.Font            = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            labelView.WantsLayer      = true;
            labelView.Alignment       = NSTextAlignment.Right;

            this.ContentView.AddSubview(labelView);
            labelView.Frame = labelView.GetFrameForAlignmentRect(new CoreGraphics.CGRect(21f, 177f, 142f, 20f));;

            // View:     namespacePopUp
            // NodeName: "namespacePopUp"
            // NodeType: INSTANCE
            // NodeId:   38:706
            namespacePopUp            = new AppKit.NSComboBox();
            namespacePopUp.WantsLayer = true;
            namespacePopUp.Font       = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            namespacePopUp.Add(new Foundation.NSString("MyApp"));
            namespacePopUp.AccessibilityTitle = "Namespace";
            namespacePopUp.AccessibilityHelp  = "The namespace to generate code in";


            this.ContentView.AddSubview(namespacePopUp);
            namespacePopUp.Frame = namespacePopUp.GetFrameForAlignmentRect(new CoreGraphics.CGRect(169f, 210f, 220f, 20f));;

            // View:     labelView1
            // NodeName: Namespace:
            // NodeType: INSTANCE
            // NodeId:   38:707
            var labelView1 = new AppKit.NSTextField();

            labelView1.Editable        = false;
            labelView1.Bordered        = false;
            labelView1.Bezeled         = false;
            labelView1.DrawsBackground = false;
            labelView1.StringValue     = "Namespace:";
            labelView1.Font            = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            labelView1.WantsLayer      = true;
            labelView1.Alignment       = NSTextAlignment.Right;

            this.ContentView.AddSubview(labelView1);
            labelView1.Frame = labelView1.GetFrameForAlignmentRect(new CoreGraphics.CGRect(21f, 211f, 142f, 20f));;

            // View:     lineView1
            // NodeName: sep
            // NodeType: VECTOR
            // NodeId:   38:708
            var lineView1 = new AppKit.NSBox();

            lineView1.WantsLayer = true;
            lineView1.BoxType    = NSBoxType.NSBoxSeparator;

            this.ContentView.AddSubview(lineView1);
            lineView1.Frame = lineView1.GetFrameForAlignmentRect(new CoreGraphics.CGRect(0f, 255.5f, 481f, 0f));;

            // View:     versionSpinner
            // NodeName: "versionSpinner"
            // NodeType: INSTANCE
            // NodeId:   38:709
            versionSpinner             = new AppKit.NSProgressIndicator();
            versionSpinner.WantsLayer  = true;
            versionSpinner.Style       = NSProgressIndicatorStyle.Spinning;
            versionSpinner.Hidden      = true;
            versionSpinner.ControlSize = NSControlSize.Small;

            this.ContentView.AddSubview(versionSpinner);
            versionSpinner.Frame = versionSpinner.GetFrameForAlignmentRect(new CoreGraphics.CGRect(396f, 281f, 18f, 18f));;

            // View:     versionPopUp
            // NodeName: "versionPopUp"
            // NodeType: INSTANCE
            // NodeId:   38:710
            versionPopUp             = new AppKit.NSPopUpButton();
            versionPopUp.WantsLayer  = true;
            versionPopUp.BezelStyle  = NSBezelStyle.Rounded;
            versionPopUp.ControlSize = NSControlSize.Regular;
            versionPopUp.AddItem("Current");

            this.ContentView.AddSubview(versionPopUp);
            versionPopUp.Frame = versionPopUp.GetFrameForAlignmentRect(new CoreGraphics.CGRect(167f, 279f, 223f, 21f));;

            // View:     labelView2
            // NodeName: Version:
            // NodeType: INSTANCE
            // NodeId:   38:711
            var labelView2 = new AppKit.NSTextField();

            labelView2.Editable        = false;
            labelView2.Bordered        = false;
            labelView2.Bezeled         = false;
            labelView2.DrawsBackground = false;
            labelView2.StringValue     = "Version:";
            labelView2.Font            = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            labelView2.WantsLayer      = true;
            labelView2.Alignment       = NSTextAlignment.Right;

            this.ContentView.AddSubview(labelView2);
            labelView2.Frame = labelView2.GetFrameForAlignmentRect(new CoreGraphics.CGRect(21f, 280f, 142f, 20f));;

            // View:     figmaUrlTextField
            // NodeName: "figmaUrlTextField"
            // NodeType: INSTANCE
            // NodeId:   38:712
            figmaUrlTextField                   = new AppKit.NSTextField();
            figmaUrlTextField.WantsLayer        = true;
            figmaUrlTextField.PlaceholderString = "https://www.figma.com/file/";

            this.ContentView.AddSubview(figmaUrlTextField);
            figmaUrlTextField.Frame = figmaUrlTextField.GetFrameForAlignmentRect(new CoreGraphics.CGRect(168f, 311f, 221f, 21f));;

            // View:     labelView3
            // NodeName: Figma URL:
            // NodeType: INSTANCE
            // NodeId:   38:713
            var labelView3 = new AppKit.NSTextField();

            labelView3.Editable        = false;
            labelView3.Bordered        = false;
            labelView3.Bezeled         = false;
            labelView3.DrawsBackground = false;
            labelView3.StringValue     = "Figma URL:";
            labelView3.Font            = AppKit.NSFont.SystemFontOfSize(AppKit.NSFont.SystemFontSize);;
            labelView3.WantsLayer      = true;
            labelView3.Alignment       = NSTextAlignment.Right;

            this.ContentView.AddSubview(labelView3);
            labelView3.Frame = labelView3.GetFrameForAlignmentRect(new CoreGraphics.CGRect(21f, 311f, 142f, 20f));;
        }
 static extern CGRect NSAccessibilityFrameInView(NSView parentView, CGRect frame);
Exemple #28
0
 public void EnumerateDraggingItems(NSDraggingItemEnumerationOptions enumOpts, NSView view, INSPasteboardReading [] classArray, NSDictionary searchOptions, NSDraggingEnumerator enumerator)