mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
remove Viewport class
This commit is contained in:
parent
105561ad77
commit
9843a1fc27
17 changed files with 60 additions and 115 deletions
|
|
@ -197,8 +197,8 @@ void GUI::actFocused() {
|
|||
}
|
||||
}
|
||||
|
||||
void GUI::act(float delta, const Viewport& vp) {
|
||||
container->setSize(vp.size());
|
||||
void GUI::act(float delta, const glm::uvec2& vp) {
|
||||
container->setSize(vp);
|
||||
container->act(delta);
|
||||
auto prevfocus = focus;
|
||||
|
||||
|
|
@ -233,7 +233,6 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
auto ctx = pctx.sub(batch2D.get());
|
||||
|
||||
auto& viewport = ctx.getViewport();
|
||||
glm::vec2 wsize = viewport.size();
|
||||
|
||||
auto& page = menu->getCurrent();
|
||||
if (page.panel) {
|
||||
|
|
@ -243,9 +242,9 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
panel->cropToContent();
|
||||
}
|
||||
}
|
||||
menu->setPos((wsize - menu->getSize()) / 2.0f);
|
||||
uicamera->setFov(wsize.y);
|
||||
uicamera->setAspectRatio(viewport.getRatio());
|
||||
menu->setPos((glm::vec2(viewport) - menu->getSize()) / 2.0f);
|
||||
uicamera->setFov(viewport.y);
|
||||
uicamera->setAspectRatio(viewport.x / static_cast<float>(viewport.y));
|
||||
|
||||
auto uishader = assets.get<Shader>("ui");
|
||||
uishader->use();
|
||||
|
|
@ -277,11 +276,11 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
batch2D->untexture();
|
||||
auto node = hover->getParent();
|
||||
while (node) {
|
||||
auto pos = node->calcPos();
|
||||
auto parentPos = node->calcPos();
|
||||
auto size = node->getSize();
|
||||
|
||||
batch2D->setColor(0, 255, 255);
|
||||
batch2D->lineRect(pos.x, pos.y, size.x-1, size.y-1);
|
||||
batch2D->lineRect(parentPos.x, parentPos.y, size.x-1, size.y-1);
|
||||
|
||||
node = node->getParent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class Viewport;
|
||||
class DrawContext;
|
||||
class Assets;
|
||||
class Camera;
|
||||
|
|
@ -106,7 +105,7 @@ namespace gui {
|
|||
/// @brief Main input handling and logic update method
|
||||
/// @param delta delta time
|
||||
/// @param viewport window size
|
||||
void act(float delta, const Viewport& viewport);
|
||||
void act(float delta, const glm::uvec2& viewport);
|
||||
|
||||
/// @brief Draw all visible elements on main container
|
||||
/// @param pctx parent graphics context
|
||||
|
|
|
|||
|
|
@ -237,8 +237,8 @@ void Label::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
textYOffset = pos.y-calcPos().y;
|
||||
totalLineHeight = lineHeight;
|
||||
|
||||
auto& viewport = pctx.getViewport();
|
||||
glm::vec4 bounds {0, 0, viewport.getWidth(), viewport.getHeight()};
|
||||
const auto& viewport = pctx.getViewport();
|
||||
glm::vec4 bounds {0, 0, viewport.x, viewport.y};
|
||||
if (parent) {
|
||||
auto ppos = parent->calcPos();
|
||||
auto psize = parent->getSize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue