Window resize looks correct. Also adjusted some things.
This commit is contained in:
@@ -72,7 +72,7 @@ namespace JUI
|
||||
public:
|
||||
Window();
|
||||
Window(Widget* parent);
|
||||
UDim2 GetMinSize() const;
|
||||
Vector2 GetMinSize() const;
|
||||
Vector2 GetMaxSize() const;
|
||||
Vector2 GetCurrentSize() const;
|
||||
float GetTitlebarHeight() const;
|
||||
@@ -109,7 +109,7 @@ namespace JUI
|
||||
bool dockable = false;
|
||||
int titlebar_height = 16;
|
||||
Vector2 max_size;
|
||||
UDim2 min_size; //= {30, 30};
|
||||
Vector2 min_size; //= {30, 30};
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ namespace JUI
|
||||
Window::Window() : Widget(), Clickable(), Hoverable(), RectBase(), Draggable(), Resizable(), Dockable() {
|
||||
this->SetPosition({200, 200, 0, 0});
|
||||
this->SetSize({400, 200, 0, 0});
|
||||
min_size = {400, 200};
|
||||
this->BGColor({0,0,0,0,});
|
||||
|
||||
|
||||
@@ -83,8 +84,8 @@ namespace JUI
|
||||
};
|
||||
|
||||
DEBUG(std::format("{} {} {} {}", Topbar->GetSize().X.Pixels, Topbar->GetSize().Y.Pixels, Topbar->GetSize().X.Scale, Topbar->GetSize().Y.Scale))
|
||||
///min_size = exit_btn->GetSize() + Topbar->GetSize() + TitleLabel->GetSize();
|
||||
min_size = Topbar->GetSize();
|
||||
//min_size = exit_btn->GetSize() + Topbar->GetSize() + TitleLabel->GetSize();
|
||||
//= Topbar->GetSize();//+ exit_btn->GetSize();
|
||||
// TODO: fs_btn
|
||||
|
||||
|
||||
@@ -94,7 +95,7 @@ namespace JUI
|
||||
this->SetParent(parent);
|
||||
}
|
||||
|
||||
UDim2 Window::GetMinSize() const { return min_size; }
|
||||
Vector2 Window::GetMinSize() const { return min_size; }
|
||||
|
||||
Vector2 Window::GetMaxSize() const { return max_size; }
|
||||
|
||||
@@ -159,8 +160,39 @@ namespace JUI
|
||||
if (resizing) {
|
||||
UDim2 cursz = this->GetSize();
|
||||
Vector2 newsz;
|
||||
newsz.x = std::abs(GetAbsolutePosition().x - last_known_mouse_pos.x);
|
||||
newsz.y = std::abs(GetAbsolutePosition().y - last_known_mouse_pos.y);
|
||||
//x > y ? x - y : y - x
|
||||
Vector2 mpos = this->last_known_mouse_pos;
|
||||
Vector2 abspos = this->GetAbsolutePosition();
|
||||
//newsz.x = mpos.x > 0 ? abspos.x - mpos.x : abspos.x + mpos.x;
|
||||
//newsz.y = mpos.y > 0 ? abspos.y - mpos.y : abspos.y + mpos.y;
|
||||
newsz.x = abspos.x < 0 ? abspos.x - mpos.x : mpos.x - abspos.x ;
|
||||
newsz.y = abspos.y < 0 ? abspos.y - mpos.y : mpos.y - abspos.y ;
|
||||
|
||||
|
||||
//newsz.x = newsz.x / 100.f <= this->min_size.GetScale().x ? newsz.x : min_size.GetPixels().x;
|
||||
//newsz.y = newsz.y / 100.f <= this->min_size.GetScale().y ? newsz.y : min_size.GetPixels().y;
|
||||
//newsz.x = newsz.x <= this->min_size.GetPixels().x ? newsz.x : min_size.GetPixels().x;
|
||||
//newsz.y = newsz.y <= this->min_size.GetPixels().y ? newsz.x : min_size.GetPixels().y;
|
||||
|
||||
//.if ((newsz.x / 100.f <= this->min_size.GetScale().x)) {// || (newsz.x <= this->min_size.GetPixels().x))
|
||||
// newsz.x = this->min_size.GetScale().x / 100.f;
|
||||
if (newsz.x <= this->min_size.x) {
|
||||
newsz.x = this->min_size.x;
|
||||
}
|
||||
|
||||
|
||||
//if ((newsz.y / 100.f <= this->min_size.GetScale().y)) {// || (newsz.x <= this->min_size.GetPixels().x))
|
||||
// newsz.y = this->min_size.GetScale().y / 100.f;
|
||||
if (newsz.y <= this->min_size.y) {
|
||||
newsz.y = this->min_size.y;
|
||||
}
|
||||
|
||||
|
||||
//newsz.x = std::abs(GetAbsolutePosition().x - last_known_mouse_pos.x);
|
||||
//newsz.y = std::abs(GetAbsolutePosition().y - last_known_mouse_pos.y);
|
||||
DEBUG(std::format("cursz {} {}", cursz.GetPixels().x, cursz.GetPixels().y))
|
||||
DEBUG(std::format("newsz {} {}", newsz.x, newsz.y))
|
||||
DEBUG(std::format("mpos {} {}", mpos.x, mpos.y))
|
||||
|
||||
//if (cursz.X.Scale < min_size.X.Scale)// || (cursz.X.Scale <= min_size.X.Scale))
|
||||
// cursz.X.Pixels = std::abs(GetAbsolutePosition().x - last_known_mouse_pos.x);
|
||||
@@ -168,20 +200,22 @@ namespace JUI
|
||||
//if (cursz.Y.Scale < min_size.Y.Scale)// || (cursz.Y.Scale <= min_size.Y.Scale))
|
||||
// cursz.Y.Pixels = std::abs(GetAbsolutePosition().y - last_known_mouse_pos.y);
|
||||
|
||||
/*
|
||||
bool stop;
|
||||
if (newsz.x / 100.f <= min_size.GetScale().x)
|
||||
if (newsz.x / 100.f <= this->min_size.GetScale().x)
|
||||
stop = true;
|
||||
|
||||
if (newsz.y / 100.f <= min_size.GetScale().y)
|
||||
if (newsz.y / 100.f <= this->min_size.GetScale().y)
|
||||
stop = true;
|
||||
|
||||
if (newsz.x <= min_size.GetPixels().x)
|
||||
if (newsz.x <= this->min_size.GetPixels().x)
|
||||
stop = true;
|
||||
|
||||
if (newsz.y <= min_size.GetPixels().y)
|
||||
if (newsz.y <= this->min_size.GetPixels().y)
|
||||
stop = true;
|
||||
*/
|
||||
|
||||
if ((last_known_mouse_pos != initial_resize_offset) && !stop)
|
||||
if ((this->last_known_mouse_pos != this->initial_resize_offset))// && !stop)
|
||||
this->SetSize({{newsz}, {0,0}});//{newsz.x / 100.f, newsz.y / 100.f}});
|
||||
|
||||
//this->SetSize(UDim2{(int)last_known_mouse_pos.x, (int)last_known_mouse_pos.y, cursz.X.Scale, cursz.Y.Scale});
|
||||
|
Reference in New Issue
Block a user