Created
July 16, 2020 16:58
-
-
Save aberba/e966c1631b6edb715b3ffcf0a07ea423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arsd.nanovega; | |
import nanogui.sdlbackend : SdlBackend; | |
class MyGui : SdlBackend | |
{ | |
this(int w, int h, string title) | |
{ | |
super(w, h, title); | |
} | |
override void onVisibleForTheFirstTime() | |
{ | |
import nanogui.widget, nanogui.screen, nanogui.checkbox, nanogui.label, | |
nanogui.common, nanogui.window, nanogui.layout, nanogui.button, nanogui.popupbutton, | |
nanogui.entypo, nanogui.popup, nanogui.vscrollpanel, | |
nanogui.combobox, nanogui.textbox; | |
auto window = new Window(screen, "Button demo", true); | |
window.position(Vector2i(15, 15)); | |
window.size = Vector2i(140, 170); | |
window.layout(new BoxLayout(Orientation.Vertical)); | |
new Label(window, "Push buttons", "sans-bold"); | |
auto checkbox = new CheckBox(window, "Checkbox #1", null); | |
checkbox.position = Vector2i(100, 190); | |
checkbox.size = checkbox.preferredSize(ctx); | |
checkbox.checked = true; | |
auto label = new Label(window, "Label"); | |
label.position = Vector2i(100, 300); | |
label.size = label.preferredSize(ctx); | |
Popup popup; | |
auto btn = new Button(window, "Button"); | |
btn.callback = () { | |
popup.children[0].visible = !popup.children[0].visible; | |
label.caption = popup.children[0].visible ? | |
"Popup label is visible" : "Popup label isn't visible"; | |
}; | |
auto popupBtn = new PopupButton(window, "PopupButton", Entypo.ICON_EXPORT); | |
popup = popupBtn.popup; | |
popup.layout(new GroupLayout()); | |
new Label(popup, "Arbitrary widgets can be placed here"); | |
new CheckBox(popup, "A check box", null); | |
window.tooltip = "Button demo tooltip"; | |
// now we should do layout manually yet | |
screen.performLayout(ctx); | |
} | |
} | |
void main() | |
{ | |
auto gui = new MyGui(1000, 800, "Nanogui demo"); | |
gui.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment