better layout management
This commit is contained in:
parent
69f8a273f3
commit
a315d72a57
11 changed files with 86 additions and 79 deletions
|
|
@ -15,29 +15,25 @@ static void slide_callback(void *data, double value) {
|
|||
snprintf(app_data->buffer, 127, "%d", (int)(value * 100));
|
||||
}
|
||||
|
||||
static void configure_widget_default(PGPL_GuiWidget *widget) {
|
||||
pgpl_gui_widget_configure(widget, 0, 0, true, true, false, false,
|
||||
PGPL_GUI_FONT_SIZE_CONTENT, NULL, false, false,
|
||||
false, false);
|
||||
}
|
||||
|
||||
PGPL_GuiWidget *create_main_view(struct AppData *app) {
|
||||
PGPL_GuiContainerLayout *layout;
|
||||
PGPL_GuiSliderWidget *slider;
|
||||
PGPL_GuiTextWidget *text;
|
||||
|
||||
layout = pgpl_gui_container_layout_create(
|
||||
PGPL_GUI_CONTAINER_LAYOUT_DIRECTION_HORIZONTAL);
|
||||
pgpl_gui_widget_configure(&layout->parent, 0, 0, true, true, false, false,
|
||||
PGPL_GUI_FONT_SIZE_CONTENT, NULL, false, true, true,
|
||||
false);
|
||||
PGPL_GUI_CONTAINER_LAYOUT_DIRECTION_VERTICAL);
|
||||
layout->parent.ignore_margin = true;
|
||||
layout->parent.ignore_border = true;
|
||||
|
||||
slider = pgpl_gui_slider_widget_create(16, true, true, 0.0, slide_callback);
|
||||
configure_widget_default(&slider->parent);
|
||||
slider = pgpl_gui_slider_widget_create(16, false, false, 0.0, slide_callback);
|
||||
slider->parent.border = true;
|
||||
slider->parent.background = true;
|
||||
|
||||
text = pgpl_gui_text_widget_create(app->buffer);
|
||||
configure_widget_default(&text->parent);
|
||||
text->parent.border = true;
|
||||
text->parent.background = true;
|
||||
text->parent.font_size = PGPL_GUI_FONT_SIZE_TITLE;
|
||||
text->parent.expansion_fraction = 3;
|
||||
|
||||
pgpl_gui_container_layout_widget_add(layout, &text->parent);
|
||||
pgpl_gui_container_layout_widget_add(layout, &slider->parent);
|
||||
|
|
@ -57,12 +53,12 @@ int32_t main(void) {
|
|||
|
||||
strcpy(app.buffer, "0");
|
||||
|
||||
font = pgpl_font_create_from_file("../roboto.ttf", 128);
|
||||
font = pgpl_font_create_from_file("../roboto.ttf", 256);
|
||||
|
||||
pgpl_gui_theme_configure(&theme, pgpl_color_create(255, 255, 255, 255), 48,
|
||||
pgpl_gui_theme_configure(&theme, pgpl_color_create(255, 255, 255, 255), 64,
|
||||
font);
|
||||
|
||||
gui = pgpl_gui_create("PGPL Test", 480, 240, 0, 0, &theme, &app);
|
||||
gui = pgpl_gui_create("PGPL Test", 480, 320, 0, 0, &theme, &app);
|
||||
|
||||
app.gui = gui;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue