diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/Button.cpp | 6 | ||||
-rw-r--r-- | src/gui/ComboBox.cpp | 28 | ||||
-rw-r--r-- | src/gui/CustomRendererWidget.cpp | 4 | ||||
-rw-r--r-- | src/gui/List.cpp | 20 | ||||
-rw-r--r-- | src/gui/ScrollablePage.cpp | 1 | ||||
-rw-r--r-- | src/gui/SettingsPage.cpp | 115 | ||||
-rw-r--r-- | src/gui/Subsection.cpp | 60 |
7 files changed, 167 insertions, 67 deletions
diff --git a/src/gui/Button.cpp b/src/gui/Button.cpp index 0cf5bee..bccf7b0 100644 --- a/src/gui/Button.cpp +++ b/src/gui/Button.cpp @@ -48,8 +48,10 @@ namespace gsr { window.draw(text); const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(window.get_mouse_position().to_vec2f()) && !has_parent_with_selected_child_widget(); - if(mouse_inside) - draw_rectangle_outline(window, draw_pos, item_size, get_theme().tint_color, std::max(1.0f, border_scale * get_theme().window_height)); + if(mouse_inside) { + const mgl::Color outline_color = (bg_color == get_theme().tint_color) ? mgl::Color(255, 255, 255) : get_theme().tint_color; + draw_rectangle_outline(window, draw_pos, item_size, outline_color, std::max(1.0f, border_scale * get_theme().window_height)); + } } mgl::vec2f Button::get_size() { diff --git a/src/gui/ComboBox.cpp b/src/gui/ComboBox.cpp index b344c4e..760ddae 100644 --- a/src/gui/ComboBox.cpp +++ b/src/gui/ComboBox.cpp @@ -22,6 +22,9 @@ namespace gsr { if(!visible) return true; + if(items.empty()) + return true; + const int padding_top = padding_top_scale * get_theme().window_height; const int padding_bottom = padding_bottom_scale * get_theme().window_height; const int padding_left = padding_left_scale * get_theme().window_height; @@ -73,9 +76,6 @@ namespace gsr { update_if_dirty(); - if(items.empty()) - return; - const int padding_top = padding_top_scale * get_theme().window_height; const int padding_bottom = padding_bottom_scale * get_theme().window_height; const int padding_left = padding_left_scale * get_theme().window_height; @@ -106,15 +106,17 @@ namespace gsr { const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(window.get_mouse_position().to_vec2f()) && !has_parent_with_selected_child_widget(); mgl::vec2f pos = draw_pos + mgl::vec2f(padding_left, padding_top); - Item &item = items[selected_item]; - item.text.set_position(pos.floor()); - if(show_dropdown || mouse_inside) { - const int border_size = std::max(1.0f, border_scale * get_theme().window_height); - const mgl::Color border_color = get_theme().tint_color; - draw_rectangle_outline(window, pos - mgl::vec2f(padding_left, padding_top), item_size.floor(), border_color, border_size); + if(selected_item < items.size()) { + Item &selected_item_widget = items[selected_item]; + selected_item_widget.text.set_position(pos.floor()); + if(show_dropdown || mouse_inside) { + const int border_size = std::max(1.0f, border_scale * get_theme().window_height); + const mgl::Color border_color = get_theme().tint_color; + draw_rectangle_outline(window, pos - mgl::vec2f(padding_left, padding_top), item_size.floor(), border_color, border_size); + } + window.draw(selected_item_widget.text); + pos.y += selected_item_widget.text.get_bounds().size.y + padding_top + padding_bottom; } - window.draw(item.text); - pos.y += item.text.get_bounds().size.y + padding_top + padding_bottom; for(size_t i = 0; i < items.size(); ++i) { Item &item = items[i]; @@ -185,6 +187,10 @@ namespace gsr { max_size.x = std::max(max_size.x, bounds.x + padding_left + padding_right); max_size.y += bounds.y + padding_top + padding_bottom; } + + if(max_size.x <= 0.001f) + max_size.x = 50.0f; + max_size.x += padding_left + get_dropdown_arrow_height(); dirty = false; } diff --git a/src/gui/CustomRendererWidget.cpp b/src/gui/CustomRendererWidget.cpp index 98b7caf..cfb113b 100644 --- a/src/gui/CustomRendererWidget.cpp +++ b/src/gui/CustomRendererWidget.cpp @@ -38,4 +38,8 @@ namespace gsr { return size; } + + void CustomRendererWidget::set_size(mgl::vec2f size) { + this->size = size; + } }
\ No newline at end of file diff --git a/src/gui/List.cpp b/src/gui/List.cpp index 849329f..81f0e80 100644 --- a/src/gui/List.cpp +++ b/src/gui/List.cpp @@ -52,6 +52,9 @@ namespace gsr { if(!widget->visible) continue; + if(i > 0) + draw_pos.y += spacing; + const auto widget_size = widget->get_size(); // TODO: Do this parent widget alignment for horizontal alignment and for other types of widget alignment // and other widgets. @@ -67,8 +70,6 @@ namespace gsr { if(widget.get() != selected_widget) widget->draw(window, mgl::vec2f(0.0f, 0.0f)); draw_pos.y += widget_size.y; - if(widget_size.y > 0.001f && i + 1 < widgets.size()) - draw_pos.y += spacing; } break; } @@ -78,6 +79,9 @@ namespace gsr { if(!widget->visible) continue; + if(i > 0) + draw_pos.x += spacing; + const auto widget_size = widget->get_size(); if(content_alignment == Alignment::CENTER) offset.y = floor(size.y * 0.5f - widget_size.y * 0.5f); @@ -88,8 +92,6 @@ namespace gsr { if(widget.get() != selected_widget) widget->draw(window, mgl::vec2f(0.0f, 0.0f)); draw_pos.x += widget_size.x; - if(widget_size.x > 0.001f && i + 1 < widgets.size()) - draw_pos.x += spacing; } break; } @@ -146,11 +148,12 @@ namespace gsr { if(!widget->visible) continue; + if(i > 0) + size.y += spacing; + const auto widget_size = widget->get_size(); size.x = std::max(size.x, widget_size.x); size.y += widget_size.y; - if(widget_size.y > 0.001f && i + 1 < widgets.size()) - size.y += spacing; } break; } @@ -160,10 +163,11 @@ namespace gsr { if(!widget->visible) continue; + if(i > 0) + size.x += spacing; + const auto widget_size = widget->get_size(); size.x += widget_size.x; - if(widget_size.x > 0.001f && i + 1 < widgets.size()) - size.x += spacing; size.y = std::max(size.y, widget_size.y); } break; diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp index a791d75..7e15edf 100644 --- a/src/gui/ScrollablePage.cpp +++ b/src/gui/ScrollablePage.cpp @@ -140,6 +140,7 @@ namespace gsr { } void ScrollablePage::add_widget(std::unique_ptr<Widget> widget) { + widget->parent_widget = this; widgets.push_back(std::move(widget)); } diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index 259df6c..12d1d99 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -3,8 +3,10 @@ #include "../../include/gui/Label.hpp" #include "../../include/gui/PageStack.hpp" #include "../../include/gui/FileChooser.hpp" +#include "../../include/gui/Subsection.hpp" #include "../../include/Theme.hpp" #include "../../include/GsrInfo.hpp" +#include "../../include/Utils.hpp" #include <mglpp/graphics/Rectangle.hpp> #include <mglpp/graphics/Sprite.hpp> @@ -61,9 +63,9 @@ namespace gsr { return record_area_box; } - std::unique_ptr<List> SettingsPage::create_record_area(const GsrInfo &gsr_info) { + std::unique_ptr<Widget> SettingsPage::create_record_area(const GsrInfo &gsr_info) { auto record_area_list = std::make_unique<List>(List::Orientation::VERTICAL); - record_area_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Record area:", get_theme().text_color)); + record_area_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Capture target:", get_theme().text_color)); record_area_list->add_widget(create_record_area_box(gsr_info)); return record_area_list; } @@ -121,14 +123,14 @@ namespace gsr { return restore_portal_session_list; } - std::unique_ptr<List> SettingsPage::create_capture_target(const GsrInfo &gsr_info) { + std::unique_ptr<Widget> SettingsPage::create_capture_target(const GsrInfo &gsr_info) { // TODO: List::Alignment::Center causes 1 frame glitch when switching record area but only the first time auto capture_target_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER); capture_target_list->add_widget(create_record_area(gsr_info)); capture_target_list->add_widget(create_select_window()); capture_target_list->add_widget(create_area_size_section()); capture_target_list->add_widget(create_restore_portal_session_section()); - return capture_target_list; + return std::make_unique<Subsection>("Record area", std::move(capture_target_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); } std::unique_ptr<ComboBox> SettingsPage::create_audio_track_selection_checkbox(const std::vector<AudioDevice> &audio_devices) { @@ -177,13 +179,12 @@ namespace gsr { return merge_audio_tracks_checkbox; } - std::unique_ptr<List> SettingsPage::create_audio_device_section(const std::vector<AudioDevice> &audio_devices) { + std::unique_ptr<Widget> SettingsPage::create_audio_device_section(const std::vector<AudioDevice> &audio_devices) { auto audio_device_section_list = std::make_unique<List>(List::Orientation::VERTICAL); - audio_device_section_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Audio:", get_theme().text_color)); audio_device_section_list->add_widget(create_add_audio_track_button(audio_devices)); audio_device_section_list->add_widget(create_audio_track_section(audio_devices)); audio_device_section_list->add_widget(create_merge_audio_tracks_checkbox()); - return audio_device_section_list; + return std::make_unique<Subsection>("Audio", std::move(audio_device_section_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); } std::unique_ptr<ComboBox> SettingsPage::create_video_quality_box() { @@ -241,7 +242,14 @@ namespace gsr { video_codec_box->add_item("VP8", "vp8"); if(gsr_info.supported_video_codecs.vp9) video_codec_box->add_item("VP9", "vp9"); - // TODO: Add hdr options + if(gsr_info.supported_video_codecs.hevc_hdr) + video_codec_box->add_item("HEVC (HDR)", "hevc_hdr"); + if(gsr_info.supported_video_codecs.hevc_10bit) + video_codec_box->add_item("HEVC (10 bit, reduces banding)", "hevc_10bit"); + if(gsr_info.supported_video_codecs.av1_hdr) + video_codec_box->add_item("AV1 (HDR)", "av1_hdr"); + if(gsr_info.supported_video_codecs.av1_10bit) + video_codec_box->add_item("AV1 (10 bit, reduces banding)", "av1_10bit"); if(gsr_info.supported_video_codecs.h264_software) video_codec_box->add_item("H264 Software Encoder (Slow, not recommended)", "h264_software"); video_codec_box_ptr = video_codec_box.get(); @@ -315,18 +323,39 @@ namespace gsr { framerate_info_list->add_widget(create_framerate_mode()); return framerate_info_list; } + + std::unique_ptr<Widget> SettingsPage::create_record_cursor_section() { + auto record_cursor_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record cursor"); + record_cursor_checkbox->set_checked(true); + record_cursor_checkbox_ptr = record_cursor_checkbox.get(); + return record_cursor_checkbox; + } - std::unique_ptr<List> SettingsPage::create_settings(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices) { + std::unique_ptr<Widget> SettingsPage::create_video_section(const GsrInfo &gsr_info) { + auto video_section_list = std::make_unique<List>(List::Orientation::VERTICAL); + video_section_list->add_widget(create_video_quality_section()); + video_section_list->add_widget(create_codec_section(gsr_info)); + video_section_list->add_widget(create_framerate_section()); + video_section_list->add_widget(create_record_cursor_section()); + return std::make_unique<Subsection>("Video", std::move(video_section_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); + } + + std::unique_ptr<Widget> SettingsPage::create_settings(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices) { auto settings_list = std::make_unique<List>(List::Orientation::VERTICAL); settings_list->set_spacing(0.018f); - settings_list->add_widget(create_view_radio_button()); settings_list->add_widget(create_capture_target(gsr_info)); settings_list->add_widget(create_audio_device_section(audio_devices)); - settings_list->add_widget(create_video_quality_section()); - settings_list->add_widget(create_codec_section(gsr_info)); - settings_list->add_widget(create_framerate_section()); + settings_list->add_widget(create_video_section(gsr_info)); settings_list_ptr = settings_list.get(); - return settings_list; + + auto page_list = std::make_unique<List>(List::Orientation::VERTICAL); + page_list->set_spacing(0.018f); + page_list->add_widget(create_view_radio_button()); + auto scrollable_page = std::make_unique<ScrollablePage>(content_page_ptr->get_inner_size() - mgl::vec2f(0.0f, page_list->get_size().y + 0.018f * get_theme().window_height)); + settings_scrollable_page_ptr = scrollable_page.get(); + scrollable_page->add_widget(std::move(settings_list)); + page_list->add_widget(std::move(scrollable_page)); + return page_list; } void SettingsPage::add_widgets(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices) { @@ -346,6 +375,10 @@ namespace gsr { record_area_box_ptr->set_selected_item(gsr_info.supported_capture_options.monitors.front().name); else if(gsr_info.supported_capture_options.portal) record_area_box_ptr->set_selected_item("portal"); + else if(gsr_info.supported_capture_options.window) + record_area_box_ptr->set_selected_item("window"); + else + record_area_box_ptr->on_selection_changed("", ""); } void SettingsPage::add_page_specific_widgets() { @@ -365,7 +398,7 @@ namespace gsr { std::unique_ptr<List> SettingsPage::create_save_directory(const char *label) { auto save_directory_list = std::make_unique<List>(List::Orientation::VERTICAL); save_directory_list->add_widget(std::make_unique<Label>(&get_theme().body_font, label, get_theme().text_color)); - auto save_directory_button = std::make_unique<Button>(&get_theme().body_font, "/home/dec05eba", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120)); + auto save_directory_button = std::make_unique<Button>(&get_theme().body_font, get_videos_dir().c_str(), mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120)); save_directory_button_ptr = save_directory_button.get(); save_directory_button->on_click = [this]() { auto select_directory_page = std::make_unique<GsrPage>(); @@ -424,15 +457,10 @@ namespace gsr { replay_data_list->add_widget(create_save_directory("Directory to save replays:")); replay_data_list->add_widget(create_container_section()); replay_data_list->add_widget(create_replay_time()); - settings_list_ptr->add_widget(std::move(replay_data_list)); + settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(replay_data_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f))); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); - auto record_cursor_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record cursor"); - record_cursor_checkbox->set_checked(true); - record_cursor_checkbox_ptr = record_cursor_checkbox.get(); - checkboxes_list->add_widget(std::move(record_cursor_checkbox)); - auto show_replay_started_notification_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Show replay started notification"); show_replay_started_notification_checkbox->set_checked(true); show_replay_started_notification_checkbox_ptr = show_replay_started_notification_checkbox.get(); @@ -448,17 +476,18 @@ namespace gsr { show_replay_saved_notification_checkbox_ptr = show_replay_saved_notification_checkbox.get(); checkboxes_list->add_widget(std::move(show_replay_saved_notification_checkbox)); - settings_list_ptr->add_widget(std::move(checkboxes_list)); + auto notifications_subsection = std::make_unique<Subsection>("Notifications", std::move(checkboxes_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); + Subsection *notifications_subsection_ptr = notifications_subsection.get(); + settings_list_ptr->add_widget(std::move(notifications_subsection)); - view_radio_button_ptr->on_selection_changed = [this](const std::string &text, const std::string &id) { + view_radio_button_ptr->on_selection_changed = [this, notifications_subsection_ptr](const std::string &text, const std::string &id) { (void)text; const bool advanced_view = id == "advanced"; color_range_list_ptr->set_visible(advanced_view); codec_list_ptr->set_visible(advanced_view); framerate_mode_list_ptr->set_visible(advanced_view); - show_replay_started_notification_checkbox_ptr->set_visible(advanced_view); - show_replay_stopped_notification_checkbox_ptr->set_visible(advanced_view); - show_replay_saved_notification_checkbox_ptr->set_visible(advanced_view); + notifications_subsection_ptr->set_visible(advanced_view); + settings_scrollable_page_ptr->reset_scroll(); }; view_radio_button_ptr->on_selection_changed("Simple", "simple"); } @@ -467,15 +496,10 @@ namespace gsr { auto file_list = std::make_unique<List>(List::Orientation::HORIZONTAL); file_list->add_widget(create_save_directory("Directory to save the video:")); file_list->add_widget(create_container_section()); - settings_list_ptr->add_widget(std::move(file_list)); + settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f))); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); - auto record_cursor_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record cursor"); - record_cursor_checkbox->set_checked(true); - record_cursor_checkbox_ptr = record_cursor_checkbox.get(); - checkboxes_list->add_widget(std::move(record_cursor_checkbox)); - auto show_recording_started_notification_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Show recording started notification"); show_recording_started_notification_checkbox->set_checked(true); show_recording_started_notification_checkbox_ptr = show_recording_started_notification_checkbox.get(); @@ -486,16 +510,18 @@ namespace gsr { show_video_saved_notification_checkbox_ptr = show_video_saved_notification_checkbox.get(); checkboxes_list->add_widget(std::move(show_video_saved_notification_checkbox)); - settings_list_ptr->add_widget(std::move(checkboxes_list)); + auto notifications_subsection = std::make_unique<Subsection>("Notifications", std::move(checkboxes_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); + Subsection *notifications_subsection_ptr = notifications_subsection.get(); + settings_list_ptr->add_widget(std::move(notifications_subsection)); - view_radio_button_ptr->on_selection_changed = [this](const std::string &text, const std::string &id) { + view_radio_button_ptr->on_selection_changed = [this, notifications_subsection_ptr](const std::string &text, const std::string &id) { (void)text; const bool advanced_view = id == "advanced"; color_range_list_ptr->set_visible(advanced_view); codec_list_ptr->set_visible(advanced_view); framerate_mode_list_ptr->set_visible(advanced_view); - show_recording_started_notification_checkbox_ptr->set_visible(advanced_view); - show_video_saved_notification_checkbox_ptr->set_visible(advanced_view); + notifications_subsection_ptr->set_visible(advanced_view); + settings_scrollable_page_ptr->reset_scroll(); }; view_radio_button_ptr->on_selection_changed("Simple", "simple"); } @@ -570,15 +596,10 @@ namespace gsr { streaming_info_list->add_widget(create_stream_key_section()); streaming_info_list->add_widget(create_stream_url_section()); streaming_info_list->add_widget(create_stream_container_section()); - settings_list_ptr->add_widget(std::move(streaming_info_list)); + settings_list_ptr->add_widget(std::make_unique<Subsection>("Streaming info", std::move(streaming_info_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f))); auto checkboxes_list = std::make_unique<List>(List::Orientation::VERTICAL); - auto record_cursor_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record cursor"); - record_cursor_checkbox->set_checked(true); - record_cursor_checkbox_ptr = record_cursor_checkbox.get(); - checkboxes_list->add_widget(std::move(record_cursor_checkbox)); - auto show_streaming_started_notification_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Show streaming started notification"); show_streaming_started_notification_checkbox->set_checked(true); show_streaming_started_notification_checkbox_ptr = show_streaming_started_notification_checkbox.get(); @@ -589,7 +610,9 @@ namespace gsr { show_streaming_stopped_notification_checkbox_ptr = show_streaming_stopped_notification_checkbox.get(); checkboxes_list->add_widget(std::move(show_streaming_stopped_notification_checkbox)); - settings_list_ptr->add_widget(std::move(checkboxes_list)); + auto notifications_subsection = std::make_unique<Subsection>("Notifications", std::move(checkboxes_list), mgl::vec2f(content_page_ptr->get_inner_size().x, 0.0f)); + Subsection *notifications_subsection_ptr = notifications_subsection.get(); + settings_list_ptr->add_widget(std::move(notifications_subsection)); streaming_service_box_ptr->on_selection_changed = [this](const std::string &text, const std::string &id) { (void)text; @@ -604,14 +627,14 @@ namespace gsr { }; streaming_service_box_ptr->on_selection_changed("Twitch", "twitch"); - view_radio_button_ptr->on_selection_changed = [this](const std::string &text, const std::string &id) { + view_radio_button_ptr->on_selection_changed = [this, notifications_subsection_ptr](const std::string &text, const std::string &id) { (void)text; const bool advanced_view = id == "advanced"; color_range_list_ptr->set_visible(advanced_view); codec_list_ptr->set_visible(advanced_view); framerate_mode_list_ptr->set_visible(advanced_view); - show_streaming_started_notification_checkbox_ptr->set_visible(advanced_view); - show_streaming_stopped_notification_checkbox_ptr->set_visible(advanced_view); + notifications_subsection_ptr->set_visible(advanced_view); + settings_scrollable_page_ptr->reset_scroll(); }; view_radio_button_ptr->on_selection_changed("Simple", "simple"); } diff --git a/src/gui/Subsection.cpp b/src/gui/Subsection.cpp new file mode 100644 index 0000000..74b65e0 --- /dev/null +++ b/src/gui/Subsection.cpp @@ -0,0 +1,60 @@ +#include "../../include/gui/Subsection.hpp" +#include "../../include/Theme.hpp" + +#include <mglpp/window/Window.hpp> +#include <mglpp/graphics/Rectangle.hpp> + +namespace gsr { + static const float margin_top_scale = 0.015f; + static const float margin_bottom_scale = 0.015f; + static const float margin_left_scale = 0.015f; + static const float margin_right_scale = 0.015f; + static const float title_spacing_scale = 0.015f; + + Subsection::Subsection(const char *title, std::unique_ptr<Widget> inner_widget, mgl::vec2f size) : + label(&get_theme().title_font, title, get_theme().text_color), + inner_widget(std::move(inner_widget)), + size(size) + { + this->inner_widget->parent_widget = this; + } + + bool Subsection::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f) { + if(!visible) + return true; + + return inner_widget->on_event(event, window, mgl::vec2f(0.0f, 0.0f)); + } + + void Subsection::draw(mgl::Window &window, mgl::vec2f offset) { + if(!visible) + return; + + mgl::vec2f draw_pos = position + offset; + mgl::Rectangle background(draw_pos.floor(), get_size().floor()); + background.set_color(mgl::Color(25, 30, 34)); + window.draw(background); + + draw_pos += mgl::vec2f(margin_left_scale, margin_top_scale) * mgl::vec2f(get_theme().window_height, get_theme().window_height); + label.draw(window, draw_pos); + draw_pos.y += label.get_size().y + title_spacing_scale * get_theme().window_height; + + inner_widget->set_position(draw_pos); + inner_widget->draw(window, mgl::vec2f(0.0f, 0.0f)); + } + + mgl::vec2f Subsection::get_size() { + if(!visible) + return {0.0f, 0.0f}; + + const mgl::vec2f margin_size = mgl::vec2f(margin_left_scale + margin_right_scale, margin_top_scale + margin_bottom_scale) * mgl::vec2f(get_theme().window_height, get_theme().window_height); + mgl::vec2f widgets_size = mgl::vec2f(0.0f, label.get_size().y + title_spacing_scale * get_theme().window_height) + inner_widget->get_size() + margin_size; + + if(std::abs(size.x) > 0.001f) + widgets_size.x = size.x; + if(std::abs(size.y) > 0.001f) + widgets_size.y = size.y; + + return widgets_size; + } +}
\ No newline at end of file |