[commit] r2030 - trunk/GME/Gme
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Mon Aug 27 11:44:54 CDT 2012
Author: ksmyth
Date: Mon Aug 27 11:44:53 2012
New Revision: 2030
Log:
Use decorator preferred size directly; do not round down
Modified:
trunk/GME/Gme/GUIObject.cpp
Modified: trunk/GME/Gme/GUIObject.cpp
==============================================================================
--- trunk/GME/Gme/GUIObject.cpp Mon Aug 27 11:44:44 2012 (r2029)
+++ trunk/GME/Gme/GUIObject.cpp Mon Aug 27 11:44:53 2012 (r2030)
@@ -29,42 +29,17 @@
void SetLocation(CRect& location, CPoint pt)
{
- CSize size = location.Size();
- int cx = pt.x + size.cx / 2;
- int cy = pt.y + size.cy / 2;
- cx = (cx / GME_GRID_SIZE) * GME_GRID_SIZE;
- cy = (cy / GME_GRID_SIZE) * GME_GRID_SIZE;
- while((cx - (size.cx / 2)) <= 0)
- cx += GME_GRID_SIZE;
- while((cy - (size.cy / 2)) <= 0)
- cy += GME_GRID_SIZE;
- pt.x = cx - size.cx / 2;
- pt.y = cy - size.cy / 2;
- location.right += pt.x - location.left;
- location.left = pt.x;
- location.bottom += pt.y - location.top;
+ CSize s = location.Size();
location.top = pt.y;
+ location.left = pt.x;
+ SetSize(location, s);
}
void SetSize(CRect& location, CSize s)
{
- if((s.cx % 2) == 0)
- s.cx--;
- if((s.cy % 2) == 0)
- s.cy--;
-
- CPoint pt = location.CenterPoint();
- int cx = pt.x;
- int cy = pt.y;
- pt.x = (cx / GME_GRID_SIZE) * GME_GRID_SIZE;
- pt.y = (cy / GME_GRID_SIZE) * GME_GRID_SIZE;
- while((pt.x - (s.cx / 2)) <= 0)
- pt.x += GME_GRID_SIZE;
- while((pt.y - (s.cy / 2)) <= 0)
- pt.y += GME_GRID_SIZE;
- location.left = pt.x - s.cx / 2;
+ location.left = max(GME_GRID_SIZE, location.left / GME_GRID_SIZE * GME_GRID_SIZE);
+ location.top = max(GME_GRID_SIZE, location.top / GME_GRID_SIZE * GME_GRID_SIZE);
location.right = location.left + s.cx;
- location.top = pt.y - s.cy / 2;
location.bottom = location.top + s.cy;
}
@@ -1368,7 +1343,7 @@
aspect = parentAspect;
VERIFY(aspect >= 0);
VERIFY(guiAspects[aspect] != NULL);
- CRect loc = guiAspects[aspect]->GetLocation();
+ CRect loc = guiAspects[aspect]->GetLocation();
::SetSize(loc,s);
guiAspects[aspect]->SetLocation(loc);
if(IsReal() && doMga)
@@ -1848,10 +1823,9 @@
POSITION pos = modelList.GetHeadPosition();
while(pos) {
CGuiObject *model = modelList.GetNext(pos);
- CPoint point = model->GetCenter() + CPoint(right * GME_GRID_SIZE, down * GME_GRID_SIZE);
- ASSERT(point.x % GME_GRID_SIZE == 0);
- ASSERT(point.y % GME_GRID_SIZE == 0);
- model->SetCenter(point);
+ CRect loc = model->GetLocation();
+ loc.OffsetRect(CPoint(right * GME_GRID_SIZE, down * GME_GRID_SIZE));
+ model->SetLocation(loc);
ASSERT(modelGrid.IsAvailable(model));
modelGrid.Set(model);
}
More information about the gme-commit
mailing list