aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-11-13 22:18:30 +0100
committerdec05eba <dec05eba@protonmail.com>2024-11-13 22:36:55 +0100
commit4ba1e814b748d57631f6b7afb7eaa63e8435c24e (patch)
treeaa49caab6f299fb42f404ace5907025616aad553 /src/gui
parent590428425e8d35c96fffca666a50755a65c1cdba (diff)
Add application audio option
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/CheckBox.cpp12
-rw-r--r--src/gui/Label.cpp4
-rw-r--r--src/gui/LineSeparator.cpp45
-rw-r--r--src/gui/SettingsPage.cpp215
-rw-r--r--src/gui/Subsection.cpp18
5 files changed, 255 insertions, 39 deletions
diff --git a/src/gui/CheckBox.cpp b/src/gui/CheckBox.cpp
index 9ae3b41..e2f591c 100644
--- a/src/gui/CheckBox.cpp
+++ b/src/gui/CheckBox.cpp
@@ -10,7 +10,7 @@ namespace gsr {
static const float spacing_scale = 0.005f;
static const float check_animation_speed = 10.0f;
- static mgl::Color color_multiply(mgl::Color color, float multiply) {
+ static mgl::Color color_multiply_ignore_alpha(mgl::Color color, float multiply) {
return mgl::Color(color.r * multiply, color.g * multiply, color.b * multiply, color.a);
}
@@ -18,12 +18,12 @@ namespace gsr {
return source + (destination - source) * interpolation;
}
- static mgl::Color interpolate_color(mgl::Color source, mgl::Color destination, float interpolation) {
+ static mgl::Color interpolate_color_ignore_alpha(mgl::Color source, mgl::Color destination, float interpolation) {
mgl::Color color;
color.r = linear_interpolation(source.r, destination.r, interpolation);
color.g = linear_interpolation(source.g, destination.g, interpolation);
color.b = linear_interpolation(source.b, destination.b, interpolation);
- color.a = linear_interpolation(source.a, destination.a, interpolation);
+ color.a = source.a;
return color;
}
@@ -61,9 +61,9 @@ namespace gsr {
apply_animation();
- const mgl::Color background_color_unchecked(0, 0, 0, 120);
- const mgl::Color background_color_checked = color_multiply(get_color_theme().tint_color, 0.6f);
- background_sprite.set_color(interpolate_color(background_color_unchecked, background_color_checked, toggle_animation_value));
+ const mgl::Color background_color_unchecked = color_multiply_ignore_alpha(mgl::Color(25, 30, 34), 0.6f);
+ const mgl::Color background_color_checked = color_multiply_ignore_alpha(get_color_theme().tint_color, 0.6f);
+ background_sprite.set_color(interpolate_color_ignore_alpha(background_color_unchecked, background_color_checked, toggle_animation_value));
background_sprite.set_position(draw_pos.floor());
window.draw(background_sprite);
diff --git a/src/gui/Label.cpp b/src/gui/Label.cpp
index 22a302f..773c2f9 100644
--- a/src/gui/Label.cpp
+++ b/src/gui/Label.cpp
@@ -22,6 +22,10 @@ namespace gsr {
text.set_string(std::move(str));
}
+ const std::string& Label::get_text() const {
+ return text.get_string();
+ }
+
mgl::vec2f Label::get_size() {
if(!visible)
return {0.0f, 0.0f};
diff --git a/src/gui/LineSeparator.cpp b/src/gui/LineSeparator.cpp
new file mode 100644
index 0000000..637c84f
--- /dev/null
+++ b/src/gui/LineSeparator.cpp
@@ -0,0 +1,45 @@
+#include "../../include/gui/LineSeparator.hpp"
+#include "../../include/Theme.hpp"
+
+#include <mglpp/window/Window.hpp>
+#include <mglpp/graphics/Rectangle.hpp>
+
+namespace gsr {
+ static const float height_scale = 0.001f;
+
+ static mgl::Color color_add_ignore_alpha(mgl::Color color, mgl::Color add) {
+ return {
+ (uint8_t)std::min((int)color.r + (int)add.r, 255),
+ (uint8_t)std::min((int)color.g + (int)add.g, 255),
+ (uint8_t)std::min((int)color.b + (int)add.b, 255),
+ color.a
+ };
+ }
+
+ LineSeparator::LineSeparator(Type type, float width) : type(type), width(width) {
+
+ }
+
+ bool LineSeparator::on_event(mgl::Event&, mgl::Window&, mgl::vec2f) {
+ return true;
+ }
+
+ void LineSeparator::draw(mgl::Window &window, mgl::vec2f offset) {
+ if(!visible)
+ return;
+
+ const mgl::vec2f draw_pos = (position + offset).floor();
+ const mgl::vec2f size = mgl::vec2f(width, std::max(1.0f, height_scale * get_theme().window_height)).floor();
+ mgl::Rectangle rectangle(draw_pos, size);
+ rectangle.set_color(color_add_ignore_alpha(mgl::Color(25, 30, 34), mgl::Color(30, 30, 30)));
+ window.draw(rectangle);
+ }
+
+ mgl::vec2f LineSeparator::get_size() {
+ if(!visible)
+ return {0.0f, 0.0f};
+
+ const mgl::vec2f size = mgl::vec2f(width, std::max(1.0f, height_scale * get_theme().window_height)).floor();
+ return size;
+ }
+} \ No newline at end of file
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index a08bd52..083fec5 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -1,6 +1,7 @@
#include "../../include/gui/SettingsPage.hpp"
#include "../../include/gui/GsrPage.hpp"
#include "../../include/gui/Label.hpp"
+#include "../../include/gui/LineSeparator.hpp"
#include "../../include/gui/PageStack.hpp"
#include "../../include/gui/FileChooser.hpp"
#include "../../include/gui/Subsection.hpp"
@@ -13,15 +14,19 @@
#include <mglpp/graphics/Text.hpp>
#include <mglpp/window/Window.hpp>
+#include <string.h>
+
namespace gsr {
- SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, std::vector<AudioDevice> audio_devices, Config &config, PageStack *page_stack) :
+ SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, Config &config, PageStack *page_stack) :
StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()),
type(type),
config(config),
- audio_devices(std::move(audio_devices)),
page_stack(page_stack),
settings_title_text("Settings", get_theme().title_font)
{
+ audio_devices = get_audio_devices();
+ application_audio = get_application_audio();
+
auto content_page = std::make_unique<GsrPage>();
content_page->add_button("Back", "back", get_color_theme().page_bg_color);
content_page->on_click = [page_stack](const std::string &id) {
@@ -177,7 +182,7 @@ namespace gsr {
return std::make_unique<Subsection>("Record area", std::move(ll), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
}
- std::unique_ptr<ComboBox> SettingsPage::create_audio_track_selection_checkbox() {
+ std::unique_ptr<ComboBox> SettingsPage::create_audio_device_selection_combobox() {
auto audio_device_box = std::make_unique<ComboBox>(&get_theme().body_font);
for(const auto &audio_device : audio_devices) {
audio_device_box->add_item(audio_device.description, audio_device.name);
@@ -185,7 +190,7 @@ namespace gsr {
return audio_device_box;
}
- std::unique_ptr<Button> SettingsPage::create_remove_audio_track_button(List *audio_device_list_ptr) {
+ std::unique_ptr<Button> SettingsPage::create_remove_audio_device_button(List *audio_device_list_ptr) {
auto remove_audio_track_button = std::make_unique<Button>(&get_theme().body_font, "Remove", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
remove_audio_track_button->on_click = [this, audio_device_list_ptr]() {
audio_devices_list_ptr->remove_widget(audio_device_list_ptr);
@@ -193,26 +198,25 @@ namespace gsr {
return remove_audio_track_button;
}
- std::unique_ptr<List> SettingsPage::create_audio_track() {
+ std::unique_ptr<List> SettingsPage::create_audio_device() {
auto audio_device_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
- audio_device_list->add_widget(create_audio_track_selection_checkbox());
- audio_device_list->add_widget(create_remove_audio_track_button(audio_device_list.get()));
+ audio_device_list->add_widget(create_audio_device_selection_combobox());
+ audio_device_list->add_widget(create_remove_audio_device_button(audio_device_list.get()));
return audio_device_list;
}
- std::unique_ptr<Button> SettingsPage::create_add_audio_track_button() {
- auto add_audio_track_button = std::make_unique<Button>(&get_theme().body_font, "Add audio track", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
- auto add_audio_track = [this]() {
- audio_devices_list_ptr->add_widget(create_audio_track());
+ std::unique_ptr<Button> SettingsPage::create_add_audio_device_button() {
+ auto add_audio_track_button = std::make_unique<Button>(&get_theme().body_font, "Add audio device", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ add_audio_track_button->on_click = [this]() {
+ audio_devices_list_ptr->add_widget(create_audio_device());
};
- add_audio_track_button->on_click = add_audio_track;
return add_audio_track_button;
}
- std::unique_ptr<List> SettingsPage::create_audio_track_section() {
+ std::unique_ptr<List> SettingsPage::create_audio_device_track_section() {
auto audio_devices_list = std::make_unique<List>(List::Orientation::VERTICAL);
audio_devices_list_ptr = audio_devices_list.get();
- audio_devices_list_ptr->add_widget(create_audio_track());
+ audio_devices_list_ptr->add_widget(create_audio_device());
return audio_devices_list;
}
@@ -223,13 +227,107 @@ namespace gsr {
return merge_audio_tracks_checkbox;
}
+ std::unique_ptr<RadioButton> SettingsPage::create_audio_type_button() {
+ auto audio_type_radio_button = std::make_unique<RadioButton>(&get_theme().body_font);
+ audio_type_radio_button->add_item("Audio devices", "audio_devices");
+ audio_type_radio_button->add_item("Application audio", "app_audio");
+ audio_type_radio_button_ptr = audio_type_radio_button.get();
+ return audio_type_radio_button;
+ }
+
std::unique_ptr<Widget> SettingsPage::create_audio_device_section() {
+ auto audio_devices_section_list = std::make_unique<List>(List::Orientation::VERTICAL);
+ audio_devices_section_list_ptr = audio_devices_section_list.get();
+ audio_devices_section_list->add_widget(std::make_unique<Label>(&get_theme().title_font, "Audio devices", get_color_theme().text_color));
+ audio_devices_section_list->add_widget(create_add_audio_device_button());
+ audio_devices_section_list->add_widget(create_audio_device_track_section());
+ return audio_devices_section_list;
+ }
+
+ std::unique_ptr<ComboBox> SettingsPage::create_application_audio_selection_combobox() {
+ auto audio_device_box = std::make_unique<ComboBox>(&get_theme().body_font);
+ for(const auto &app_audio : application_audio) {
+ audio_device_box->add_item(app_audio, app_audio);
+ }
+ return audio_device_box;
+ }
+
+ std::unique_ptr<Button> SettingsPage::create_remove_application_audio_button(List *app_audio_item) {
+ auto remove_audio_track_button = std::make_unique<Button>(&get_theme().body_font, "Remove", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ remove_audio_track_button->on_click = [this, app_audio_item]() {
+ application_audio_list_ptr->remove_widget(app_audio_item);
+ };
+ return remove_audio_track_button;
+ }
+
+ std::unique_ptr<List> SettingsPage::create_application_audio() {
+ auto application_audio_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+ application_audio_list->add_widget(create_application_audio_selection_combobox());
+ application_audio_list->add_widget(create_remove_application_audio_button(application_audio_list.get()));
+ return application_audio_list;
+ }
+
+ std::unique_ptr<List> SettingsPage::create_custom_application_audio() {
+ auto application_audio_list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+ application_audio_list->add_widget(std::make_unique<Entry>(&get_theme().body_font, "", (int)(get_theme().body_font.get_character_size() * 10.0f)));
+ application_audio_list->add_widget(create_remove_application_audio_button(application_audio_list.get()));
+ return application_audio_list;
+ }
+
+ std::unique_ptr<List> SettingsPage::create_add_application_audio_buttons() {
+ auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER);
+
+ auto add_application_audio_button = std::make_unique<Button>(&get_theme().body_font, "Add application audio", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ add_application_audio_button->on_click = [this]() {
+ application_audio_list_ptr->add_widget(create_application_audio());
+ };
+ list->add_widget(std::move(add_application_audio_button));
+
+ auto add_custom_application_audio_button = std::make_unique<Button>(&get_theme().body_font, "Add custom application audio", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120));
+ add_custom_application_audio_button->on_click = [this]() {
+ application_audio_list_ptr->add_widget(create_custom_application_audio());
+ };
+ list->add_widget(std::move(add_custom_application_audio_button));
+
+ return list;
+ }
+
+ std::unique_ptr<List> SettingsPage::create_application_audio_track_section() {
+ auto application_audio_list = std::make_unique<List>(List::Orientation::VERTICAL);
+ application_audio_list_ptr = application_audio_list.get();
+ return application_audio_list;
+ }
+
+ std::unique_ptr<CheckBox> SettingsPage::create_application_audio_invert_checkbox() {
+ auto application_audio_invert_checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Record all applications except the selected ones");
+ application_audio_invert_checkbox->set_checked(false);
+ application_audio_invert_checkbox_ptr = application_audio_invert_checkbox.get();
+ return application_audio_invert_checkbox;
+ }
+
+ std::unique_ptr<List> SettingsPage::create_application_audio_section() {
+ auto application_audio_section_list = std::make_unique<List>(List::Orientation::VERTICAL);
+ application_audio_section_list_ptr = application_audio_section_list.get();
+ application_audio_section_list->add_widget(std::make_unique<Label>(&get_theme().title_font, "Application audio", get_color_theme().text_color));
+ application_audio_section_list->add_widget(create_add_application_audio_buttons());
+ application_audio_section_list->add_widget(create_application_audio_track_section());
+ application_audio_section_list->add_widget(create_application_audio_invert_checkbox());
+ return application_audio_section_list;
+ }
+
+ std::unique_ptr<Widget> SettingsPage::create_audio_section() {
auto audio_device_section_list = std::make_unique<List>(List::Orientation::VERTICAL);
- audio_device_section_list->add_widget(create_add_audio_track_button());
- audio_device_section_list->add_widget(create_audio_track_section());
- audio_device_section_list->add_widget(create_merge_audio_tracks_checkbox());
- audio_device_section_list->add_widget(create_audio_codec());
- return std::make_unique<Subsection>("Audio", std::move(audio_device_section_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
+ List *audio_device_section_list_ptr = audio_device_section_list.get();
+ auto audio_section = std::make_unique<Subsection>("Audio", std::move(audio_device_section_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
+
+ audio_device_section_list_ptr->add_widget(create_audio_type_button());
+ audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Type::HORIZONTAL, audio_section->get_inner_size().x));
+ audio_device_section_list_ptr->add_widget(create_audio_device_section());
+ audio_device_section_list_ptr->add_widget(create_application_audio_section());
+ //audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Type::HORIZONTAL, audio_section->get_inner_size().x));
+ audio_device_section_list_ptr->add_widget(create_merge_audio_tracks_checkbox());
+ audio_device_section_list_ptr->add_widget(create_audio_codec());
+ return audio_section;
}
std::unique_ptr<List> SettingsPage::create_video_quality_box() {
@@ -418,7 +516,7 @@ namespace gsr {
auto settings_list = std::make_unique<List>(List::Orientation::VERTICAL);
settings_list->set_spacing(0.018f);
settings_list->add_widget(create_capture_target(gsr_info));
- settings_list->add_widget(create_audio_device_section());
+ settings_list->add_widget(create_audio_section());
settings_list->add_widget(create_video_section(gsr_info));
settings_list_ptr = settings_list.get();
settings_scrollable_page_ptr->add_widget(std::move(settings_list));
@@ -463,6 +561,17 @@ namespace gsr {
record_area_box_ptr->set_selected_item("window");
else
record_area_box_ptr->on_selection_changed("", "");
+
+ audio_type_radio_button_ptr->on_selection_changed = [this](const std::string&, const std::string &id) {
+ if(id == "audio_devices") {
+ audio_devices_section_list_ptr->set_visible(true);
+ application_audio_section_list_ptr->set_visible(false);
+ } else if(id == "app_audio") {
+ audio_devices_section_list_ptr->set_visible(false);
+ application_audio_section_list_ptr->set_visible(true);
+ }
+ };
+ audio_type_radio_button_ptr->on_selection_changed("", "audio_devices");
}
void SettingsPage::add_page_specific_widgets() {
@@ -496,7 +605,8 @@ namespace gsr {
select_directory_page->on_click = [this, file_chooser_ptr](const std::string &id) {
if(id == "save")
save_directory_button_ptr->set_text(file_chooser_ptr->get_current_directory());
- page_stack->pop();
+ else if(id == "cancel")
+ page_stack->pop();
};
page_stack->push(std::move(select_directory_page));
@@ -811,22 +921,50 @@ namespace gsr {
save_config(config);
}
- void SettingsPage::load_audio_tracks(RecordOptions &record_options) {
+ static const std::string* get_application_audio_by_name_case_insensitive(const std::vector<std::string> &application_audio, const std::string &name) {
+ for(const auto &app_audio : application_audio) {
+ if(strcasecmp(app_audio.c_str(), name.c_str()) == 0)
+ return &app_audio;
+ }
+ return nullptr;
+ }
+
+ void SettingsPage::load_audio_device_tracks(RecordOptions &record_options) {
audio_devices_list_ptr->clear();
for(const std::string &audio_track : record_options.audio_tracks) {
- std::unique_ptr<List> audio_track_widget = create_audio_track();
+ std::unique_ptr<List> audio_track_widget = create_audio_device();
ComboBox *audio_device_box = static_cast<ComboBox*>(audio_track_widget->get_child_widget_by_index(0));
audio_device_box->set_selected_item(audio_track);
audio_devices_list_ptr->add_widget(std::move(audio_track_widget));
}
}
+ void SettingsPage::load_application_audio_tracks(RecordOptions &record_options) {
+ application_audio_list_ptr->clear();
+ for(const std::string &audio_track : record_options.application_audio) {
+ const std::string *app_audio = get_application_audio_by_name_case_insensitive(application_audio, audio_track);
+ if(app_audio) {
+ std::unique_ptr<List> application_audio_widget = create_application_audio();
+ ComboBox *application_audio_box = static_cast<ComboBox*>(application_audio_widget->get_child_widget_by_index(0));
+ application_audio_box->set_selected_item(*app_audio);
+ application_audio_list_ptr->add_widget(std::move(application_audio_widget));
+ } else {
+ std::unique_ptr<List> application_audio_widget = create_custom_application_audio();
+ Entry *application_audio_entry = static_cast<Entry*>(application_audio_widget->get_child_widget_by_index(0));
+ application_audio_entry->set_text(audio_track);
+ application_audio_list_ptr->add_widget(std::move(application_audio_widget));
+ }
+ }
+ }
+
void SettingsPage::load_common(RecordOptions &record_options) {
record_area_box_ptr->set_selected_item(record_options.record_area_option);
merge_audio_tracks_checkbox_ptr->set_checked(record_options.merge_audio_tracks);
+ application_audio_invert_checkbox_ptr->set_checked(record_options.application_audio_invert);
change_video_resolution_checkbox_ptr->set_checked(record_options.change_video_resolution);
-
- load_audio_tracks(record_options);
+ audio_type_radio_button_ptr->set_selected_item(record_options.audio_type_view);
+ load_audio_device_tracks(record_options);
+ load_application_audio_tracks(record_options);
color_range_box_ptr->set_selected_item(record_options.color_range);
video_quality_box_ptr->set_selected_item(record_options.video_quality);
video_codec_box_ptr->set_selected_item(record_options.video_codec);
@@ -910,12 +1048,26 @@ namespace gsr {
container_box_ptr->set_selected_item(config.streaming_config.custom.container);
}
- static void save_audio_tracks(std::vector<std::string> &audio_tracks, List *audio_devices_list_ptr) {
- audio_tracks.clear();
- audio_devices_list_ptr->for_each_child_widget([&audio_tracks](std::unique_ptr<Widget> &child_widget) {
+ static void save_audio_device_tracks(std::vector<std::string> &audio_devices, List *audio_devices_list_ptr) {
+ audio_devices.clear();
+ audio_devices_list_ptr->for_each_child_widget([&audio_devices](std::unique_ptr<Widget> &child_widget) {
List *audio_device_line = static_cast<List*>(child_widget.get());
ComboBox *audio_device_box = static_cast<ComboBox*>(audio_device_line->get_child_widget_by_index(0));
- audio_tracks.push_back(audio_device_box->get_selected_id());
+ audio_devices.push_back(audio_device_box->get_selected_id());
+ return true;
+ });
+ }
+
+ static void save_application_audio_tracks(std::vector<std::string> &application_audio, List *application_audio_list_ptr) {
+ application_audio.clear();
+ application_audio_list_ptr->for_each_child_widget([&application_audio](std::unique_ptr<Widget> &child_widget) {
+ List *application_audio_line = static_cast<List*>(child_widget.get());
+ ComboBox *application_audio_box = dynamic_cast<ComboBox*>(application_audio_line->get_child_widget_by_index(0));
+ Entry *application_audio_entry = dynamic_cast<Entry*>(application_audio_line->get_child_widget_by_index(0));
+ if(application_audio_box)
+ application_audio.push_back(application_audio_box->get_selected_id());
+ else if(application_audio_entry)
+ application_audio.push_back(application_audio_entry->get_text());
return true;
});
}
@@ -929,8 +1081,11 @@ namespace gsr {
record_options.fps = atoi(framerate_entry_ptr->get_text().c_str());
record_options.video_bitrate = atoi(video_bitrate_entry_ptr->get_text().c_str());
record_options.merge_audio_tracks = merge_audio_tracks_checkbox_ptr->is_checked();
+ record_options.application_audio_invert = application_audio_invert_checkbox_ptr->is_checked();
record_options.change_video_resolution = change_video_resolution_checkbox_ptr->is_checked();
- save_audio_tracks(record_options.audio_tracks, audio_devices_list_ptr);
+ record_options.audio_type_view = audio_type_radio_button_ptr->get_selected_id();
+ save_audio_device_tracks(record_options.audio_tracks, audio_devices_list_ptr);
+ save_application_audio_tracks(record_options.application_audio, application_audio_list_ptr);
record_options.color_range = color_range_box_ptr->get_selected_id();
record_options.video_quality = video_quality_box_ptr->get_selected_id();
record_options.video_codec = video_codec_box_ptr->get_selected_id();
diff --git a/src/gui/Subsection.cpp b/src/gui/Subsection.cpp
index 16d6828..15eac04 100644
--- a/src/gui/Subsection.cpp
+++ b/src/gui/Subsection.cpp
@@ -36,8 +36,11 @@ namespace gsr {
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;
+
+ if(!label.get_text().empty()) {
+ 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));
@@ -48,7 +51,8 @@ namespace gsr {
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;
+ const float title_height = !label.get_text().empty() ? (label.get_size().y + title_spacing_scale * get_theme().window_height) : 0.0f;
+ mgl::vec2f widgets_size = mgl::vec2f(0.0f, title_height) + inner_widget->get_size() + margin_size;
if(std::abs(size.x) > 0.001f)
widgets_size.x = size.x;
@@ -57,4 +61,12 @@ namespace gsr {
return widgets_size;
}
+
+ mgl::vec2f Subsection::get_inner_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);
+ return get_size() - margin_size;
+ }
} \ No newline at end of file