From 2326451761040807a15581ffd176537a6fd04c8e Mon Sep 17 00:00:00 2001 From: turanszkij Date: Mon, 6 Jun 2016 00:47:35 +0200 Subject: [PATCH] gui update --- WickedEngine/wiVersion.cpp | 2 +- WickedEngine/wiWidget.cpp | 50 +++++++++++++++++++++++++++++++++----- WickedEngine/wiWidget.h | 4 +++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 71e51d36f..455470def 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -7,7 +7,7 @@ namespace wiVersion // minor features, major bug fixes const int minor = 8; // minor bug fixes, alterations, refactors - const int revision = 0; + const int revision = 1; long GetVersion() diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index b28b83496..3278d58fe 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -374,9 +374,11 @@ void wiSlider::Update(wiGUI* gui) state = IDLE; } - hitBox.pos.x = Transform::translation.x; + float headWidth = scale.x*0.05f; + + hitBox.pos.x = Transform::translation.x - headWidth*0.5f; hitBox.pos.y = Transform::translation.y; - hitBox.siz.x = Transform::scale.x; + hitBox.siz.x = Transform::scale.x + headWidth; hitBox.siz.y = Transform::scale.y; XMFLOAT4 pointerPos = wiInputManager::GetInstance()->getpointer(); @@ -625,7 +627,7 @@ wiWindow::wiWindow(wiGUI* gui, const string& name) :wiWidget() // Add a grabber onto the title bar moveDragger = new wiButton(name + "move_dragger"); moveDragger->SetText(""); - moveDragger->SetSize(XMFLOAT2(scale.x - controlSize * 2, controlSize)); + moveDragger->SetSize(XMFLOAT2(scale.x - controlSize * 3, controlSize)); moveDragger->SetPos(XMFLOAT2(controlSize, 0)); moveDragger->OnDrag([this](wiEventArgs args) { this->Translate(XMFLOAT3(args.deltaPos.x, args.deltaPos.y, 0)); @@ -633,7 +635,6 @@ wiWindow::wiWindow(wiGUI* gui, const string& name) :wiWidget() gui->AddWidget(moveDragger); moveDragger->attachTo(this); - // Add close button to the top right corner closeButton = new wiButton(name + "_close_button"); closeButton->SetText("x"); @@ -645,6 +646,17 @@ wiWindow::wiWindow(wiGUI* gui, const string& name) :wiWidget() gui->AddWidget(closeButton); closeButton->attachTo(this); + // Add minimize button to the top right corner + minimizeButton = new wiButton(name + "_minimize_button"); + minimizeButton->SetText("-"); + minimizeButton->SetSize(XMFLOAT2(controlSize, controlSize)); + minimizeButton->SetPos(XMFLOAT2(translation.x + scale.x - controlSize*2, translation.y)); + minimizeButton->OnClick([this](wiEventArgs args) { + this->SetMinimized(!this->IsMinimized()); + }); + gui->AddWidget(minimizeButton); + minimizeButton->attachTo(this); + // Add a resizer control to the upperleft corner resizeDragger_UpperLeft = new wiButton(name + "resize_dragger_upper_left"); resizeDragger_UpperLeft->SetText(""); @@ -744,8 +756,11 @@ void wiWindow::Render(wiGUI* gui) wiColor color = GetColor(); // body - wiImage::Draw(wiTextureHelper::getInstance()->getColor(color) - , wiImageEffects(translation.x, translation.y, scale.x, scale.y), gui->GetGraphicsThread()); + if (!IsMinimized()) + { + wiImage::Draw(wiTextureHelper::getInstance()->getColor(color) + , wiImageEffects(translation.x, translation.y, scale.x, scale.y), gui->GetGraphicsThread()); + } scissorRect.bottom = (LONG)(translation.y + scale.y); @@ -758,10 +773,15 @@ void wiWindow::Render(wiGUI* gui) void wiWindow::SetVisible(bool value) { wiWidget::SetVisible(value); + SetMinimized(!value); if (closeButton != nullptr) { closeButton->SetVisible(value); } + if (minimizeButton != nullptr) + { + minimizeButton->SetVisible(value); + } if (moveDragger != nullptr) { moveDragger->SetVisible(value); @@ -787,3 +807,21 @@ void wiWindow::SetEnabled(bool value) x->SetEnabled(value); } } +void wiWindow::SetMinimized(bool value) +{ + minimized = value; + + if (resizeDragger_BottomRight != nullptr) + { + resizeDragger_BottomRight->SetVisible(!value); + } + for (auto& x : childrenWidgets) + { + x->SetVisible(!value); + } +} +bool wiWindow::IsMinimized() +{ + return minimized; +} + diff --git a/WickedEngine/wiWidget.h b/WickedEngine/wiWidget.h index 359aa0099..4b8ac9075 100644 --- a/WickedEngine/wiWidget.h +++ b/WickedEngine/wiWidget.h @@ -159,10 +159,12 @@ class wiWindow :public wiWidget protected: wiGUI* gui; wiButton* closeButton; + wiButton* minimizeButton; wiButton* resizeDragger_UpperLeft; wiButton* resizeDragger_BottomRight; wiButton* moveDragger; list childrenWidgets; + bool minimized; public: wiWindow(wiGUI* gui, const string& name = ""); virtual ~wiWindow(); @@ -176,5 +178,7 @@ public: virtual void SetVisible(bool value) override; virtual void SetEnabled(bool value) override; + void SetMinimized(bool value); + bool IsMinimized(); };