Enhanced demo program.
This commit is contained in:
270
main.cpp
270
main.cpp
@@ -203,102 +203,189 @@ JUI::UtilityBar* CreateUtilityBar(JUI::Widget* root) {
|
||||
|
||||
/// Constructs, styles, and returns a JUI::Rect which contains a sample of each widget in action.
|
||||
JUI::Rect* CreateWidgetList(JUI::Widget* root) {
|
||||
auto* widget_list = new Rect(root);
|
||||
|
||||
auto* window = new Window(root);
|
||||
window->Title("Widgets");
|
||||
window->Size({300_px, 80_percent});
|
||||
|
||||
auto* widget_list = new Rect(window->Content());
|
||||
//column_rect->ZIndex(4);
|
||||
widget_list->Size({0, -24, 0.2f, 1.f});
|
||||
widget_list->Position({0, 24, 0, 0});
|
||||
widget_list->Size({0, 0, 1.f, 1.f});
|
||||
widget_list->Position({0, 0, 0, 0});
|
||||
widget_list->BGColor(Colors::Grays::Gainsboro);
|
||||
|
||||
|
||||
auto* column_layout = new VerticalListLayout(widget_list);
|
||||
|
||||
auto* btn_container1 = new Rect(column_layout);
|
||||
btn_container1->Size({100_percent, 24_px});
|
||||
auto* button_section = new Collapsible(column_layout);
|
||||
{
|
||||
button_section->Title("Button Styles");
|
||||
button_section->Size({100_percent, 100_px});
|
||||
auto* button_section_layout = new VerticalListLayout(button_section->ContentBox());
|
||||
|
||||
auto* btn_h_layout1 = new HorizontalListLayout(btn_container1);
|
||||
btn_h_layout1->Padding({2_px});
|
||||
auto* btn_container1 = new Rect(button_section_layout);
|
||||
{
|
||||
btn_container1->Size({100_percent, 32_px});
|
||||
|
||||
auto* button = new TextButton(btn_h_layout1);
|
||||
//button->Position({5, 105, 0, 0});
|
||||
button->Size({0, 20, 0.32f, 0});
|
||||
button->TextColor(Colors::Black);
|
||||
button->Content("Button");
|
||||
button->AlignLeft();
|
||||
//button->Padding(5_px);
|
||||
|
||||
auto* tt2 = new JUI::Tooltip(button);
|
||||
tt2->Content("Test 123");
|
||||
auto* button = new TextButton(btn_container1);
|
||||
//button->Position({5, 105, 0, 0});
|
||||
button->Size({30_percent, 100_percent-10_px});
|
||||
button->Position({10_px, 50_percent});
|
||||
button->AnchorPoint({0, 0.5});
|
||||
button->TextColor(Colors::Black);
|
||||
button->Content("Left");
|
||||
button->AlignLeft();
|
||||
|
||||
auto* button2 = new TextButton(btn_h_layout1);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button2->Size({0, 20, 0.32f, 0});
|
||||
button2->TextColor(Colors::Black);
|
||||
button2->Content("Button");
|
||||
button2->AlignCenterHorizontally();
|
||||
auto* tt2 = new JUI::Tooltip(button);
|
||||
tt2->Content("Test 123");
|
||||
|
||||
auto* button3 = new TextButton(btn_h_layout1);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button3->Size({0, 20, 0.32f, 0});
|
||||
button3->TextColor(Colors::Black);
|
||||
button3->Content("Button");
|
||||
button3->AlignRight();
|
||||
auto* button2 = new TextButton(btn_container1);
|
||||
button2->Size({30_percent, 100_percent-10_px});
|
||||
button2->Position({50_percent, 50_percent});
|
||||
button2->AnchorPoint({0.5f, .5f});
|
||||
button2->TextColor(Colors::Black);
|
||||
button2->Content("Center");
|
||||
button2->AlignCenterHorizontally();
|
||||
|
||||
auto* btn_container2 = new Rect(column_layout);
|
||||
btn_container2->Size({100_percent, 24_px});
|
||||
btn_container2->BGColor(Colors::DarkGray);
|
||||
auto* button3 = new TextButton(btn_container1);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button3->Size({30_percent, 100_percent-10_px});
|
||||
button3->TextColor(Colors::Black);
|
||||
button3->Position({100_percent-10_px, 50_percent});
|
||||
button3->AnchorPoint({1, 0.5});
|
||||
button3->Content("Right");
|
||||
button3->AlignRight();
|
||||
}
|
||||
|
||||
auto* btn_h_layout2 = new HorizontalListLayout(btn_container2);
|
||||
btn_h_layout2->Padding({2_px});
|
||||
|
||||
auto* button4 = new TextButton(btn_h_layout2);
|
||||
//button->Position({5, 105, 0, 0});
|
||||
button4->Size({0, 20, 0.32f, 0});
|
||||
button4->TextColor(Colors::Black);
|
||||
button4->Content("Button");
|
||||
button4->AlignLeft();
|
||||
//button4->CornerRounding(4);
|
||||
auto* btn_container2 = new Rect(button_section_layout);
|
||||
{
|
||||
btn_container2->Size({100_percent, 32_px});
|
||||
btn_container2->BGColor(Colors::DarkGray);
|
||||
|
||||
auto* button5 = new TextButton(btn_h_layout2);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button5->Size({0, 20, 0.32f, 0});
|
||||
button5->TextColor(Colors::Black);
|
||||
button5->Content("Button");
|
||||
button5->AlignCenterHorizontally();
|
||||
//button5->CornerRounding(4);
|
||||
|
||||
auto* button6 = new TextButton(btn_h_layout2);
|
||||
//button2->Position({5, 105, 0, 0});
|
||||
button6->Size({0, 20, 0.32f, 0});
|
||||
button6->TextColor(Colors::Black);
|
||||
button6->Content("Button");
|
||||
button6->AlignRight();
|
||||
//button6->CornerRounding(4);
|
||||
auto* button4 = new TextButton(btn_container2);
|
||||
//button->Position({5, 105, 0, 0});
|
||||
button4->Size({30_percent, 100_percent-10_px});
|
||||
button4->Position({10_px, 50_percent});
|
||||
button4->AnchorPoint({0, 0.5});
|
||||
button4->TextColor(Colors::Black);
|
||||
button4->Content("Left");
|
||||
button4->AlignLeft();
|
||||
button4->CornerRounding(8);
|
||||
button4->BorderWidth(2);
|
||||
button4->BorderColor(Colors::Cyans::Aqua);
|
||||
|
||||
auto* checkbox_container = new Rect(column_layout);
|
||||
checkbox_container->Size({0, 24, 1, 0});
|
||||
auto* button5 = new TextButton(btn_container2);
|
||||
button5->Size({30_percent, 100_percent-10_px});
|
||||
button5->Position({50_percent, 50_percent});
|
||||
button5->AnchorPoint({0.5f, .5f});
|
||||
button5->TextColor(Colors::Black);
|
||||
button5->Content("Center");
|
||||
button5->AlignCenterHorizontally();
|
||||
button5->CornerRounding(8);
|
||||
button5->BorderWidth(2);
|
||||
button5->BorderColor(Colors::Cyans::Aqua);
|
||||
|
||||
auto* checkbox_horiz = new HorizontalListLayout(checkbox_container);
|
||||
checkbox_horiz->Padding(2_px);
|
||||
auto* button6 = new TextButton(btn_container2);
|
||||
button6->Size({30_percent, 100_percent-10_px});
|
||||
button6->TextColor(Colors::Black);
|
||||
button6->Position({100_percent-10_px, 50_percent});
|
||||
button6->AnchorPoint({1, 0.5});
|
||||
button6->Content("Right");
|
||||
button6->AlignRight();
|
||||
button6->CornerRounding(8);
|
||||
button6->Disable();
|
||||
}
|
||||
|
||||
auto* label = new TextRect(checkbox_horiz);
|
||||
label->Content("Checkboxes");
|
||||
label->BorderWidth(0);
|
||||
label->AutoFitSizeToText(true);
|
||||
|
||||
auto* check1 = new Checkbox(checkbox_horiz);
|
||||
check1->Size({20_px, 20_px});
|
||||
auto* check2 = new Checkbox(checkbox_horiz);
|
||||
check2->Size({20_px, 20_px});
|
||||
check2->CheckedColor(Colors::Blue);
|
||||
check2->CornerRounding(7);
|
||||
auto* check3 = new Checkbox(checkbox_horiz);
|
||||
check3->Size({20_px, 20_px});
|
||||
check3->CheckedColor(Colors::Oranges::Coral);
|
||||
check3->CornerRounding(7);
|
||||
|
||||
auto* input_form = new TextInputForm(column_layout);
|
||||
input_form->Size({0,24, 1, 0});
|
||||
input_form->Content("");
|
||||
input_form->TextSize(14);
|
||||
auto* link_container = new Rect(button_section_layout);
|
||||
{
|
||||
link_container->Size({100_percent, 20_px});
|
||||
link_container->BGColor(Colors::DarkGray);
|
||||
|
||||
auto* link = new JUI::Link(link_container);
|
||||
link->Content("Clickable Link");
|
||||
link->Center();
|
||||
link->Clicked += [](auto event) {
|
||||
std::cout << "Link Released" << std::endl;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
auto* checkbox_section = new Collapsible(column_layout);
|
||||
{
|
||||
checkbox_section->Title("Checkbox Styles");
|
||||
checkbox_section->Size({100_percent, 50_px});
|
||||
|
||||
auto* checkbox_layout = new VerticalListLayout(checkbox_section->ContentBox());
|
||||
|
||||
auto* set_1 = new Rect(checkbox_layout);
|
||||
{
|
||||
set_1->Size({100_percent, 40_px});
|
||||
auto* set_1_layout = new HorizontalListLayout(set_1);
|
||||
auto* label = new TextRect(set_1_layout);
|
||||
label->Content("Standard");
|
||||
label->BorderWidth(0);
|
||||
label->AutoFitSizeToText(true);
|
||||
label->Size({100_px, 20_px});
|
||||
|
||||
auto* check1 = new Checkbox(set_1_layout);
|
||||
check1->Size({20_px, 20_px});
|
||||
auto* check2 = new Checkbox(set_1_layout);
|
||||
check2->Size({20_px, 20_px});
|
||||
check2->CheckedColor(Colors::Blue);
|
||||
check2->CornerRounding(7);
|
||||
auto* check3 = new Checkbox(set_1_layout);
|
||||
check3->Size({20_px, 20_px});
|
||||
check3->CheckedColor(Colors::Oranges::Coral);
|
||||
check3->CornerRounding(7);
|
||||
}
|
||||
}
|
||||
|
||||
auto* inputform_section = new Collapsible(column_layout);
|
||||
{
|
||||
inputform_section->Title("Input Forms");
|
||||
inputform_section->Size({100_percent, 50_px});
|
||||
|
||||
|
||||
auto* input_form = new TextInputForm(inputform_section->ContentBox());
|
||||
input_form->Size({0,24, 1, 0});
|
||||
input_form->Content("");
|
||||
input_form->SetAutoCompleteText("Accepts text input!");
|
||||
input_form->TextSize(14);
|
||||
}
|
||||
|
||||
auto* slider_section = new Collapsible(column_layout);
|
||||
{
|
||||
slider_section->Title("Slider Styles");
|
||||
slider_section->Size({100_percent, 50_px});
|
||||
|
||||
|
||||
auto* slider = new LabeledSlider(slider_section->ContentBox());
|
||||
slider->Size({90_percent, 12_px});
|
||||
slider->Position({50_percent, 50_percent});
|
||||
slider->AnchorPoint({0.5f, 0.5f});
|
||||
slider->Content("Value: 0");
|
||||
slider->Minimum(-1.f);
|
||||
slider->Maximum(1.f);
|
||||
slider->CurrentValue(0.f);
|
||||
slider->Interval(1/5.f);
|
||||
slider->ValueChanged += [slider](float value) mutable {
|
||||
slider->Content(std::format("Value: {}", value));
|
||||
};
|
||||
slider->CornerRounding(6);
|
||||
slider->ScrubberRounding(12);
|
||||
slider->ScrubberColor(Colors::Black);
|
||||
slider->ScrubberSize({24_px, 24_px});
|
||||
//slider->SetClipsDescendants(true);
|
||||
slider->BGColor(Colors::Blues::DarkSlateBlue);
|
||||
slider->Center();
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto* collapsible = new Collapsible(column_layout);
|
||||
collapsible->Size({100_percent, 200_px});
|
||||
@@ -332,34 +419,9 @@ JUI::Rect* CreateWidgetList(JUI::Widget* root) {
|
||||
auto* radio_c_btn = new Checkbox(radio_btn_set_layout);
|
||||
radio_c_btn->Size({20_px, 20_px});
|
||||
|
||||
auto* link_container = new Rect(collapsible->ContentBox());
|
||||
{
|
||||
link_container->Size({100_percent, 30_px});
|
||||
link_container->Position({0_px, 20_px});
|
||||
|
||||
auto* link = new JUI::Link(link_container);
|
||||
link->Content("Clickable Link");
|
||||
link->Clicked += [](auto event) {
|
||||
std::cout << "Link Released" << std::endl;
|
||||
};
|
||||
}
|
||||
|
||||
auto* slider = new LabeledSlider(collapsible->ContentBox());
|
||||
slider->Size({90_percent, 20_px});
|
||||
slider->Position({10_px, 50_px});
|
||||
slider->Content("Value: 0");
|
||||
slider->Minimum(-1.f);
|
||||
slider->Maximum(1.f);
|
||||
slider->CurrentValue(0.f);
|
||||
slider->Interval(1/5.f);
|
||||
slider->ValueChanged += [slider](float value) mutable {
|
||||
slider->Content(std::format("Value: {}", value));
|
||||
};
|
||||
slider->CornerRounding(10);
|
||||
slider->ScrubberColor(Colors::Black);
|
||||
slider->ScrubberWidth(20);
|
||||
slider->SetClipsDescendants(true);
|
||||
slider->BGColor(Colors::Blues::DarkSlateBlue);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -411,8 +473,8 @@ JUI::Scene* CreateScene() {
|
||||
|
||||
auto* colorpicker_wnd = new JUI::Window(root);
|
||||
colorpicker_wnd->Name("Slider ColorPicker");
|
||||
colorpicker_wnd->Size({100_px, 150_px});
|
||||
colorpicker_wnd->MinSize({100, 150});
|
||||
colorpicker_wnd->Size({150_px, 100_px});
|
||||
colorpicker_wnd->MinSize({50, 50});
|
||||
auto* cpicker = new JUI::ColorPicker(colorpicker_wnd->Content());
|
||||
|
||||
topbar = CreateUtilityBar(root);
|
||||
|
Reference in New Issue
Block a user