From: <rds...@us...> - 2008-03-10 22:47:24
|
Revision: 1163 http://planeshift.svn.sourceforge.net/planeshift/?rev=1163&view=rev Author: rdschulz Date: 2008-03-10 15:47:14 -0700 (Mon, 10 Mar 2008) Log Message: ----------- - Fix for resizing of windows working weirdly when window was aspect locked by coreyo ... Thanks :) (FS#900) Modified Paths: -------------- trunk/docs/history.txt trunk/src/common/paws/pawsmanager.cpp trunk/src/common/paws/pawswidget.cpp trunk/src/common/paws/pawswidget.h Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2008-03-09 20:43:42 UTC (rev 1162) +++ trunk/docs/history.txt 2008-03-10 22:47:14 UTC (rev 1163) @@ -1,3 +1,7 @@ +*** 2008-03-10 by Roland Schulz +- Fix for resizing of windows working weirdly when window was aspect locked + by coreyo ... Thanks :) (FS#900) + *** 2008-03-09 by Mike Gist - A few pslaunch fixes. Modified: trunk/src/common/paws/pawsmanager.cpp =================================================================== --- trunk/src/common/paws/pawsmanager.cpp 2008-03-09 20:43:42 UTC (rev 1162) +++ trunk/src/common/paws/pawsmanager.cpp 2008-03-10 22:47:14 UTC (rev 1163) @@ -557,9 +557,7 @@ if ( resizingWidget ) { - resizingWidget->Resize( mouse->GetDeltas().x, - mouse->GetDeltas().y, - resizingFlags ); + resizingWidget->Resize( resizingFlags ); return true; } Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2008-03-09 20:43:42 UTC (rev 1162) +++ trunk/src/common/paws/pawswidget.cpp 2008-03-10 22:47:14 UTC (rev 1163) @@ -1839,6 +1839,71 @@ } } +void pawsWidget::Resize( int flags ) +{ + psPoint mousePos = PawsManager::GetSingleton().GetMouse()->GetPosition(); + csRect newFrame = screenFrame; + + float scale = 1.0f; + if(defaultFrame.Height() && defaultFrame.Width()) + { + scale = defaultFrame.Width() / defaultFrame.Height(); + } + + if(keepaspect && flags & RESIZE_RIGHT && flags & RESIZE_BOTTOM) + { + int deltaX = (mousePos.x - screenFrame.xmin); + int deltaY = (mousePos.y - screenFrame.ymin); + if ( deltaX < (deltaY * scale) ) + { + newFrame.ymax = mousePos.y; + newFrame.xmax = screenFrame.xmin + (int)(deltaY * scale); + } + else + { + newFrame.xmax = mousePos.x; + newFrame.ymax = screenFrame.ymin + (int)(deltaX / scale); + } + } + else + { + if(flags & RESIZE_RIGHT) + { + newFrame.xmax = mousePos.x; + } + if(flags & RESIZE_BOTTOM) + { + newFrame.ymax = mousePos.y; + } + } + + if ( flags & RESIZE_LEFT) + { + newFrame.xmin = mousePos.x; + } + if ( flags & RESIZE_TOP ) + { + newFrame.ymin = mousePos.y; + } + + /// prevent the widget from going below its min height and width + if (newFrame.xmax - newFrame.xmin < min_width) newFrame.xmax = newFrame.xmin + min_width; + if (newFrame.ymax - newFrame.ymin < min_height) newFrame.ymax = newFrame.ymin + min_height; + + /// prevent the widget from going beyond its max height and width + if (newFrame.xmax - newFrame.xmin > max_width) newFrame.xmax = max_width + newFrame.xmin; + if (newFrame.ymax - newFrame.ymin > max_height) newFrame.ymax = max_height + newFrame.ymin; + + screenFrame = newFrame; + + OnResize(); + + for ( size_t x = children.GetSize(); x-- > 0; ) + { + children[x]->Resize(); + } +} + void pawsWidget::Resize( int deltaX, int deltaY, int flags ) { csRect newFrame = screenFrame; Modified: trunk/src/common/paws/pawswidget.h =================================================================== --- trunk/src/common/paws/pawswidget.h 2008-03-09 20:43:42 UTC (rev 1162) +++ trunk/src/common/paws/pawswidget.h 2008-03-10 22:47:14 UTC (rev 1163) @@ -745,8 +745,14 @@ */ virtual void CenterToMouse(); + /** Resize a widget based on the current mouse position. + * This will recurse through all the children calling Resize() on each. + * @param flags The resize direction. + */ + virtual void Resize( int flags ); + /** Resize a widget by a delta amount. - * This will recurse through all the children calling MoveDelta on each. + * This will recurse through all the children calling Resize() on each. * @param dx Delta x * @param dy Delta y * @param flags The resize direction. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |