dpi change will trigger ResizeLayout callback for render path
This commit is contained in:
@@ -825,7 +825,7 @@ The custom GUI, implemented with engine features
|
||||
[[Header]](../WickedEngine/wiGUI.h) [[Cpp]](../WickedEngine/wiGUI.cpp)
|
||||
The wiGUI is responsible to run a GUI interface and manage widgets.
|
||||
|
||||
<b>GUI Scaling:</b> To ensure correct GUI scaling, GUI elements should be designed for the current window size. If they are placed inside `RenderPath2D::ResizeBuffers()` function according to current screen size, it will ensure that GUI will be scaled on a Resilution change event, which is recommended.
|
||||
<b>GUI Scaling:</b> To ensure correct GUI scaling, GUI elements should be designed for the current window size. If they are placed inside `RenderPath2D::ResizeLayout()` function according to current screen size, it will ensure that GUI will be scaled on a Resolution or DPI change event, which is recommended.
|
||||
|
||||
### wiEventArgs
|
||||
[[Header]](../WickedEngine/wiWidget.h) [[Cpp]](../WickedEngine/wiWidget.cpp)
|
||||
|
||||
+5
-1
@@ -206,7 +206,10 @@ void EditorComponent::ResizeBuffers()
|
||||
hr = device->CreateRenderPass(&desc, &renderpass_selectionOutline[1]);
|
||||
assert(SUCCEEDED(hr));
|
||||
}
|
||||
|
||||
}
|
||||
void EditorComponent::ResizeLayout()
|
||||
{
|
||||
__super::ResizeLayout();
|
||||
|
||||
// GUI elements scaling:
|
||||
|
||||
@@ -724,6 +727,7 @@ void EditorComponent::Load()
|
||||
shaderButton->SetTooltip("Reload shaders from the default directory...");
|
||||
shaderButton->SetColor(wiColor(255, 33, 140, 180), wiWidget::WIDGETSTATE::IDLE);
|
||||
shaderButton->SetColor(wiColor(255, 100, 140, 255), wiWidget::WIDGETSTATE::FOCUS);
|
||||
shaderButton->font.params.size -= 2;
|
||||
shaderButton->OnClick([=](wiEventArgs args) {
|
||||
|
||||
wiRenderer::ReloadShaders();
|
||||
|
||||
@@ -120,6 +120,7 @@ public:
|
||||
const wiGraphics::Texture* GetGUIBlurredBackground() const override { return renderPath->GetGUIBlurredBackground(); }
|
||||
|
||||
void ResizeBuffers() override;
|
||||
void ResizeLayout() override;
|
||||
void Load() override;
|
||||
void Start() override;
|
||||
void FixedUpdate() override;
|
||||
|
||||
+2
-2
@@ -23,9 +23,9 @@ void Tests::Initialize()
|
||||
ActivatePath(&renderer);
|
||||
}
|
||||
|
||||
void TestsRenderer::ResizeBuffers()
|
||||
void TestsRenderer::ResizeLayout()
|
||||
{
|
||||
__super::ResizeBuffers();
|
||||
__super::ResizeLayout();
|
||||
|
||||
float screenW = wiRenderer::GetDevice()->GetScreenWidth();
|
||||
float screenH = wiRenderer::GetDevice()->GetScreenHeight();
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ class TestsRenderer : public RenderPath3D_Deferred
|
||||
public:
|
||||
void Load() override;
|
||||
void Update(float dt) override;
|
||||
void ResizeBuffers() override;
|
||||
void ResizeLayout() override;
|
||||
|
||||
void RunJobSystemTest();
|
||||
void RunFontTest();
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
#include "RenderPath2D.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiPlatform.h"
|
||||
|
||||
void RenderPath::ResizeLayout()
|
||||
{
|
||||
dpi = wiPlatform::GetDPI();
|
||||
}
|
||||
|
||||
void RenderPath::Update(float dt)
|
||||
{
|
||||
if (wiRenderer::ResolutionChanged() || !initial_resizebuffer)
|
||||
{
|
||||
ResizeBuffers();
|
||||
ResizeLayout();
|
||||
initial_resizebuffer = true;
|
||||
}
|
||||
if (dpi != wiPlatform::GetDPI())
|
||||
{
|
||||
ResizeLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPath::Start()
|
||||
|
||||
@@ -9,10 +9,13 @@ class RenderPath
|
||||
private:
|
||||
uint32_t layerMask = 0xFFFFFFFF;
|
||||
bool initial_resizebuffer = false;
|
||||
uint32_t dpi = 0;
|
||||
|
||||
protected:
|
||||
// create resolution dependant resources
|
||||
// create resolution dependant resources, such as render targets
|
||||
virtual void ResizeBuffers() {}
|
||||
// update resolution dependent elements, such as elements dependent on current monitor DPI
|
||||
virtual void ResizeLayout();
|
||||
public:
|
||||
std::function<void()> onStart;
|
||||
std::function<void()> onStop;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates
|
||||
const int minor = 41;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 3;
|
||||
const int revision = 4;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user