aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llresizebar.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llui/llresizebar.cpp
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/llui/llresizebar.cpp')
-rw-r--r--linden/indra/llui/llresizebar.cpp86
1 files changed, 37 insertions, 49 deletions
diff --git a/linden/indra/llui/llresizebar.cpp b/linden/indra/llui/llresizebar.cpp
index 79127a8..f716e8e 100644
--- a/linden/indra/llui/llresizebar.cpp
+++ b/linden/indra/llui/llresizebar.cpp
@@ -38,16 +38,18 @@
38#include "llfocusmgr.h" 38#include "llfocusmgr.h"
39#include "llwindow.h" 39#include "llwindow.h"
40 40
41LLResizeBar::LLResizeBar( const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, Side side ) 41LLResizeBar::LLResizeBar( const LLString& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side )
42 : 42 :
43 LLView( name, rect, TRUE ), 43 LLView( name, rect, TRUE ),
44 mDragLastScreenX( 0 ), 44 mDragLastScreenX( 0 ),
45 mDragLastScreenY( 0 ), 45 mDragLastScreenY( 0 ),
46 mLastMouseScreenX( 0 ), 46 mLastMouseScreenX( 0 ),
47 mLastMouseScreenY( 0 ), 47 mLastMouseScreenY( 0 ),
48 mMinWidth( min_width ), 48 mMinSize( min_size ),
49 mMinHeight( min_height ), 49 mMaxSize( max_size ),
50 mSide( side ) 50 mSide( side ),
51 mSnappingEnabled(TRUE),
52 mResizingView(resizing_view)
51{ 53{
52 // set up some generically good follow code. 54 // set up some generically good follow code.
53 switch( side ) 55 switch( side )
@@ -149,12 +151,11 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
149 // Make sure the mouse in still over the application. We don't want to make the parent 151 // Make sure the mouse in still over the application. We don't want to make the parent
150 // so big that we can't see the resize handle any more. 152 // so big that we can't see the resize handle any more.
151 LLRect valid_rect = getRootView()->getRect(); 153 LLRect valid_rect = getRootView()->getRect();
152 LLView* resizing_view = getParent();
153 154
154 if( valid_rect.localPointInRect( screen_x, screen_y ) && resizing_view ) 155 if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView )
155 { 156 {
156 // Resize the parent 157 // Resize the parent
157 LLRect orig_rect = resizing_view->getRect(); 158 LLRect orig_rect = mResizingView->getRect();
158 LLRect scaled_rect = orig_rect; 159 LLRect scaled_rect = orig_rect;
159 160
160 S32 new_width = orig_rect.getWidth(); 161 S32 new_width = orig_rect.getWidth();
@@ -163,76 +164,63 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
163 switch( mSide ) 164 switch( mSide )
164 { 165 {
165 case LEFT: 166 case LEFT:
166 new_width = orig_rect.getWidth() - delta_x; 167 new_width = llclamp(orig_rect.getWidth() - delta_x, mMinSize, mMaxSize);
167 if( new_width < mMinWidth ) 168 delta_x = orig_rect.getWidth() - new_width;
168 {
169 new_width = mMinWidth;
170 delta_x = orig_rect.getWidth() - mMinWidth;
171 }
172 scaled_rect.translate(delta_x, 0); 169 scaled_rect.translate(delta_x, 0);
173 break; 170 break;
174 171
175 case TOP: 172 case TOP:
176 new_height = orig_rect.getHeight() + delta_y; 173 new_height = llclamp(orig_rect.getHeight() + delta_y, mMinSize, mMaxSize);
177 if( new_height < mMinHeight ) 174 delta_y = new_height - orig_rect.getHeight();
178 {
179 new_height = mMinHeight;
180 delta_y = mMinHeight - orig_rect.getHeight();
181 }
182 break; 175 break;
183 176
184 case RIGHT: 177 case RIGHT:
185 new_width = orig_rect.getWidth() + delta_x; 178 new_width = llclamp(orig_rect.getWidth() + delta_x, mMinSize, mMaxSize);
186 if( new_width < mMinWidth ) 179 delta_x = new_width - orig_rect.getWidth();
187 {
188 new_width = mMinWidth;
189 delta_x = mMinWidth - orig_rect.getWidth();
190 }
191 break; 180 break;
192 181
193 case BOTTOM: 182 case BOTTOM:
194 new_height = orig_rect.getHeight() - delta_y; 183 new_height = llclamp(orig_rect.getHeight() - delta_y, mMinSize, mMaxSize);
195 if( new_height < mMinHeight ) 184 delta_y = orig_rect.getHeight() - new_height;
196 {
197 new_height = mMinHeight;
198 delta_y = orig_rect.getHeight() - mMinHeight;
199 }
200 scaled_rect.translate(0, delta_y); 185 scaled_rect.translate(0, delta_y);
201 break; 186 break;
202 } 187 }
203 188
204 scaled_rect.mTop = scaled_rect.mBottom + new_height; 189 scaled_rect.mTop = scaled_rect.mBottom + new_height;
205 scaled_rect.mRight = scaled_rect.mLeft + new_width; 190 scaled_rect.mRight = scaled_rect.mLeft + new_width;
206 resizing_view->setRect(scaled_rect); 191 mResizingView->setRect(scaled_rect);
207 192
208 LLView* snap_view = NULL; 193 LLView* snap_view = NULL;
209 194
210 switch( mSide ) 195 if (mSnappingEnabled)
211 { 196 {
212 case LEFT: 197 switch( mSide )
213 snap_view = resizing_view->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); 198 {
214 break; 199 case LEFT:
215 case TOP: 200 snap_view = mResizingView->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
216 snap_view = resizing_view->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); 201 break;
217 break; 202 case TOP:
218 case RIGHT: 203 snap_view = mResizingView->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
219 snap_view = resizing_view->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); 204 break;
220 break; 205 case RIGHT:
221 case BOTTOM: 206 snap_view = mResizingView->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
222 snap_view = resizing_view->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin")); 207 break;
223 break; 208 case BOTTOM:
209 snap_view = mResizingView->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, LLUI::sConfigGroup->getS32("SnapMargin"));
210 break;
211 }
224 } 212 }
225 213
226 // register "snap" behavior with snapped view 214 // register "snap" behavior with snapped view
227 resizing_view->snappedTo(snap_view); 215 mResizingView->snappedTo(snap_view);
228 216
229 // restore original rectangle so the appropriate changes are detected 217 // restore original rectangle so the appropriate changes are detected
230 resizing_view->setRect(orig_rect); 218 mResizingView->setRect(orig_rect);
231 // change view shape as user operation 219 // change view shape as user operation
232 resizing_view->userSetShape(scaled_rect); 220 mResizingView->userSetShape(scaled_rect);
233 221
234 // update last valid mouse cursor position based on resized view's actual size 222 // update last valid mouse cursor position based on resized view's actual size
235 LLRect new_rect = resizing_view->getRect(); 223 LLRect new_rect = mResizingView->getRect();
236 switch(mSide) 224 switch(mSide)
237 { 225 {
238 case LEFT: 226 case LEFT: