Example #1
0
        protected void SimpleCreateInstructions(string text = "")
        {
            var layout = new UILayout();

            layout.Rect = UIView.Rect;

            layout.LayoutPosition             = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM;
            layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM;

            var fontDesc = new UIFontDescription();

            fontDesc.Id   = "Vera";
            fontDesc.Size = 18;

            var label = new UIEditField();

            label.FontDescription    = fontDesc;
            label.ReadOnly           = true;
            label.Multiline          = true;
            label.AdaptToContentSize = true;
            label.Text = text;
            layout.AddChild(label);

            UIView.AddChild(layout);
        }
    private static void HandleUieditfieldEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uieditfieldcode")
            {
                AtomicMain.AppLog("UIEditField support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uieditfield.cs", widget.GetParent());
            }
            if (widget.GetId() == "uieditfieldlayout")
            {
                AtomicMain.AppLog("UIEditField support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uieditfield.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "editfieldadd")
            {
                AtomicMain.AppLog("UIEditField action : " + widget.GetId() + " was pressed ");
                UIEditField ef1 = (UIEditField)widget.FindWidget("editfieldmulti");
                if (!ef1.Equals(null))
                {
                    var    cache = GetSubsystem <ResourceCache>();
                    File   filex = cache.GetFile("Scenes/layout_uieditfield.ui.txt");
                    String textx = filex.ReadText();
                    filex.Close();
                    ef1.SetText(textx);
                }
            }
            if (widget.GetId() == "editfieldclr")
            {
                AtomicMain.AppLog("UIEditField action : " + widget.GetId() + " was pressed ");
                UIEditField ef1 = (UIEditField)widget.FindWidget("editfieldmulti");
                if (!ef1.Equals(null))
                {
                    ef1.SetText("");
                }
            }
        }
        else
        {
            if (widget.GetId() == "editfieldsingle")
            {
                UIEditField efx = (UIEditField)widget;
                AtomicMain.AppLog("UIEditField event : " + widget.GetId() + " text = `" + efx.GetText() + "` event type = " + AtomicMain.EventReport((int)ev.Type));
            }
            if (widget.GetId() == "editfieldmulti")
            {
                UIEditField efx = (UIEditField)widget;
                AtomicMain.AppLog("UIEditField event : " + widget.GetId() + " text = `" + efx.GetText() + "` event type = " + AtomicMain.EventReport((int)ev.Type));
            }
        }
    }
Example #3
0
        void InitWindow()
        {
            var layout = new UILayout();

            layout.Axis = UI_AXIS.UI_AXIS_Y;

            var checkBox = new UICheckBox();

            checkBox.Id = "Checkbox";

            layout.AddChild(checkBox);

            var button = new UIButton();

            button.Text = "Button";
            button.Id   = "Button";

            layout.AddChild(button);

            var edit = new UIEditField();

            layout.AddChild(edit);
            edit.Id = "EditField";

            window          = new UIWindow();
            window.Settings = UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_TITLEBAR | UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON;

            window.Text = "Hello Atomic GUI!";

            window.AddChild(layout);

            window.ResizeToFitContent();

            UIView.AddChild(window);
            window.Center();

            SubscribeToEvent <WidgetEvent>(window, e =>
            {
                if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                {
                    var target = e.Target;
                    if (target != null)
                    {
                        window.Text = $"Hello: {target.Id}";
                    }
                }
            });

            SubscribeToEvent <WidgetDeletedEvent>(window, e =>
            {
                BackToSelector();
            });
        }
Example #4
0
        void InitWindow()
        {
            var layout = new UILayout();
            layout.Axis = UI_AXIS.UI_AXIS_Y;

            var checkBox = new UICheckBox();
            checkBox.Id = "Checkbox";

            layout.AddChild(checkBox);

            var button = new UIButton();
            button.Text = "Button";
            button.Id = "Button";

            layout.AddChild(button);

            var edit = new UIEditField();
            layout.AddChild(edit);
            edit.Id = "EditField";

            window = new UIWindow();
            window.Settings = UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_TITLEBAR | UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON;

            window.Text = "Hello Atomic GUI!";

            window.AddChild(layout);

            window.ResizeToFitContent();

            UIView.AddChild(window);
            window.Center();

            SubscribeToEvent<WidgetEvent>(window, e =>
            {
                if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
                {
                    var target = e.Target;
                    if (target != null)
                    {
                        window.Text = $"Hello: {target.Id}";
                    }

                }

            });

            SubscribeToEvent<WidgetDeletedEvent>(window, e =>
            {
                BackToSelector();
            });
        }
Example #5
0
        protected void SimpleCreateInstructions(string text = "")
        {
            var layout = new UILayout();

            layout.Rect = UIView.Rect;

            layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM;
            layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM;

            var fontDesc = new UIFontDescription();
            fontDesc.Id = "Vera";
            fontDesc.Size = 18;

            var label = new UIEditField();
            label.FontDescription = fontDesc;
            label.ReadOnly = true;
            label.Multiline = true;
            label.AdaptToContentSize = true;
            label.Text = text;
            layout.AddChild(label);

            UIView.AddChild(layout);
        }
    private static void HandleUitabcontainerEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uitabcontainercode")
            {
                AtomicMain.AppLog("UITabContainer support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uitabcontainer.cs", widget.GetParent());
            }
            if (widget.GetId() == "uitabcontainerlayout")
            {
                AtomicMain.AppLog("UITabContainer support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uitabcontainer.ui.txt", widget.GetParent());
            }


            if (widget.GetId() == "uitabcontainerremove")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx     = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                int            current = tcx.GetCurrentPage();
                tcx.DeletePage(current);
            }
            if (widget.GetId() == "uitabcontaineradd")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                tcx.AddTabPageFile("New File", "Scenes/sheet.ui.txt");
            }
            if (widget.GetId() == "uitabcontainermake")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                var            cache = GetSubsystem <ResourceCache>();
                UITabContainer tcx   = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                UILayout       lo    = new UILayout();
                lo.SetLayoutConfig("YAGAC");     // YACAC!
                UIEditField myeditfield = new UIEditField();
                myeditfield.SetGravity(UI_GRAVITY.UI_GRAVITY_ALL);
                myeditfield.SetMultiline(true);
                File   filex = cache.GetFile("Components/code_uitabcontainer.cs");
                String textx = filex.ReadText();
                filex.Close();
                myeditfield.SetText(textx);
                UIFontDescription myfont = new UIFontDescription();  // put in a coder font
                myfont.SetSize(16);
                myfont.SetId("Vera");
                myeditfield.SetFontDescription(myfont);
                lo.AddChild(myeditfield);
                tcx.AddTabPageWidget("New Code", lo);
            }
            if (widget.GetId() == "uitabcontainerundock")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx     = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                int            current = tcx.GetCurrentPage();
                tcx.UndockPage(current);
            }
            if (widget.GetId() == "uitabcontainerredock")
            {
                AtomicMain.AppLog("UITabContainer action : " + widget.GetId() + " was pressed ");
                UITabContainer tcx = (UITabContainer)widget.FindWidget("UITabContainerDemo");
                if (!tcx.DockWindow("tab1"))
                {
                    if (!tcx.DockWindow("tab2"))
                    {
                        if (!tcx.DockWindow("tab3"))
                        {
                            if (!tcx.DockWindow("New File"))
                            {
                                if (!tcx.DockWindow("New Code"))
                                {
                                    AtomicMain.AppLog("UITabContainer action : no more windows to dock.");
                                }
                            }
                        }
                    }
                }
            }
        }
    }