Separating safe window area from window area
This commit is contained in:
parent
97d299a346
commit
b1f6f04d37
18 changed files with 121 additions and 102 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <include/core/SkPath.h>
|
||||
#include <include/core/SkPathBuilder.h>
|
||||
#include "../GUIManager.hpp"
|
||||
#include "../../TimePoint.hpp"
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
#include "Helpers/ConvertVec.hpp"
|
||||
#include <include/core/SkCanvas.h>
|
||||
#include "../../TimePoint.hpp"
|
||||
#include <Eigen/Dense>
|
||||
#include <include/core/SkFont.h>
|
||||
#include <include/core/SkFontMgr.h>
|
||||
|
|
@ -12,7 +11,6 @@
|
|||
#include <Helpers/SCollision.hpp>
|
||||
#include <Helpers/Serializers.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "../../RichText/TextBox.hpp"
|
||||
#include "../../InputManager.hpp"
|
||||
#include "../GUIManagerID.hpp"
|
||||
|
||||
|
|
@ -108,8 +106,8 @@ struct UpdateInputData {
|
|||
float deltaTime = 0.0f;
|
||||
|
||||
float guiScaleMultiplier = 1.0f;
|
||||
Vector2f windowPos = {0.0f, 0.0f};
|
||||
Vector2f windowSize = {0.0f, 0.0f};
|
||||
SCollision::AABB<float> safeWindowRect;
|
||||
|
||||
std::shared_ptr<FontData> fonts;
|
||||
sk_sp<SkTypeface> textTypeface;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popup
|
|||
auto& bb = layoutElement->get_bb().value();
|
||||
if((popupPos.y() + bb.height()) > gui.io.windowSize.y())
|
||||
popupPos.y() -= bb.height();
|
||||
if((popupPos.x() + bb.width()) > gui.io.windowSize.x())
|
||||
if((popupPos.x() + bb.width()) > gui.io.windowSize.y())
|
||||
popupPos.x() -= bb.width();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "RadioButton.hpp"
|
||||
#include "../GUIManager.hpp"
|
||||
#include "../../TimePoint.hpp"
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ template <typename T> void TextBox<T>::clay_draw(SkCanvas* canvas, UpdateInputDa
|
|||
|
||||
template <typename T> void TextBox<T>::select() {
|
||||
if(!is_selected()) {
|
||||
SCollision::AABB<float> rect = {(boundingBox.value().min + gui.io.windowPos) * gui.io.guiScaleMultiplier, (boundingBox.value().max + gui.io.windowPos) * gui.io.guiScaleMultiplier};
|
||||
SCollision::AABB<float> rect = {boundingBox.value().min * gui.io.guiScaleMultiplier, boundingBox.value().max * gui.io.guiScaleMultiplier};
|
||||
unsigned id = gui.io.input->set_text_box_front(rect, userInfo.textInputProps);
|
||||
edit = TextEditData(id, textbox, cur);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,11 +74,8 @@ void GUIManager::clip_rect_transform(SkCanvas* canvas, std::vector<SCollision::A
|
|||
SCollision::AABB<float> c = clipRect.value();
|
||||
c.min *= io.guiScaleMultiplier;
|
||||
c.max *= io.guiScaleMultiplier;
|
||||
c.min += io.windowPos;
|
||||
c.max += io.windowPos;
|
||||
canvas->clipIRect(c.get_sk_irect());
|
||||
}
|
||||
canvas->translate(io.windowPos.x(), io.windowPos.y());
|
||||
canvas->scale(io.guiScaleMultiplier, io.guiScaleMultiplier);
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +283,6 @@ void GUIManager::draw(SkCanvas* c, bool skiaAA) {
|
|||
|
||||
void GUIManager::draw_force(SkCanvas* canvas, bool skiaAA) {
|
||||
canvas->save();
|
||||
canvas->translate(io.windowPos.x(), io.windowPos.y());
|
||||
canvas->scale(io.guiScaleMultiplier, io.guiScaleMultiplier);
|
||||
|
||||
for(size_t i = 0; i < static_cast<size_t>(renderCommands.length); i++) {
|
||||
|
|
@ -521,13 +517,15 @@ GUIFloatAnimation* GUIManager::float_animation(const char* animationID, const GU
|
|||
return toRet;
|
||||
}
|
||||
|
||||
void GUIManager::update_window(const Vector2f& windowPos, const Vector2f& windowSize, float guiScaleMultiplier) {
|
||||
if(io.windowPos != windowPos || io.windowSize != windowSize || io.guiScaleMultiplier != guiScaleMultiplier) {
|
||||
void GUIManager::update_window(const Vector2f& windowSize, const SCollision::AABB<float>& safeWindowRect, float guiScaleMultiplier) {
|
||||
if(io.windowSize != windowSize || io.safeWindowRect != safeWindowRect || io.guiScaleMultiplier != guiScaleMultiplier) {
|
||||
io.redrawSurface = true;
|
||||
set_to_layout();
|
||||
}
|
||||
io.windowPos = windowPos;
|
||||
io.windowSize = windowSize / guiScaleMultiplier;
|
||||
io.safeWindowRect = safeWindowRect;
|
||||
io.safeWindowRect.min /= guiScaleMultiplier;
|
||||
io.safeWindowRect.max /= guiScaleMultiplier;
|
||||
io.guiScaleMultiplier = guiScaleMultiplier;
|
||||
}
|
||||
|
||||
|
|
@ -692,19 +690,16 @@ void GUIManager::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
|||
}
|
||||
|
||||
void GUIManager::input_mouse_button_callback(InputManager::MouseButtonCallbackArgs button) {
|
||||
button.pos -= io.windowPos;
|
||||
button.pos /= io.guiScaleMultiplier;
|
||||
mouse_callback(button.pos, [&button] (ElementContainer* e) { e->elem->input_mouse_button_callback(button); });
|
||||
}
|
||||
|
||||
void GUIManager::input_mouse_motion_callback(InputManager::MouseMotionCallbackArgs motion) {
|
||||
motion.pos -= io.windowPos;
|
||||
motion.pos /= io.guiScaleMultiplier;
|
||||
mouse_callback(motion.pos, [&motion] (ElementContainer* e) { e->elem->input_mouse_motion_callback(motion); });
|
||||
}
|
||||
|
||||
void GUIManager::input_mouse_wheel_callback(InputManager::MouseWheelCallbackArgs wheel) {
|
||||
wheel.mousePos -= io.windowPos;
|
||||
wheel.mousePos /= io.guiScaleMultiplier;
|
||||
mouse_callback(wheel.mousePos, [&wheel] (ElementContainer* e) { e->elem->input_mouse_wheel_callback(wheel); });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class GUIManager {
|
|||
GUIFloatAnimation* float_animation(const char* animationID, const GUIFloatAnimationData& animation);
|
||||
|
||||
void update();
|
||||
void update_window(const Vector2f& windowPos, const Vector2f& windowSize, float guiScaleMultiplier);
|
||||
void update_window(const Vector2f& windowRect, const SCollision::AABB<float>& safeWindowRect, float guiScaleMultiplier);
|
||||
|
||||
UpdateInputData io;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue