gui window onResize callback , editor about window updates

This commit is contained in:
Turánszki János
2023-08-27 17:49:14 +02:00
parent 19280fc45e
commit 7dde93da20
6 changed files with 63 additions and 16 deletions
+16 -5
View File
@@ -173,8 +173,8 @@ void EditorComponent::ResizeLayout()
componentsWnd.SetPos(XMFLOAT2(screenW - componentsWnd.GetScale().x, screenH - componentsWnd.GetScale().y));
componentsWnd.scale_local = wi::math::Clamp(componentsWnd.scale_local, XMFLOAT3(1, 1, 1), XMFLOAT3(screenW, screenH, 1));
aboutLabel.SetSize(XMFLOAT2(screenW / 2.0f, screenH / 1.5f));
aboutLabel.SetPos(XMFLOAT2(screenW / 2.0f - aboutLabel.scale.x / 2.0f, screenH / 2.0f - aboutLabel.scale.y / 2.0f));
aboutWindow.SetSize(XMFLOAT2(screenW / 2.0f, screenH / 1.5f));
aboutWindow.SetPos(XMFLOAT2(screenW / 2.0f - aboutWindow.scale.x / 2.0f, screenH / 2.0f - aboutWindow.scale.y / 2.0f));
}
void EditorComponent::Load()
@@ -451,7 +451,7 @@ void EditorComponent::Load()
aboutButton.SetColor(wi::Color(50, 160, 200, 180), wi::gui::WIDGETSTATE::IDLE);
aboutButton.SetColor(wi::Color(120, 200, 200, 255), wi::gui::WIDGETSTATE::FOCUS);
aboutButton.OnClick([&](wi::gui::EventArgs args) {
aboutLabel.SetVisible(!aboutLabel.IsVisible());
aboutWindow.SetVisible(!aboutWindow.IsVisible());
});
GetGUI().AddWidget(&aboutButton);
@@ -517,10 +517,21 @@ void EditorComponent::Load()
aboutLabel.Create("AboutLabel");
aboutLabel.SetText(ss);
aboutLabel.SetVisible(false);
aboutLabel.SetSize(XMFLOAT2(600,4000));
aboutLabel.SetColor(wi::Color(113, 183, 214, 100));
aboutLabel.SetLocalizationEnabled(false);
GetGUI().AddWidget(&aboutLabel);
aboutWindow.AddWidget(&aboutLabel);
auto wctrl = wi::gui::Window::WindowControls::ALL;
wctrl &= ~wi::gui::Window::WindowControls::RESIZE_BOTTOMLEFT;
aboutWindow.Create("About", wctrl);
aboutWindow.SetVisible(false);
aboutWindow.SetPos(XMFLOAT2(100, 100));
aboutWindow.SetSize(XMFLOAT2(640, 480));
aboutWindow.OnResize([this]() {
aboutLabel.SetSize(XMFLOAT2(aboutWindow.GetWidgetAreaSize().x - 20, aboutLabel.GetSize().y));
});
GetGUI().AddWidget(&aboutWindow);
}
exitButton.Create("Exit");
+1
View File
@@ -45,6 +45,7 @@ public:
wi::gui::Button bugButton;
wi::gui::Button aboutButton;
wi::gui::Button exitButton;
wi::gui::Window aboutWindow;
wi::gui::Label aboutLabel;
OptionsWindow optionsWnd;
+22
View File
@@ -510,6 +510,20 @@ void GeneralWindow::Create(EditorComponent* _editor)
ktxConvButton.sprites[i].params.corners_rounding[1].radius = 8;
ktxConvButton.sprites[i].params.corners_rounding[2].radius = 8;
ktxConvButton.sprites[i].params.corners_rounding[3].radius = 8;
editor->aboutWindow.sprites[i].params.enableCornerRounding();
editor->aboutWindow.sprites[i].params.corners_rounding[0].radius = 10;
editor->aboutWindow.sprites[i].params.corners_rounding[1].radius = 10;
editor->aboutWindow.sprites[i].params.corners_rounding[2].radius = 10;
editor->aboutWindow.sprites[i].params.corners_rounding[3].radius = 10;
editor->aboutWindow.resizeDragger_UpperLeft.sprites[i].params.enableCornerRounding();
editor->aboutWindow.resizeDragger_UpperLeft.sprites[i].params.corners_rounding[0].radius = 10;
editor->aboutWindow.resizeDragger_UpperRight.sprites[i].params.enableCornerRounding();
editor->aboutWindow.resizeDragger_UpperRight.sprites[i].params.corners_rounding[1].radius = 10;
editor->aboutWindow.resizeDragger_BottomLeft.sprites[i].params.enableCornerRounding();
editor->aboutWindow.resizeDragger_BottomLeft.sprites[i].params.corners_rounding[2].radius = 10;
editor->aboutWindow.resizeDragger_BottomRight.sprites[i].params.enableCornerRounding();
editor->aboutWindow.resizeDragger_BottomRight.sprites[i].params.corners_rounding[3].radius = 10;
}
for (int i = 0; i < arraysize(wi::gui::Widget::sprites); ++i)
{
@@ -565,6 +579,14 @@ void GeneralWindow::Create(EditorComponent* _editor)
editor->save_text_color = theme.font.color;
editor->aboutLabel.SetShadowColor(wi::Color::Transparent());
editor->aboutLabel.SetColor(wi::Color::Transparent());
for (int i = 0; i < arraysize(wi::gui::Widget::sprites); ++i)
{
editor->aboutLabel.sprites[i].params.disableBackground();
editor->aboutLabel.sprites[i].params.blendFlag = wi::enums::BLENDMODE_ALPHA;
}
});
AddWidget(&themeCombo);
+9
View File
@@ -3362,6 +3362,10 @@ namespace wi::gui
{
onCollapse = func;
}
void Window::OnResize(std::function<void()> func)
{
onResize = func;
}
void Window::SetColor(wi::Color color, int id)
{
Widget::SetColor(color, id);
@@ -3537,6 +3541,11 @@ namespace wi::gui
scrollbar_vertical.AttachTo(this);
scrollbar_vertical.SetSafeArea(scrollbar_vertical.scale.x);
}
if (onResize)
{
onResize();
}
}
void Window::ExportLocalization(wi::Localization& localization) const
{
+12 -10
View File
@@ -18,16 +18,16 @@ namespace wi::gui
struct EventArgs
{
XMFLOAT2 clickPos = {};
XMFLOAT2 startPos = {};
XMFLOAT2 deltaPos = {};
XMFLOAT2 endPos = {};
float fValue = 0;
bool bValue = false;
int iValue = 0;
wi::Color color;
std::string sValue;
uint64_t userdata = 0;
XMFLOAT2 clickPos = {}; // mouse click coordinate
XMFLOAT2 startPos = {}; // mouse start position of operation (drag)
XMFLOAT2 deltaPos = {}; // mouse delta position of operation since last update (drag)
XMFLOAT2 endPos = {}; // mouse end position of operation (drag)
float fValue = 0; // generic float value of operation
bool bValue = false; // generic boolean value of operation
int iValue = 0; // generic integer value of operation
wi::Color color; // color value of color picker operation
std::string sValue; // generic string value of operation
uint64_t userdata = 0; // this will provide the userdata value that was set to a widget (or part of a widget)
};
enum WIDGETSTATE
@@ -619,6 +619,7 @@ namespace wi::gui
float control_size = 20;
std::function<void(EventArgs args)> onClose;
std::function<void(EventArgs args)> onCollapse;
std::function<void()> onResize;
public:
enum class WindowControls
@@ -669,6 +670,7 @@ namespace wi::gui
void OnClose(std::function<void(EventArgs args)> func);
void OnCollapse(std::function<void(EventArgs args)> func);
void OnResize(std::function<void()> func);
Button closeButton;
Button collapseButton;
+3 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 278;
const int revision = 279;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
@@ -137,6 +137,8 @@ Patreon supporters
- Peter Moore
- therealjtgill
- Nicolas Embleton
- Desuuc
- radino1977
)";
return credits;