mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-04-19 08:25:51 +09:00
Use scissor for pages
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#include "../../include/gui/StaticPage.hpp"
|
||||
|
||||
#include <mglpp/window/Window.hpp>
|
||||
|
||||
namespace gsr {
|
||||
StaticPage::StaticPage(mgl::vec2f size) : size(size) {}
|
||||
|
||||
bool StaticPage::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) {
|
||||
const mgl::vec2f draw_pos = position + offset;
|
||||
offset = draw_pos;
|
||||
@@ -18,16 +22,26 @@ namespace gsr {
|
||||
const mgl::vec2f draw_pos = position + offset;
|
||||
offset = draw_pos;
|
||||
|
||||
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);
|
||||
|
||||
for(auto &widget : widgets) {
|
||||
if(widget->move_to_top) {
|
||||
widget->move_to_top = false;
|
||||
std::swap(widget, widgets.back());
|
||||
}
|
||||
widget->draw(window, offset);
|
||||
}
|
||||
|
||||
for(auto &widget : widgets) {
|
||||
widget->draw(window, offset);
|
||||
}
|
||||
|
||||
mgl_window_set_scissor(window.internal_window(), &prev_scissor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user