mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-05 22:40:44 +09:00
Add settings icon, close window when pressing the close button
This commit is contained in:
@@ -46,7 +46,7 @@ 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();
|
||||
if(mouse_inside)
|
||||
draw_rectangle_outline(window, draw_pos, item_size, get_theme().tint_color, border_scale * get_theme().window_height);
|
||||
draw_rectangle_outline(window, draw_pos, item_size, get_theme().tint_color, std::max(1.0f, border_scale * get_theme().window_height));
|
||||
}
|
||||
|
||||
mgl::vec2f Button::get_size() {
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace gsr {
|
||||
return mgl::vec2f(text_bounds.y, text_bounds.y).floor();
|
||||
}
|
||||
|
||||
void CheckBox::set_checked(bool checked) {
|
||||
this->checked = checked;
|
||||
}
|
||||
|
||||
bool CheckBox::is_checked() const {
|
||||
return checked;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace gsr {
|
||||
static const float padding_right_scale = 0.007f;
|
||||
static const float border_scale = 0.0015f;
|
||||
|
||||
ComboBox::ComboBox(mgl::Font *font) : font(font), dropdown_arrow(&get_theme().combobox_arrow) {
|
||||
ComboBox::ComboBox(mgl::Font *font) : font(font), dropdown_arrow(&get_theme().combobox_arrow_texture) {
|
||||
assert(font);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace gsr {
|
||||
Item &item = items[selected_item];
|
||||
item.text.set_position(pos.floor());
|
||||
if(show_dropdown || mouse_inside) {
|
||||
const int border_size = border_scale * get_theme().window_height;
|
||||
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);
|
||||
}
|
||||
|
||||
41
src/gui/CustomRendererWidget.cpp
Normal file
41
src/gui/CustomRendererWidget.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "../../include/gui/CustomRendererWidget.hpp"
|
||||
|
||||
#include <mglpp/window/Window.hpp>
|
||||
|
||||
namespace gsr {
|
||||
CustomRendererWidget::CustomRendererWidget(mgl::vec2f size) : size(size) {}
|
||||
|
||||
bool CustomRendererWidget::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) {
|
||||
if(!visible || !event_handler)
|
||||
return true;
|
||||
return event_handler(event, window, position + offset, size);
|
||||
}
|
||||
|
||||
void CustomRendererWidget::draw(mgl::Window &window, mgl::vec2f offset) {
|
||||
if(!visible)
|
||||
return;
|
||||
|
||||
const mgl::vec2f draw_pos = position + offset;
|
||||
|
||||
mgl_scissor prev_scissor;
|
||||
mgl_window_get_scissor(window.internal_window(), &prev_scissor);
|
||||
|
||||
mgl_scissor new_scissor = {
|
||||
mgl_vec2i{(int)draw_pos.x, (int)draw_pos.y},
|
||||
mgl_vec2i{(int)size.x, (int)size.y}
|
||||
};
|
||||
mgl_window_set_scissor(window.internal_window(), &new_scissor);
|
||||
|
||||
if(draw_handler)
|
||||
draw_handler(window, draw_pos, size);
|
||||
|
||||
mgl_window_set_scissor(window.internal_window(), &prev_scissor);
|
||||
}
|
||||
|
||||
mgl::vec2f CustomRendererWidget::get_size() {
|
||||
if(!visible)
|
||||
return {0.0f, 0.0f};
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace gsr {
|
||||
window.draw(background);
|
||||
|
||||
if(selected) {
|
||||
const int border_size = border_scale * get_theme().window_height;
|
||||
const int border_size = std::max(1.0f, border_scale * get_theme().window_height);
|
||||
draw_rectangle_outline(window, draw_pos.floor(), get_size().floor(), get_theme().tint_color, border_size);
|
||||
|
||||
const int caret_width = std::max(1.0f, caret_width_scale * get_theme().window_height);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace gsr {
|
||||
|
||||
const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(window.get_mouse_position().to_vec2f());
|
||||
if(can_select_item && mouse_inside) {
|
||||
const int border_size = border_scale * get_theme().window_height;
|
||||
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, draw_pos.floor(), item_size.floor(), border_color, border_size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user