summaryrefslogtreecommitdiff
path: root/indra/llui/llresizebar.cpp
diff options
context:
space:
mode:
authorAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
committerAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
commit1b67dd855c41f5a0cda7ec2a68d98071986ca703 (patch)
treeab243607f74f78200787bba5b9b88f07ef1b966f /indra/llui/llresizebar.cpp
parent6d6eabca44d08d5b97bfe3e941d2b9687c2246ea (diff)
parente1623bb276f83a43ce7a197e388720c05bdefe61 (diff)
Merge remote-tracking branch 'origin/main' into DRTVWR-600-maint-A
# Conflicts: # autobuild.xml # indra/cmake/CMakeLists.txt # indra/cmake/GoogleMock.cmake # indra/llaudio/llaudioengine_fmodstudio.cpp # indra/llaudio/llaudioengine_fmodstudio.h # indra/llaudio/lllistener_fmodstudio.cpp # indra/llaudio/lllistener_fmodstudio.h # indra/llaudio/llstreamingaudio_fmodstudio.cpp # indra/llaudio/llstreamingaudio_fmodstudio.h # indra/llcharacter/llmultigesture.cpp # indra/llcharacter/llmultigesture.h # indra/llimage/llimage.cpp # indra/llimage/llimagepng.cpp # indra/llimage/llimageworker.cpp # indra/llimage/tests/llimageworker_test.cpp # indra/llmessage/tests/llmockhttpclient.h # indra/llprimitive/llgltfmaterial.h # indra/llrender/llfontfreetype.cpp # indra/llui/llcombobox.cpp # indra/llui/llfolderview.cpp # indra/llui/llfolderviewmodel.h # indra/llui/lllineeditor.cpp # indra/llui/lllineeditor.h # indra/llui/lltextbase.cpp # indra/llui/lltextbase.h # indra/llui/lltexteditor.cpp # indra/llui/lltextvalidate.cpp # indra/llui/lltextvalidate.h # indra/llui/lluictrl.h # indra/llui/llview.cpp # indra/llwindow/llwindowmacosx.cpp # indra/newview/app_settings/settings.xml # indra/newview/llappearancemgr.cpp # indra/newview/llappearancemgr.h # indra/newview/llavatarpropertiesprocessor.cpp # indra/newview/llavatarpropertiesprocessor.h # indra/newview/llbreadcrumbview.cpp # indra/newview/llbreadcrumbview.h # indra/newview/llbreastmotion.cpp # indra/newview/llbreastmotion.h # indra/newview/llconversationmodel.h # indra/newview/lldensityctrl.cpp # indra/newview/lldensityctrl.h # indra/newview/llface.inl # indra/newview/llfloatereditsky.cpp # indra/newview/llfloatereditwater.cpp # indra/newview/llfloateremojipicker.h # indra/newview/llfloaterimsessiontab.cpp # indra/newview/llfloaterprofiletexture.cpp # indra/newview/llfloaterprofiletexture.h # indra/newview/llgesturemgr.cpp # indra/newview/llgesturemgr.h # indra/newview/llimpanel.cpp # indra/newview/llimpanel.h # indra/newview/llinventorybridge.cpp # indra/newview/llinventorybridge.h # indra/newview/llinventoryclipboard.cpp # indra/newview/llinventoryclipboard.h # indra/newview/llinventoryfunctions.cpp # indra/newview/llinventoryfunctions.h # indra/newview/llinventorygallery.cpp # indra/newview/lllistbrowser.cpp # indra/newview/lllistbrowser.h # indra/newview/llpanelobjectinventory.cpp # indra/newview/llpanelprofile.cpp # indra/newview/llpanelprofile.h # indra/newview/llpreviewgesture.cpp # indra/newview/llsavedsettingsglue.cpp # indra/newview/llsavedsettingsglue.h # indra/newview/lltooldraganddrop.cpp # indra/newview/llurllineeditorctrl.cpp # indra/newview/llvectorperfoptions.cpp # indra/newview/llvectorperfoptions.h # indra/newview/llviewerparceloverlay.cpp # indra/newview/llviewertexlayer.cpp # indra/newview/llviewertexturelist.cpp # indra/newview/macmain.h # indra/test/test.cpp
Diffstat (limited to 'indra/llui/llresizebar.cpp')
-rw-r--r--indra/llui/llresizebar.cpp752
1 files changed, 376 insertions, 376 deletions
diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp
index c05a7dddf7..85d886a3ed 100644
--- a/indra/llui/llresizebar.cpp
+++ b/indra/llui/llresizebar.cpp
@@ -1,376 +1,376 @@
-/**
- * @file llresizebar.cpp
- * @brief LLResizeBar base class
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llresizebar.h"
-
-#include "lllocalcliprect.h"
-#include "llmath.h"
-#include "llui.h"
-#include "llmenugl.h"
-#include "llfocusmgr.h"
-#include "llwindow.h"
-
-LLResizeBar::Params::Params()
-: max_size("max_size", S32_MAX),
- snapping_enabled("snapping_enabled", true),
- resizing_view("resizing_view"),
- side("side"),
- allow_double_click_snapping("allow_double_click_snapping", true)
-{
- name = "resize_bar";
-}
-
-LLResizeBar::LLResizeBar(const LLResizeBar::Params& p)
-: LLView(p),
- mDragLastScreenX( 0 ),
- mDragLastScreenY( 0 ),
- mLastMouseScreenX( 0 ),
- mLastMouseScreenY( 0 ),
- mMinSize( p.min_size ),
- mMaxSize( p.max_size ),
- mSide( p.side ),
- mSnappingEnabled(p.snapping_enabled),
- mAllowDoubleClickSnapping(p.allow_double_click_snapping),
- mResizingView(p.resizing_view),
- mResizeListener(NULL),
- mImagePanel(NULL)
-{
- setFollowsNone();
- // set up some generically good follow code.
- switch( mSide )
- {
- case LEFT:
- setFollowsLeft();
- setFollowsTop();
- setFollowsBottom();
- break;
- case TOP:
- setFollowsTop();
- setFollowsLeft();
- setFollowsRight();
- break;
- case RIGHT:
- setFollowsRight();
- setFollowsTop();
- setFollowsBottom();
- break;
- case BOTTOM:
- setFollowsBottom();
- setFollowsLeft();
- setFollowsRight();
- break;
- default:
- break;
- }
-}
-
-bool LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask)
-{
- if (!canResize()) return false;
-
- // Route future Mouse messages here preemptively. (Release on mouse up.)
- // No handler needed for focus lost since this clas has no state that depends on it.
- gFocusMgr.setMouseCapture( this );
-
- localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
- mLastMouseScreenX = mDragLastScreenX;
- mLastMouseScreenY = mDragLastScreenY;
-
- return true;
-}
-
-
-bool LLResizeBar::handleMouseUp(S32 x, S32 y, MASK mask)
-{
- bool handled = false;
-
- if( hasMouseCapture() )
- {
- // Release the mouse
- gFocusMgr.setMouseCapture( NULL );
- handled = true;
- }
- else
- {
- handled = true;
- }
- return handled;
-}
-
-
-bool LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
-{
- bool handled = false;
-
- // We only handle the click if the click both started and ended within us
- if( hasMouseCapture() )
- {
- S32 screen_x;
- S32 screen_y;
- localPointToScreen(x, y, &screen_x, &screen_y);
-
- S32 delta_x = screen_x - mDragLastScreenX;
- S32 delta_y = screen_y - mDragLastScreenY;
-
- LLCoordGL mouse_dir;
- // use hysteresis on mouse motion to preserve user intent when mouse stops moving
- mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX;
- mouse_dir.mY = (screen_y == mLastMouseScreenY) ? mLastMouseDir.mY : screen_y - mLastMouseScreenY;
- mLastMouseDir = mouse_dir;
- mLastMouseScreenX = screen_x;
- mLastMouseScreenY = screen_y;
-
- // Make sure the mouse in still over the application. We don't want to make the parent
- // so big that we can't see the resize handle any more.
- LLRect valid_rect = getRootView()->getRect();
-
- if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView )
- {
- // Resize the parent
- LLRect orig_rect = mResizingView->getRect();
- LLRect scaled_rect = orig_rect;
-
- S32 new_width = orig_rect.getWidth();
- S32 new_height = orig_rect.getHeight();
-
- switch( mSide )
- {
- case LEFT:
- new_width = llclamp(orig_rect.getWidth() - delta_x, mMinSize, mMaxSize);
- delta_x = orig_rect.getWidth() - new_width;
- scaled_rect.translate(delta_x, 0);
- break;
-
- case TOP:
- new_height = llclamp(orig_rect.getHeight() + delta_y, mMinSize, mMaxSize);
- delta_y = new_height - orig_rect.getHeight();
- break;
-
- case RIGHT:
- new_width = llclamp(orig_rect.getWidth() + delta_x, mMinSize, mMaxSize);
- delta_x = new_width - orig_rect.getWidth();
- break;
-
- case BOTTOM:
- new_height = llclamp(orig_rect.getHeight() - delta_y, mMinSize, mMaxSize);
- delta_y = orig_rect.getHeight() - new_height;
- scaled_rect.translate(0, delta_y);
- break;
- }
-
- notifyParent(LLSD().with("action", "resize")
- .with("view_name", mResizingView->getName())
- .with("new_height", new_height)
- .with("new_width", new_width));
-
- scaled_rect.mTop = scaled_rect.mBottom + new_height;
- scaled_rect.mRight = scaled_rect.mLeft + new_width;
- mResizingView->setRect(scaled_rect);
-
- LLView* snap_view = NULL;
-
- if (mSnappingEnabled)
- {
- static LLUICachedControl<S32> snap_margin ("SnapMargin", 0);
- switch( mSide )
- {
- case LEFT:
- snap_view = mResizingView->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, snap_margin);
- break;
- case TOP:
- snap_view = mResizingView->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, snap_margin);
- break;
- case RIGHT:
- snap_view = mResizingView->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, snap_margin);
- break;
- case BOTTOM:
- snap_view = mResizingView->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, snap_margin);
- break;
- }
- }
-
- // register "snap" behavior with snapped view
- mResizingView->setSnappedTo(snap_view);
-
- // restore original rectangle so the appropriate changes are detected
- mResizingView->setRect(orig_rect);
- // change view shape as user operation
- mResizingView->setShape(scaled_rect, true);
-
- // update last valid mouse cursor position based on resized view's actual size
- LLRect new_rect = mResizingView->getRect();
-
- switch(mSide)
- {
- case LEFT:
- {
- S32 actual_delta_x = new_rect.mLeft - orig_rect.mLeft;
- if (actual_delta_x != delta_x)
- {
- // restore everything by left
- new_rect.mBottom = orig_rect.mBottom;
- new_rect.mTop = orig_rect.mTop;
- new_rect.mRight = orig_rect.mRight;
- mResizingView->setShape(new_rect, true);
- }
- mDragLastScreenX += actual_delta_x;
-
- break;
- }
- case RIGHT:
- {
- S32 actual_delta_x = new_rect.mRight - orig_rect.mRight;
- if (actual_delta_x != delta_x)
- {
- // restore everything by left
- new_rect.mBottom = orig_rect.mBottom;
- new_rect.mTop = orig_rect.mTop;
- new_rect.mLeft = orig_rect.mLeft;
- mResizingView->setShape(new_rect, true);
- }
- mDragLastScreenX += new_rect.mRight - orig_rect.mRight;
- break;
- }
- case TOP:
- {
- S32 actual_delta_y = new_rect.mTop - orig_rect.mTop;
- if (actual_delta_y != delta_y)
- {
- // restore everything by left
- new_rect.mBottom = orig_rect.mBottom;
- new_rect.mLeft = orig_rect.mLeft;
- new_rect.mRight = orig_rect.mRight;
- mResizingView->setShape(new_rect, true);
- }
- mDragLastScreenY += new_rect.mTop - orig_rect.mTop;
- break;
- }
- case BOTTOM:
- {
- S32 actual_delta_y = new_rect.mBottom - orig_rect.mBottom;
- if (actual_delta_y != delta_y)
- {
- // restore everything by left
- new_rect.mTop = orig_rect.mTop;
- new_rect.mLeft = orig_rect.mLeft;
- new_rect.mRight = orig_rect.mRight;
- mResizingView->setShape(new_rect, true);
- }
- mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom;
- break;
- }
- default:
- break;
- }
- }
-
- handled = true;
- }
- else
- {
- handled = true;
- }
-
- if( handled && canResize() )
- {
- switch( mSide )
- {
- case LEFT:
- case RIGHT:
- getWindow()->setCursor(UI_CURSOR_SIZEWE);
- break;
-
- case TOP:
- case BOTTOM:
- getWindow()->setCursor(UI_CURSOR_SIZENS);
- break;
- }
- }
-
- if (mResizeListener)
- {
- mResizeListener(NULL);
- }
-
- return handled;
-} // end LLResizeBar::handleHover
-
-bool LLResizeBar::handleDoubleClick(S32 x, S32 y, MASK mask)
-{
- LLRect orig_rect = mResizingView->getRect();
- LLRect scaled_rect = orig_rect;
-
- if (mSnappingEnabled && mAllowDoubleClickSnapping)
- {
- switch( mSide )
- {
- case LEFT:
- mResizingView->findSnapEdge(scaled_rect.mLeft, LLCoordGL(0, 0), SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
- scaled_rect.mLeft = scaled_rect.mRight - llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize);
- break;
- case TOP:
- mResizingView->findSnapEdge(scaled_rect.mTop, LLCoordGL(0, 0), SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
- scaled_rect.mTop = scaled_rect.mBottom + llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize);
- break;
- case RIGHT:
- mResizingView->findSnapEdge(scaled_rect.mRight, LLCoordGL(0, 0), SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
- scaled_rect.mRight = scaled_rect.mLeft + llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize);
- break;
- case BOTTOM:
- mResizingView->findSnapEdge(scaled_rect.mBottom, LLCoordGL(0, 0), SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
- scaled_rect.mBottom = scaled_rect.mTop - llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize);
- break;
- }
-
- mResizingView->setShape(scaled_rect, true);
- }
-
- return true;
-}
-
-void LLResizeBar::setImagePanel(LLPanel * panelp)
-{
- const LLView::child_list_t * children = getChildList();
- if (getChildCount() == 2)
- {
- LLPanel * image_panelp = dynamic_cast<LLPanel*>(children->back());
- if (image_panelp)
- {
- removeChild(image_panelp);
- delete image_panelp;
- }
- }
-
- addChild(panelp);
- sendChildToBack(panelp);
-}
-
-LLPanel * LLResizeBar::getImagePanel() const
-{
- return getChildCount() > 0 ? (LLPanel *)getChildList()->back() : NULL;
-}
+/**
+ * @file llresizebar.cpp
+ * @brief LLResizeBar base class
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+#include "llresizebar.h"
+
+#include "lllocalcliprect.h"
+#include "llmath.h"
+#include "llui.h"
+#include "llmenugl.h"
+#include "llfocusmgr.h"
+#include "llwindow.h"
+
+LLResizeBar::Params::Params()
+: max_size("max_size", S32_MAX),
+ snapping_enabled("snapping_enabled", true),
+ resizing_view("resizing_view"),
+ side("side"),
+ allow_double_click_snapping("allow_double_click_snapping", true)
+{
+ name = "resize_bar";
+}
+
+LLResizeBar::LLResizeBar(const LLResizeBar::Params& p)
+: LLView(p),
+ mDragLastScreenX( 0 ),
+ mDragLastScreenY( 0 ),
+ mLastMouseScreenX( 0 ),
+ mLastMouseScreenY( 0 ),
+ mMinSize( p.min_size ),
+ mMaxSize( p.max_size ),
+ mSide( p.side ),
+ mSnappingEnabled(p.snapping_enabled),
+ mAllowDoubleClickSnapping(p.allow_double_click_snapping),
+ mResizingView(p.resizing_view),
+ mResizeListener(NULL),
+ mImagePanel(NULL)
+{
+ setFollowsNone();
+ // set up some generically good follow code.
+ switch( mSide )
+ {
+ case LEFT:
+ setFollowsLeft();
+ setFollowsTop();
+ setFollowsBottom();
+ break;
+ case TOP:
+ setFollowsTop();
+ setFollowsLeft();
+ setFollowsRight();
+ break;
+ case RIGHT:
+ setFollowsRight();
+ setFollowsTop();
+ setFollowsBottom();
+ break;
+ case BOTTOM:
+ setFollowsBottom();
+ setFollowsLeft();
+ setFollowsRight();
+ break;
+ default:
+ break;
+ }
+}
+
+bool LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+ if (!canResize()) return false;
+
+ // Route future Mouse messages here preemptively. (Release on mouse up.)
+ // No handler needed for focus lost since this clas has no state that depends on it.
+ gFocusMgr.setMouseCapture( this );
+
+ localPointToScreen(x, y, &mDragLastScreenX, &mDragLastScreenY);
+ mLastMouseScreenX = mDragLastScreenX;
+ mLastMouseScreenY = mDragLastScreenY;
+
+ return true;
+}
+
+
+bool LLResizeBar::handleMouseUp(S32 x, S32 y, MASK mask)
+{
+ bool handled = false;
+
+ if( hasMouseCapture() )
+ {
+ // Release the mouse
+ gFocusMgr.setMouseCapture( NULL );
+ handled = true;
+ }
+ else
+ {
+ handled = true;
+ }
+ return handled;
+}
+
+
+bool LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
+{
+ bool handled = false;
+
+ // We only handle the click if the click both started and ended within us
+ if( hasMouseCapture() )
+ {
+ S32 screen_x;
+ S32 screen_y;
+ localPointToScreen(x, y, &screen_x, &screen_y);
+
+ S32 delta_x = screen_x - mDragLastScreenX;
+ S32 delta_y = screen_y - mDragLastScreenY;
+
+ LLCoordGL mouse_dir;
+ // use hysteresis on mouse motion to preserve user intent when mouse stops moving
+ mouse_dir.mX = (screen_x == mLastMouseScreenX) ? mLastMouseDir.mX : screen_x - mLastMouseScreenX;
+ mouse_dir.mY = (screen_y == mLastMouseScreenY) ? mLastMouseDir.mY : screen_y - mLastMouseScreenY;
+ mLastMouseDir = mouse_dir;
+ mLastMouseScreenX = screen_x;
+ mLastMouseScreenY = screen_y;
+
+ // Make sure the mouse in still over the application. We don't want to make the parent
+ // so big that we can't see the resize handle any more.
+ LLRect valid_rect = getRootView()->getRect();
+
+ if( valid_rect.localPointInRect( screen_x, screen_y ) && mResizingView )
+ {
+ // Resize the parent
+ LLRect orig_rect = mResizingView->getRect();
+ LLRect scaled_rect = orig_rect;
+
+ S32 new_width = orig_rect.getWidth();
+ S32 new_height = orig_rect.getHeight();
+
+ switch( mSide )
+ {
+ case LEFT:
+ new_width = llclamp(orig_rect.getWidth() - delta_x, mMinSize, mMaxSize);
+ delta_x = orig_rect.getWidth() - new_width;
+ scaled_rect.translate(delta_x, 0);
+ break;
+
+ case TOP:
+ new_height = llclamp(orig_rect.getHeight() + delta_y, mMinSize, mMaxSize);
+ delta_y = new_height - orig_rect.getHeight();
+ break;
+
+ case RIGHT:
+ new_width = llclamp(orig_rect.getWidth() + delta_x, mMinSize, mMaxSize);
+ delta_x = new_width - orig_rect.getWidth();
+ break;
+
+ case BOTTOM:
+ new_height = llclamp(orig_rect.getHeight() - delta_y, mMinSize, mMaxSize);
+ delta_y = orig_rect.getHeight() - new_height;
+ scaled_rect.translate(0, delta_y);
+ break;
+ }
+
+ notifyParent(LLSD().with("action", "resize")
+ .with("view_name", mResizingView->getName())
+ .with("new_height", new_height)
+ .with("new_width", new_width));
+
+ scaled_rect.mTop = scaled_rect.mBottom + new_height;
+ scaled_rect.mRight = scaled_rect.mLeft + new_width;
+ mResizingView->setRect(scaled_rect);
+
+ LLView* snap_view = NULL;
+
+ if (mSnappingEnabled)
+ {
+ static LLUICachedControl<S32> snap_margin ("SnapMargin", 0);
+ switch( mSide )
+ {
+ case LEFT:
+ snap_view = mResizingView->findSnapEdge(scaled_rect.mLeft, mouse_dir, SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, snap_margin);
+ break;
+ case TOP:
+ snap_view = mResizingView->findSnapEdge(scaled_rect.mTop, mouse_dir, SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, snap_margin);
+ break;
+ case RIGHT:
+ snap_view = mResizingView->findSnapEdge(scaled_rect.mRight, mouse_dir, SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, snap_margin);
+ break;
+ case BOTTOM:
+ snap_view = mResizingView->findSnapEdge(scaled_rect.mBottom, mouse_dir, SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, snap_margin);
+ break;
+ }
+ }
+
+ // register "snap" behavior with snapped view
+ mResizingView->setSnappedTo(snap_view);
+
+ // restore original rectangle so the appropriate changes are detected
+ mResizingView->setRect(orig_rect);
+ // change view shape as user operation
+ mResizingView->setShape(scaled_rect, true);
+
+ // update last valid mouse cursor position based on resized view's actual size
+ LLRect new_rect = mResizingView->getRect();
+
+ switch(mSide)
+ {
+ case LEFT:
+ {
+ S32 actual_delta_x = new_rect.mLeft - orig_rect.mLeft;
+ if (actual_delta_x != delta_x)
+ {
+ // restore everything by left
+ new_rect.mBottom = orig_rect.mBottom;
+ new_rect.mTop = orig_rect.mTop;
+ new_rect.mRight = orig_rect.mRight;
+ mResizingView->setShape(new_rect, true);
+ }
+ mDragLastScreenX += actual_delta_x;
+
+ break;
+ }
+ case RIGHT:
+ {
+ S32 actual_delta_x = new_rect.mRight - orig_rect.mRight;
+ if (actual_delta_x != delta_x)
+ {
+ // restore everything by left
+ new_rect.mBottom = orig_rect.mBottom;
+ new_rect.mTop = orig_rect.mTop;
+ new_rect.mLeft = orig_rect.mLeft;
+ mResizingView->setShape(new_rect, true);
+ }
+ mDragLastScreenX += new_rect.mRight - orig_rect.mRight;
+ break;
+ }
+ case TOP:
+ {
+ S32 actual_delta_y = new_rect.mTop - orig_rect.mTop;
+ if (actual_delta_y != delta_y)
+ {
+ // restore everything by left
+ new_rect.mBottom = orig_rect.mBottom;
+ new_rect.mLeft = orig_rect.mLeft;
+ new_rect.mRight = orig_rect.mRight;
+ mResizingView->setShape(new_rect, true);
+ }
+ mDragLastScreenY += new_rect.mTop - orig_rect.mTop;
+ break;
+ }
+ case BOTTOM:
+ {
+ S32 actual_delta_y = new_rect.mBottom - orig_rect.mBottom;
+ if (actual_delta_y != delta_y)
+ {
+ // restore everything by left
+ new_rect.mTop = orig_rect.mTop;
+ new_rect.mLeft = orig_rect.mLeft;
+ new_rect.mRight = orig_rect.mRight;
+ mResizingView->setShape(new_rect, true);
+ }
+ mDragLastScreenY += new_rect.mBottom- orig_rect.mBottom;
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ handled = true;
+ }
+ else
+ {
+ handled = true;
+ }
+
+ if( handled && canResize() )
+ {
+ switch( mSide )
+ {
+ case LEFT:
+ case RIGHT:
+ getWindow()->setCursor(UI_CURSOR_SIZEWE);
+ break;
+
+ case TOP:
+ case BOTTOM:
+ getWindow()->setCursor(UI_CURSOR_SIZENS);
+ break;
+ }
+ }
+
+ if (mResizeListener)
+ {
+ mResizeListener(NULL);
+ }
+
+ return handled;
+} // end LLResizeBar::handleHover
+
+bool LLResizeBar::handleDoubleClick(S32 x, S32 y, MASK mask)
+{
+ LLRect orig_rect = mResizingView->getRect();
+ LLRect scaled_rect = orig_rect;
+
+ if (mSnappingEnabled && mAllowDoubleClickSnapping)
+ {
+ switch( mSide )
+ {
+ case LEFT:
+ mResizingView->findSnapEdge(scaled_rect.mLeft, LLCoordGL(0, 0), SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
+ scaled_rect.mLeft = scaled_rect.mRight - llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize);
+ break;
+ case TOP:
+ mResizingView->findSnapEdge(scaled_rect.mTop, LLCoordGL(0, 0), SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
+ scaled_rect.mTop = scaled_rect.mBottom + llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize);
+ break;
+ case RIGHT:
+ mResizingView->findSnapEdge(scaled_rect.mRight, LLCoordGL(0, 0), SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
+ scaled_rect.mRight = scaled_rect.mLeft + llclamp(scaled_rect.getWidth(), mMinSize, mMaxSize);
+ break;
+ case BOTTOM:
+ mResizingView->findSnapEdge(scaled_rect.mBottom, LLCoordGL(0, 0), SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, S32_MAX);
+ scaled_rect.mBottom = scaled_rect.mTop - llclamp(scaled_rect.getHeight(), mMinSize, mMaxSize);
+ break;
+ }
+
+ mResizingView->setShape(scaled_rect, true);
+ }
+
+ return true;
+}
+
+void LLResizeBar::setImagePanel(LLPanel * panelp)
+{
+ const LLView::child_list_t * children = getChildList();
+ if (getChildCount() == 2)
+ {
+ LLPanel * image_panelp = dynamic_cast<LLPanel*>(children->back());
+ if (image_panelp)
+ {
+ removeChild(image_panelp);
+ delete image_panelp;
+ }
+ }
+
+ addChild(panelp);
+ sendChildToBack(panelp);
+}
+
+LLPanel * LLResizeBar::getImagePanel() const
+{
+ return getChildCount() > 0 ? (LLPanel *)getChildList()->back() : NULL;
+}