CBaseWindow flipped pointers for use with CBaseContainer::Add()
This commit is contained in:
parent
6e524b1707
commit
3c7f999306
@ -57,7 +57,7 @@ static ui::Var<int> text({ "nonya" }, "Editable Text", 1);
|
||||
class TestWindow : public CBaseWindow {
|
||||
public:
|
||||
TestWindow(IWidget* parent)
|
||||
: CBaseWindow("root_test", parent) {
|
||||
: CBaseWindow(parent, "root_test") {
|
||||
this->always_visible = false;
|
||||
this->hover = false;
|
||||
SetMaxSize(1270, 1000);
|
||||
|
@ -58,11 +58,7 @@ public:
|
||||
|
||||
inline virtual void Show() { this->visible = true; }
|
||||
inline virtual void Hide() { this->visible = false; }
|
||||
inline virtual bool IsVisible() {
|
||||
if (GetParent())
|
||||
return GetParent()->IsVisible() && this->visible;
|
||||
return this->visible;
|
||||
}
|
||||
virtual bool IsVisible();
|
||||
|
||||
virtual bool IsHovered();
|
||||
virtual bool IsFocused();
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
class CBaseWindow : public CBaseContainer {
|
||||
public:
|
||||
inline CBaseWindow(std::string name = "unnamed", IWidget* parent = nullptr)
|
||||
inline CBaseWindow(IWidget* parent, std::string name = "unnamed")
|
||||
: CBaseContainer(name, parent) { }
|
||||
inline virtual ~CBaseWindow() {};
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
ui::Var<bool> gui_draw_bounds({ "Gui", "Debug" }, "Draw Bounds", false);
|
||||
ui::Var<bool> gui_visible({ "Gui" }, "Visible", true);
|
||||
Canvas::Canvas()
|
||||
: CBaseWindow("root") { }
|
||||
: CBaseWindow(nullptr, "root") { }
|
||||
|
||||
// Crashes associated with no set root in globals
|
||||
void Canvas::Setup() {
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "gui/widgets/titlebar.hpp"
|
||||
|
||||
CMenuWindow::CMenuWindow(std::string name, IWidget* parent)
|
||||
: CBaseWindow(name, parent) {
|
||||
: CBaseWindow(parent, name) {
|
||||
m_pList = new CMenuList("list", this);
|
||||
AddChild(m_pList);
|
||||
m_pActiveTab = 0;
|
||||
|
@ -78,13 +78,15 @@ std::pair<int, int> CBaseWidget::AbsolutePosition() {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CBaseWidget::IsVisible() {
|
||||
return this->visible && (!this->GetParent() || GetParent()->IsVisible());
|
||||
}
|
||||
|
||||
Canvas* CBaseWidget::GetCanvas() {
|
||||
auto* parent = GetParent();
|
||||
if (parent) {
|
||||
if (auto* canvas = parent->GetCanvas())
|
||||
return canvas;
|
||||
}
|
||||
auto* ret = dynamic_cast<Canvas*>(this);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = this->GetParent()->GetCanvas();
|
||||
assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -41,9 +41,8 @@ void CBaseWindow::MoveChildren() {
|
||||
if (c->GetPositionMode() != FLOATING)
|
||||
my += (size.second + 2);
|
||||
}
|
||||
if (GetParent()) {
|
||||
if (GetParent())
|
||||
SetSize(mx + 4, my + 2);
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseWindow::OnFocusGain() {
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "gui/canvas.hpp"
|
||||
|
||||
CDropdownList::CDropdownList(std::string name, CDropdown* menu, int offset)
|
||||
: CBaseContainer(name, nullptr) {
|
||||
: CBaseContainer(name, menu) {
|
||||
m_pMenu = menu;
|
||||
Hide();
|
||||
SetZIndex(5);
|
||||
|
Loading…
x
Reference in New Issue
Block a user