mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
CtrlCore: Fixed issue with gtk CenterRect
This commit is contained in:
parent
9298d61657
commit
43dbe40be0
3 changed files with 18 additions and 18 deletions
|
|
@ -455,9 +455,8 @@ Ctrl& Ctrl::VCenterPosZ(int size, int delta) {
|
|||
Rect Ctrl::GetWorkArea(Point pt)
|
||||
{
|
||||
GuiLock __;
|
||||
static Array<Rect> rc;
|
||||
if (rc.IsEmpty())
|
||||
GetWorkArea(rc);
|
||||
Array<Rect> rc;
|
||||
GetWorkArea(rc);
|
||||
for(int i = 0; i < rc.GetCount(); i++)
|
||||
if(rc[i].Contains(pt))
|
||||
return rc[i];
|
||||
|
|
@ -468,10 +467,6 @@ Rect Ctrl::StdGetWorkArea() const
|
|||
{
|
||||
GuiLock __;
|
||||
|
||||
static Array<Rect> rc;
|
||||
if(rc.IsEmpty())
|
||||
GetWorkArea(rc);
|
||||
|
||||
const Ctrl *top = GetTopCtrl();
|
||||
if(top && top->IsOpen())
|
||||
return GetWorkArea(top->GetScreenRect().TopLeft());
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ void Ctrl::Create(Ctrl *owner, bool popup)
|
|||
tw->SyncSizeHints();
|
||||
|
||||
Rect r = GetRect();
|
||||
|
||||
|
||||
gtk_window_set_default_size (gtk(), LSC(r.GetWidth()), LSC(r.GetHeight()));
|
||||
|
||||
gtk_window_move(gtk(), LSC(r.left), LSC(r.top));
|
||||
|
|
|
|||
|
|
@ -73,25 +73,30 @@ void TopWindow::CenterRect(Ctrl *owner)
|
|||
SetupRect(owner);
|
||||
if(owner && center == 1 || center == 2) {
|
||||
Size sz = GetRect().Size();
|
||||
Rect r, wr;
|
||||
wr = Ctrl::GetPrimaryWorkArea();
|
||||
Rect wr = owner? owner->GetWorkArea() : Ctrl::GetPrimaryWorkArea();
|
||||
Rect fm = GetFrameMargins();
|
||||
if(center == 1)
|
||||
r = owner->GetRect();
|
||||
else
|
||||
r = wr;
|
||||
Point p = r.CenterPos(sz);
|
||||
r = RectC(p.x, p.y, sz.cx, sz.cy);
|
||||
Rect r = (center == 1 && owner ? owner->GetRect() : wr)
|
||||
.CenterRect(sz);
|
||||
wr.left += fm.left;
|
||||
wr.right -= fm.right;
|
||||
wr.top += fm.top;
|
||||
wr.bottom -= fm.bottom;
|
||||
if(r.top < wr.top) {
|
||||
r.bottom += wr.top - r.top;
|
||||
r.top = wr.top;
|
||||
r.bottom = r.top + sz.cy;
|
||||
}
|
||||
if(r.bottom > wr.bottom)
|
||||
if(r.left < wr.left) {
|
||||
r.left = wr.left;
|
||||
r.right = r.left + sz.cx;
|
||||
}
|
||||
if(r.bottom > wr.bottom) {
|
||||
r.bottom = wr.bottom;
|
||||
r.top = r.bottom - sz.cy;
|
||||
}
|
||||
if(r.right > wr.right) {
|
||||
r.right = wr.right;
|
||||
r.left = r.right - sz.cx;
|
||||
}
|
||||
minsize.cx = min(minsize.cx, r.GetWidth());
|
||||
minsize.cy = min(minsize.cy, r.GetHeight());
|
||||
SetRect(r);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue