mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
Keep the frames of the GUI inside the content area
The engine draws the window bar on top of the GUI, so a frame as high as the window lost its top to the bar. GUI::act() limits such a frame to the content area and places it right below the bar; frames that are smaller than the window are not touched.
This commit is contained in:
parent
fbedfad478
commit
3a574ade8c
1 changed files with 12 additions and 2 deletions
|
|
@ -243,10 +243,20 @@ void GUI::actFocused() {
|
|||
|
||||
void GUI::act(float delta, const glm::uvec2& vp) {
|
||||
const uint inset = static_cast<uint>(viewportOffset);
|
||||
const uint contentHeight = vp.y > inset ? vp.y - inset : vp.y;
|
||||
container->setPos({0.0f, static_cast<float>(inset)});
|
||||
container->setSize({vp.x, vp.y > inset ? vp.y - inset : vp.y});
|
||||
container->setSize({vp.x, contentHeight});
|
||||
for (auto& pair : frames) {
|
||||
pair.second->act(delta);
|
||||
auto& frame = *pair.second;
|
||||
auto size = frame.getSize();
|
||||
// the bar covers the top of the window, so a frame as high as the
|
||||
// window is limited to the content area
|
||||
if (size.y > static_cast<float>(contentHeight)) {
|
||||
size.y = static_cast<float>(contentHeight);
|
||||
frame.setSize(size);
|
||||
frame.setPos({0.0f, static_cast<float>(inset)});
|
||||
}
|
||||
frame.act(delta);
|
||||
}
|
||||
auto prevfocus = focus;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue