Main page dropdown buttons when not recording

This commit is contained in:
dec05eba
2025-04-22 02:14:24 +02:00
parent 19f3fe67bf
commit 719236d4f4
4 changed files with 26 additions and 3 deletions

6
TODO
View File

@@ -159,4 +159,8 @@ If CursorTrackerWayland fails then fallback to getting focused monitor by window
Maybe automatically switch to recording with the device that controls the monitor.
In that case also add all monitors available to capture in the capture list and automatically choose the gpu that controls the monitor.
Support cjk font. Use fc-match to find the location of the font. This also works in flatpak, in which case the fonts are in /run/host/..., where it lists system fonts.
Support cjk font. Use fc-match to find the location of the font. This also works in flatpak, in which case the fonts are in /run/host/..., where it lists system fonts.
Keyboard layout is incorrect on wayland when using kde plasma keyboard settings to setup multiple keyboards, for example when changing to french.
Text input is correct, but hotkey is incorrect.
Need to use "setxkbmap fr" as well.

View File

@@ -21,6 +21,7 @@ namespace gsr {
void set_item_label(const std::string &id, const std::string &new_label);
void set_item_icon(const std::string &id, mgl::Texture *texture);
void set_item_description(const std::string &id, const std::string &new_description);
void set_item_enabled(const std::string &id, bool enabled);
void set_description(std::string description_text);
void set_activated(bool activated);
@@ -36,6 +37,7 @@ namespace gsr {
mgl::Text description_text;
mgl::Texture *icon_texture = nullptr;
std::string id;
bool enabled = true;
};
std::vector<Item> items;

View File

@@ -1070,6 +1070,7 @@ namespace gsr {
on_press_start_replay(false, false);
}
};
button->set_item_enabled("save", false);
main_buttons_list->add_widget(std::move(button));
}
{
@@ -1096,6 +1097,7 @@ namespace gsr {
on_press_start_record(false);
}
};
button->set_item_enabled("pause", false);
main_buttons_list->add_widget(std::move(button));
}
{
@@ -1872,6 +1874,7 @@ namespace gsr {
record_dropdown_button_ptr->set_activated(true);
record_dropdown_button_ptr->set_description("Recording");
record_dropdown_button_ptr->set_item_icon("start", &get_theme().stop_texture);
record_dropdown_button_ptr->set_item_enabled("pause", true);
}
void Overlay::update_ui_recording_stopped() {
@@ -1885,6 +1888,7 @@ namespace gsr {
record_dropdown_button_ptr->set_item_label("pause", "Pause");
record_dropdown_button_ptr->set_item_icon("pause", &get_theme().pause_texture);
record_dropdown_button_ptr->set_item_enabled("pause", false);
paused = false;
}
@@ -1916,6 +1920,7 @@ namespace gsr {
replay_dropdown_button_ptr->set_activated(true);
replay_dropdown_button_ptr->set_description("On");
replay_dropdown_button_ptr->set_item_icon("start", &get_theme().stop_texture);
replay_dropdown_button_ptr->set_item_enabled("save", true);
}
void Overlay::update_ui_replay_stopped() {
@@ -1926,6 +1931,7 @@ namespace gsr {
replay_dropdown_button_ptr->set_activated(false);
replay_dropdown_button_ptr->set_description("Off");
replay_dropdown_button_ptr->set_item_icon("start", &get_theme().play_texture);
replay_dropdown_button_ptr->set_item_enabled("save", false);
}
static std::string get_date_str() {

View File

@@ -148,7 +148,7 @@ namespace gsr {
window.draw(separator);
}
if(mouse_inside_item == -1) {
if(mouse_inside_item == -1 && item.enabled) {
const bool inside = mgl::FloatRect(item_position, item_size).contains({ (float)mouse_pos.x, (float)mouse_pos.y });
if(inside) {
draw_rectangle_outline(window, item_position, item_size, get_color_theme().tint_color, border_size);
@@ -161,16 +161,18 @@ namespace gsr {
mgl::Sprite icon(item.icon_texture);
icon.set_height((int)(item_size.y * 0.4f));
icon.set_position((item_position + mgl::vec2f(padding_left, item_size.y * 0.5f - icon.get_size().y * 0.5f)).floor());
icon.set_color(item.enabled ? mgl::Color(255, 255, 255, 255) : mgl::Color(255, 255, 255, 80));
window.draw(icon);
icon_offset = icon.get_size().x + icon_spacing;
}
item.text.set_position((item_position + mgl::vec2f(padding_left + icon_offset, item_size.y * 0.5f - text_bounds.size.y * 0.5f)).floor());
item.text.set_color(item.enabled ? mgl::Color(255, 255, 255, 255) : mgl::Color(255, 255, 255, 80));
window.draw(item.text);
const auto description_bounds = item.description_text.get_bounds();
item.description_text.set_position((item_position + mgl::vec2f(item_size.x - description_bounds.size.x - padding_right, item_size.y * 0.5f - description_bounds.size.y * 0.5f)).floor());
item.description_text.set_color(mgl::Color(255, 255, 255, 120));
item.description_text.set_color(item.enabled ? mgl::Color(255, 255, 255, 120) : mgl::Color(255, 255, 255, 40));
window.draw(item.description_text);
item_position.y += item_size.y;
@@ -210,6 +212,15 @@ namespace gsr {
}
}
void DropdownButton::set_item_enabled(const std::string &id, bool enabled) {
for(auto &item : items) {
if(item.id == id) {
item.enabled = enabled;
return;
}
}
}
void DropdownButton::set_description(std::string description_text) {
description.set_string(std::move(description_text));
}