Esempio n. 1
0
        public static unsafe int Main(string[] args)
        {
            uiInitOptions options = new uiInitOptions();
            string        err;
            IntPtr        tab;

            err = uiInit(&options);
            if (err != null)
            {
                Console.WriteLine("error initializing libui: " + err);
                uiFreeInitError(err);
                return(1);
            }

            mainwin = uiNewWindow("libui Control Gallery", 640, 480, 1);
            uiWindowOnClosing(mainwin, onClosing, IntPtr.Zero);
            uiOnShouldQuit(onShouldQuit, mainwin);

            tab = uiNewTab();
            uiWindowSetChild(mainwin, uiControl(tab));
            uiWindowSetMargined(mainwin, 1);

            uiTabAppend(tab, "Basic Controls", makeBasicControlsPage());
            uiTabSetMargined(tab, 0, 1);

            uiTabAppend(tab, "Numbers and Lists", makeNumbersPage());
            uiTabSetMargined(tab, 1, 1);

            uiTabAppend(tab, "Data Choosers", makeDataChoosersPage());
            uiTabSetMargined(tab, 2, 1);

            uiControlShow(uiControl(mainwin));
            uiMain();
            return(0);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes LibUI.
        /// </summary>
        /// <exception cref="ExternalException">
        /// Thrown if LibUI encounters an error.
        /// </exception>
        public static void Init()
        {
            uiInitOptions o = new uiInitOptions();

            o.Size = UIntPtr.Zero;
            Init(o);
        }
Esempio n. 3
0
        static void Init(uiInitOptions o)
        {
            var err = uiInit(ref o);

            if (!String.IsNullOrEmpty(err))
            {
                uiFreeInitError(err);
                throw new ExternalException(err);
            }
        }
Esempio n. 4
0
 public static extern IntPtr uiInit(ref uiInitOptions options);
Esempio n. 5
0
 internal static string uiInit(ref uiInitOptions options) => FunctionLoader.LoadLibuiFunc <uiInit_t>("uiInit")(ref options);
Esempio n. 6
0
 static extern string uiInit(ref uiInitOptions options);
Esempio n. 7
0
        public static void Main(string[] args)
        {
            uiInitOptions o = new uiInitOptions();

            uiInit(ref o);

            List <UIMenu> menus = new List <UIMenu>();
            var           menu  = new UIMenu("File");

            menus.Add(menu);
            var item = menu.AppendItem("Open");

            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected", filename);
            };
            item            = menu.AppendItem("Save");
            item.OnClicked += (mi, w) =>
            {
                string filename = window.OpenFile();
                if (String.IsNullOrEmpty(filename))
                {
                    window.MessageBox("No file selected", "Don't be alarmed!", true);
                    return;
                }
                window.MessageBox("File selected (don't worry, it's still there)", filename);
            };
            item = menu.AppendQuitItem();
            //uiOnShouldQuit()

            menu = new UIMenu("Edit");
            menus.Add(menu);
            item = menu.AppendCheckItem("Checkable Item");
            menu.AppendSeparator();
            item         = menu.AppendItem("Disabled Item");
            item.Enabled = false;
            item         = menu.AppendPreferencesItem();

            menu = new UIMenu("Help");
            menus.Add(menu);
            item = menu.AppendItem("Help");
            menu.AppendAboutItem();

            window = new UIWindow("libui Control Gallery", 640, 480, true);

            window.Margined   = true;
            window.OnClosing += (w) =>
            {
                window.Dispose();
                uiQuit();
                return(0);
            };

            var box = new UIBox(true);

            box.Padded = true;
            window.SetChild(box);

            var hbox = new UIBox();

            box.Padded = true;
            box.Append(hbox, true);

            var group = new UIGroup("Basic Controls");

            group.Margined = true;
            hbox.Append(group, false);

            var inner = new UIBox(true);

            inner.Padded = true;
            group.SetChild(inner);

            inner.Append(new UIButton("Button"), false);

            var entry = new UIEntry();

            entry.Text = "Entry";
            inner.Append(entry, false);

            inner.Append(new UILabel("Label"), false);

            inner.Append(new UISeparator(), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Date), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.Time), false);

            inner.Append(new UIDateTimePicker(UIDateTimePickerType.DateTime), false);

            //inner.Append(new UIFontButton(), false);

            var inner2 = new UIBox(true);

            inner2.Padded = true;
            hbox.Append(inner2, true);

            group          = new UIGroup("Numbers");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            var spinbox = new UISpinbox(0, 100);

            inner.Append(spinbox, false);

            var slider = new UISlider(0, 100);

            inner.Append(slider, false);

            var progressbar = new UIProgressBar();

            inner.Append(progressbar, false);

            group          = new UIGroup("Lists");
            group.Margined = true;
            inner2.Append(group, false);

            inner        = new UIBox(true);
            inner.Padded = true;
            group.SetChild(inner);

            spinbox.OnChanged += (s) =>
            {
                slider.Value      = spinbox.Value;
                progressbar.Value = (int)spinbox.Value;
            };

            slider.OnChanged += (s) =>
            {
                spinbox.Value     = slider.Value;
                progressbar.Value = (int)slider.Value;
            };

            var cbox = new UICombobox();

            cbox.Append("Combobox Item 1");
            cbox.Append("Combobox Item 2");
            cbox.Append("Combobox Item 3");
            inner.Append(cbox, false);

            cbox = new UICombobox(true);
            cbox.Append("Editable Item 1");
            cbox.Append("Editable Item 2");
            cbox.Append("Editable Item 3");
            inner.Append(cbox, false);

            var rb = new UIRadioButtons();

            rb.Append("Radio Button 1");
            rb.Append("Radio Button 2");
            rb.Append("Radio Button 3");
            inner.Append(rb, true);

            var tab = new UITab();

            tab.Append("Page 1", new UIBox());
            tab.Append("Page 2", new UIBox());
            tab.Append("Page 3", new UIBox());
            inner2.Append(tab, true);

            GC.Collect();

            window.Shown = true;
            uiMain();
            uiUninit();
            GC.KeepAlive(menus);
            GC.KeepAlive(window);
        }