From 1e91bddeff42f86f6897bb0dc8b289b74c39f561 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Thu, 16 Jan 2025 23:53:10 -0500 Subject: [PATCH] Layout for mod details panel, add gap property setters --- src/ui/elements/ui_style.cpp | 13 +++++++++++ src/ui/elements/ui_style.h | 3 +++ src/ui/ui_mod_details_panel.cpp | 38 +++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/ui/elements/ui_style.cpp b/src/ui/elements/ui_style.cpp index b1293d3..1736501 100644 --- a/src/ui/elements/ui_style.cpp +++ b/src/ui/elements/ui_style.cpp @@ -424,4 +424,17 @@ namespace recompui { set_property(Rml::PropertyId::TextAlign, to_rml(text_align), Animation()); } + void Style::set_gap(float size, Unit unit, Animation animation) { + set_row_gap(size, unit, animation); + set_column_gap(size, unit, animation); + } + + void Style::set_row_gap(float size, Unit unit, Animation animation) { + set_property(Rml::PropertyId::RowGap, Rml::Property(size, to_rml(unit)), animation); + } + + void Style::set_column_gap(float size, Unit unit, Animation animation) { + set_property(Rml::PropertyId::ColumnGap, Rml::Property(size, to_rml(unit)), animation); + } + } // namespace recompui \ No newline at end of file diff --git a/src/ui/elements/ui_style.h b/src/ui/elements/ui_style.h index 32bf1eb..ba2e5af 100644 --- a/src/ui/elements/ui_style.h +++ b/src/ui/elements/ui_style.h @@ -77,6 +77,9 @@ namespace recompui { void set_font_style(FontStyle style); void set_font_weight(uint32_t weight, Animation animation = Animation()); void set_text_align(TextAlign text_align); + void set_gap(float size, Unit unit = Unit::Dp, Animation animation = Animation()); + void set_row_gap(float size, Unit unit = Unit::Dp, Animation animation = Animation()); + void set_column_gap(float size, Unit unit = Unit::Dp, Animation animation = Animation()); }; } // namespace recompui \ No newline at end of file diff --git a/src/ui/ui_mod_details_panel.cpp b/src/ui/ui_mod_details_panel.cpp index 006e2eb..9404229 100644 --- a/src/ui/ui_mod_details_panel.cpp +++ b/src/ui/ui_mod_details_panel.cpp @@ -7,15 +7,19 @@ namespace recompui { ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) { set_flex(1.0f, 1.0f, 200.0f); set_height(100.0f, Unit::Percent); + set_display(Display::Flex); set_flex_direction(FlexDirection::Column); set_border_bottom_right_radius(16.0f); set_background_color(Color{ 190, 184, 219, 25 }); header_container = new Container(FlexDirection::Row, JustifyContent::FlexStart, this); + header_container->set_flex(0.0f, 0.0f); header_container->set_padding(16.0f); + header_container->set_gap(16.0f); header_container->set_background_color(Color{ 0, 0, 0, 89 }); { thumbnail_container = new Container(FlexDirection::Column, JustifyContent::SpaceEvenly, header_container); + thumbnail_container->set_flex(0.0f, 0.0f); { thumbnail_image = new Image(thumbnail_container); thumbnail_image->set_width(100.0f); @@ -24,10 +28,9 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) { } header_details_container = new Container(FlexDirection::Column, JustifyContent::SpaceEvenly, header_container); - header_details_container->set_width(100.0f, Unit::Percent); - header_details_container->set_margin_left(32.0f); - header_details_container->set_overflow(Overflow::Hidden); - + header_details_container->set_flex(1.0f, 1.0f); + header_details_container->set_flex_basis(100.0f, Unit::Percent); + header_details_container->set_text_align(TextAlign::Left); { title_label = new Label(LabelStyle::Large, header_details_container); version_label = new Label(LabelStyle::Normal, header_details_container); @@ -35,19 +38,26 @@ ModDetailsPanel::ModDetailsPanel(Element *parent) : Element(parent) { } body_container = new recompui::Container(FlexDirection::Column, JustifyContent::FlexStart, this); - body_container->set_padding_left(16.0f); + body_container->set_flex(0.0f, 0.0f); + body_container->set_text_align(TextAlign::Left); + body_container->set_padding(16.0f); + body_container->set_gap(16.0f); { description_label = new Label(LabelStyle::Normal, body_container); authors_label = new Label(LabelStyle::Normal, body_container); - spacer_element = new Element(body_container); - buttons_container = new Container(FlexDirection::Row, JustifyContent::SpaceAround, body_container); - buttons_container->set_padding_left(16.0f); - { - enable_toggle = new Toggle(buttons_container); - enable_toggle->add_checked_callback(std::bind(&ModDetailsPanel::enable_toggle_checked, this, std::placeholders::_1)); - configure_button = new Button("Configure", recompui::ButtonStyle::Secondary, buttons_container); - erase_button = new Button("Erase", recompui::ButtonStyle::Secondary, buttons_container); - } + } + + spacer_element = new Element(this); + spacer_element->set_flex(1.0f, 0.0f); + + buttons_container = new Container(FlexDirection::Row, JustifyContent::SpaceAround, this); + buttons_container->set_flex(0.0f, 0.0f); + buttons_container->set_padding(16.0f); + { + enable_toggle = new Toggle(buttons_container); + enable_toggle->add_checked_callback(std::bind(&ModDetailsPanel::enable_toggle_checked, this, std::placeholders::_1)); + configure_button = new Button("Configure", recompui::ButtonStyle::Secondary, buttons_container); + erase_button = new Button("Erase", recompui::ButtonStyle::Secondary, buttons_container); } }