コード例 #1
0
        private void Init()
        {
            label = CreateChild <Label>("label", 0);
            {
                label.Anchor    = AnchorType.TopLeft;
                label.Pivot     = PivotType.TopLeft;
                label.X         = 32f;
                label.Y         = -32f;
                label.IsBold    = true;
                label.FontSize  = 18;
                label.Alignment = TextAnchor.UpperLeft;

                label.Text = "Description";
            }
            scrollView = CreateChild <UguiScrollView>("scrollview", 1);
            {
                scrollView.Anchor = AnchorType.Fill;
                scrollView.Offset = new Offset(32f, 64f, 32f, 32f);

                scrollView.Background.Alpha = 0f;

                contentLabel = scrollView.Container.CreateChild <Label>("content", 0);
                {
                    contentLabel.Anchor    = AnchorType.Fill;
                    contentLabel.RawSize   = Vector2.zero;
                    contentLabel.FontSize  = 16;
                    contentLabel.Alignment = TextAnchor.UpperLeft;
                }
            }

            OnEnableInited();
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: berlamont/FigmaSharp
        static void Main(string[] args)
        {
            FigmaApplication.Init(Environment.GetEnvironmentVariable("TOKEN"));

            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var stackView = new StackView()
            {
                Orientation = LayoutOrientation.Vertical
            };

            var mainWindow = new Window(new Rectangle(0, 0, 540, 800))
            {
                Content = stackView
            };

            mainWindow.Closing += delegate { NSRunningApplication.CurrentApplication.Terminate(); };

            scrollView = new ScrollView();
            stackView.AddChild(scrollView);

            manager = new ExampleViewManager(scrollView);

            mainWindow.Title = manager.WindowTitle;
            mainWindow.Show();

            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
コード例 #3
0
        private void Init()
        {
            container.Anchor = AnchorType.RightStretch;
            container.Pivot  = PivotType.TopRight;
            container.X      = 0f;
            container.Width  = 340f;
            container.SetOffsetVertical(0f);

            scrollView = container.CreateChild <UguiScrollView>("scrollview");
            {
                scrollView.Anchor           = AnchorType.Fill;
                scrollView.Offset           = Offset.Zero;
                scrollView.Background.Color = new Color(1f, 1f, 1f, 0.0625f);

                notificationList = scrollView.Container.CreateChild <NotificationList>("list");
                {
                    notificationList.Anchor = AnchorType.Fill;
                    notificationList.Offset = Offset.Zero;
                    notificationList.Scope  = NotificationScope.Stored;

                    notificationList.OnDismiss += OnDismissed;
                }
            }

            OnEnableInited();
        }
コード例 #4
0
        public ExampleViewManager(IScrollView scrollView, FigmaViewConverter[] converters)
        {
            fileProvider    = new FigmaRemoteFileProvider();
            RendererService = new FigmaFileRendererService(fileProvider, converters);

            var options = new FigmaViewRendererServiceOptions()
            {
                ScanChildrenFromFigmaInstances = false
            };

            RendererService.Start(fileName, scrollView.ContentView, options);

            distributionService = new FigmaViewRendererDistributionService(RendererService);
            distributionService.Start();

            //We want know the background color of the figma camvas and apply to our scrollview
            var canvas = fileProvider.Nodes.OfType <FigmaCanvas>().FirstOrDefault();

            if (canvas != null)
            {
                scrollView.BackgroundColor = canvas.backgroundColor;
            }


            scrollView.AdjustToContent();
        }
コード例 #5
0
        public ExampleViewManager(IScrollView scrollView)
        {
            //we get the default basic view converters from the current loaded toolkit
            var converters = FigmaSharp.AppContext.Current.GetFigmaConverters();

            //TIP: the render consist in 2 steps:
            //1) generate all the views, decorating and calculate sizes
            //2) with this views we generate the hierarchy and position all the views based in the
            //native toolkit positioning system

            //in this case we want use a remote file provider (figma url from our document)
            fileProvider = new FigmaRemoteFileProvider();

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>
            var rendererService = new FigmaFileRendererService(fileProvider, converters);

            rendererService.Start(fileName, scrollView);

            //now we have all the views processed and the relationship we can distribute all the views into the desired base view
            var distributionService = new FigmaViewRendererDistributionService(rendererService);

            distributionService.Start();

            //We want know the background color of the figma camvas and apply to our scrollview
            var canvas = fileProvider.Nodes.OfType <FigmaCanvas>().FirstOrDefault();

            if (canvas != null)
            {
                scrollView.BackgroundColor = canvas.backgroundColor;
            }

            //NOTE: some toolkits requires set the real size of the content of the scrollview before position layers
            scrollView.AdjustToContent();
        }
コード例 #6
0
        internal static void HandleScrollBarVisibilityChange(this IScrollView scrollView)
        {
            // According to the Android Documentation
            // * <p>AwakenScrollBars method should be invoked every time a subclass directly updates
            // *the scroll parameters.</ p >

            // If AwakenScrollBars is never called there are cases where the ScrollDrawable is never called
            // which causes a crash during draw

            if (scrollView.ScrollBarsInitialized)
            {
                scrollView.AwakenScrollBars();
            }

            // The scrollbar drawable won't initialize if ScrollbarFadingEnabled == false
            if (!scrollView.ScrollbarFadingEnabled)
            {
                scrollView.ScrollbarFadingEnabled = true;
                scrollView.AwakenScrollBars();
                scrollView.ScrollbarFadingEnabled = false;
            }
            else
            {
                scrollView.AwakenScrollBars();
            }

            scrollView.ScrollBarsInitialized = true;
        }
コード例 #7
0
        private void Init()
        {
            container.Anchor = AnchorType.TopStretch;
            container.Pivot  = PivotType.Top;
            container.SetOffsetHorizontal(16f);
            container.Y      = -16f;
            container.Height = ButtonSize.y;

            scrollView = container.CreateChild <UguiScrollView>("scrollview", 0);
            {
                scrollView.Anchor           = AnchorType.Fill;
                scrollView.Offset           = Offset.Zero;
                scrollView.Background.Color = new Color(0f, 0f, 0f, 0.5f);

                grid = scrollView.Container.AddComponentInject <UguiGrid>();
                {
                    grid.Anchor = AnchorType.LeftStretch;
                    grid.SetOffsetVertical(0f);
                    grid.X        = 0f;
                    grid.CellSize = ButtonSize;

                    foreach (var info in model.GetMenus())
                    {
                        CreateMenuButton(info);
                    }

                    // Resize scrollview container
                    InvokeAfterTransformed(1, () => scrollView.Container.Width = Mathf.Max(scrollView.Width, grid.ChildCount * ButtonSize.x));
                }
            }
        }
コード例 #8
0
        // creates an auto scroller object for the tests
        private AutoScroller CreateAutoScroller(out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller)
        {
            scrollView             = A.Fake <IScrollView>();
            content                = A.Fake <IRectangle>();
            elementToStartScroller = A.Fake <IActivateable>();
            AutoScroller autoScroller = new AutoScroller(scrollView, content, elementToStartScroller);

            return(autoScroller);
        }
コード例 #9
0
        private void Init(IColorPreset colorPreset)
        {
            Color = colorPreset.DarkBackground;

            menuHolder = CreateChild <MenuHolder>("menu", 0);
            {
                menuHolder.Anchor   = AnchorType.TopStretch;
                menuHolder.Pivot    = PivotType.Top;
                menuHolder.RawWidth = 0f;
                menuHolder.Y        = 0f;
                menuHolder.Height   = 56f;
            }
            versionDisplay = CreateChild <VersionDisplay>("version", 1);
            {
                versionDisplay.Anchor   = AnchorType.TopStretch;
                versionDisplay.Pivot    = PivotType.Top;
                versionDisplay.RawWidth = 0f;
                versionDisplay.Y        = -56f;
                versionDisplay.Height   = 72f;
            }
            contentScroll = CreateChild <UguiScrollView>("content", 2);
            {
                contentScroll.Anchor = AnchorType.Fill;
                contentScroll.Offset = new Offset(0f, 128f, 0f, 0f);

                contentScroll.Background.Alpha = 0f;

                metaContainer = contentScroll.Container.CreateChild <MetaContainer>("meta");
                {
                    metaContainer.Anchor = AnchorType.TopStretch;
                    metaContainer.Pivot  = PivotType.Top;
                    metaContainer.Y      = -32f;
                    metaContainer.Height = 360f;
                    metaContainer.SetOffsetHorizontal(64f);
                }
                rankingContainer = contentScroll.Container.CreateChild <RankingContainer>("ranking");
                {
                    rankingContainer.Anchor = AnchorType.TopStretch;
                    rankingContainer.Pivot  = PivotType.Top;
                    rankingContainer.Y      = -424f;
                    rankingContainer.Height = 360f;
                    rankingContainer.SetOffsetHorizontal(64f);
                }
                actionsContainer = contentScroll.Container.CreateChild <ActionsContainer>("actions");
                {
                    actionsContainer.Anchor = AnchorType.TopStretch;
                    actionsContainer.Pivot  = PivotType.Top;
                    actionsContainer.Y      = -816f;
                    actionsContainer.Height = 48f;
                    actionsContainer.SetOffsetHorizontal(64f);
                }

                // Calculate height of the scrollview content.
                contentScroll.Container.Height = GetContentHeight();
            }
        }
コード例 #10
0
ファイル: Sprite.cs プロジェクト: samoteph/Sugoi
        /// <summary>
        /// Fixe le scroll selon la vue scrollé (une page la plupart du temps)
        /// </summary>
        /// <param name="scrollView"></param>

        public void SetScroll(IScrollView scrollView)
        {
            this.ScrollWidth = scrollView.ScrollWidth;
            this.ScrollX     = (int)-scrollView.ScrollX;

            this.ScrollHeight = scrollView.ScrollHeight;
            this.ScrollY      = (int)-scrollView.ScrollY;

            this.UpdatePositionScrolled();
        }
コード例 #11
0
        public DocumentExample(IScrollView scrollView, FigmaFile storyboard)
        {
            //we set our storyboard like the content view of the scrollview
            scrollView.ContentView = storyboard.ContentView;

            //we need reload after set the content to ensure the scrollview
            storyboard.Reload();

            //now we want recalculate all the bounds based in all the views generated
            scrollView.AdjustToContent();
        }
コード例 #12
0
        public FigmaFileDocumentController()
        {
            scrollview = new ScrollView();

            var nativeScrollview = (FigmaSharp.Views.Native.Cocoa.FNSScrollview)scrollview.NativeObject;

            nativeScrollview.TranslatesAutoresizingMaskIntoConstraints = true;

            _content = new GtkNSViewHost(nativeScrollview);

            _content.ShowAll();
        }
コード例 #13
0
ファイル: Main.cs プロジェクト: whjvenyl/FigmaSharp
        static void Main(string[] args)
        {
            FigmaApplication.Init(Environment.GetEnvironmentVariable("TOKEN"));

            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var stackView = new StackView()
            {
                Orientation = LayoutOrientation.Vertical
            };

            scrollView = new ScrollView();

            var mainWindow = new Window(new Rectangle(0, 0, 540, 800))
            {
                Content = scrollView
            };

            mainWindow.Closing += delegate { NSRunningApplication.CurrentApplication.Terminate(); };

            //TIP: the render consist in 2 steps:
            //1) generate all the views, decorating and calculate sizes
            //2) with this views we generate the hierarchy and position all the views based in the
            //native toolkit positioning system

            //in this case we want use a remote file provider (figma url from our document)
            var fileProvider = new FigmaRemoteFileProvider();

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>
            var rendererService = new FigmaViewRendererService(fileProvider);

            rendererService.Start(fileName, scrollView.ContentView);

            //now we have all the views processed and the relationship we can distribute all the views into the desired base view
            var layoutManager = new StoryboardLayoutManager();

            layoutManager.Run(scrollView.ContentView, rendererService);

            //NOTE: some toolkits requires set the real size of the content of the scrollview before position layers
            scrollView.AdjustToContent();

            mainWindow.Show();
            //mainWindow.Title = manager.WindowTitle;

            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
コード例 #14
0
        public FigmaFileDocumentController()
        {
            container = new NSStackView();

            container.Spacing               = 10;
            container.WantsLayer            = true;
            container.Layer.BackgroundColor = NSColor.DarkGray.CGColor;

            container.Distribution = NSStackViewDistribution.Fill;
            container.Orientation  = NSUserInterfaceLayoutOrientation.Vertical;

            _content           = GtkMacInterop.NSViewToGtkWidget(container);
            _content.CanFocus  = true;
            _content.Sensitive = true;

            var scrollView = new FNSScrollview()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = true,
            };

            scrollView.AutohidesScrollers = false;
            scrollView.BackgroundColor    = NSColor.DarkGray;
            scrollView.ScrollerStyle      = NSScrollerStyle.Legacy;

            scrollViewWrapper = new ScrollView(scrollView);

            var contentView = new NSView();

            contentView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
            scrollView.DocumentView      = contentView;

            container.AddArrangedSubview(scrollView);

            _content.ShowAll();

            grid          = PropertyPad.Instance.Control;
            grid.Changed += PropertyPad_Changed;
        }
コード例 #15
0
ファイル: ScrollViewExtensions.cs プロジェクト: Glepooek/maui
 public static void UpdateIsEnabled(this UIScrollView nativeScrollView, IScrollView scrollView)
 {
     nativeScrollView.ScrollEnabled = scrollView.IsEnabled;
 }