summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llnavigationbar.cpp81
-rw-r--r--indra/newview/llnavigationbar.h53
-rw-r--r--indra/newview/skins/default/xui/en/panel_navigation_bar.xml6
3 files changed, 132 insertions, 8 deletions
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index fdecda86e6..59708fcfb5 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -34,6 +34,8 @@
#include "llnavigationbar.h"
+#include "v2math.h"
+
#include "llregionhandle.h"
#include "llfloaterreg.h"
@@ -181,6 +183,77 @@ void LLTeleportHistoryMenuItem::onMouseLeave(S32 x, S32 y, MASK mask)
mArrowIcon->setVisible(FALSE);
}
+static LLDefaultChildRegistry::Register<LLPullButton> menu_button("pull_button");
+
+LLPullButton::LLPullButton(const LLPullButton::Params& params):
+ LLButton(params)
+ , mClickDraggingSignal(NULL)
+{
+ setDirectionFromName(params.direction);
+}
+boost::signals2::connection LLPullButton::setClickDraggingCallback( const commit_signal_t::slot_type& cb )
+{
+ if (!mClickDraggingSignal) mClickDraggingSignal = new commit_signal_t();
+ return mClickDraggingSignal->connect(cb);
+}
+
+/*virtual*/
+void LLPullButton::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+ LLButton::onMouseLeave(x, y, mask);
+
+ if(mMouseDownTimer.getStarted() )
+ {
+ const LLVector2 cursor_direction = LLVector2(F32(x),F32(y)) - mLastMouseDown;
+ if( angle_between(mDraggingDirection, cursor_direction) < 0.5 * F_PI_BY_TWO)//call if angle < pi/4
+ {
+ if(mClickDraggingSignal)
+ {
+ (*mClickDraggingSignal)(this, LLSD());
+ }
+ }
+ }
+
+}
+
+/*virtual*/
+BOOL LLPullButton::handleMouseDown(S32 x, S32 y, MASK mask)
+ {
+ BOOL handled = LLButton::handleMouseDown(x,y, mask);
+ if(handled)
+ {
+ mLastMouseDown.set(F32(x), F32(y));
+ }
+ return handled;
+}
+
+/*virtual*/
+BOOL LLPullButton::handleMouseUp(S32 x, S32 y, MASK mask)
+{
+ mLastMouseDown.clear();
+ return LLButton::handleMouseUp(x, y, mask);
+}
+
+void LLPullButton::setDirectionFromName(const std::string& name)
+{
+ if (name == "left")
+ {
+ mDraggingDirection.set(F32(-1), F32(0));
+ }
+ else if (name == "right")
+ {
+ mDraggingDirection.set(F32(0), F32(1));
+ }
+ else if (name == "down")
+ {
+ mDraggingDirection.set(F32(0), F32(-1));
+ }
+ else if (name == "up")
+ {
+ mDraggingDirection.set(F32(0), F32(1));
+ }
+}
+
//-- LNavigationBar ----------------------------------------------------------
/*
@@ -215,8 +288,8 @@ LLNavigationBar::~LLNavigationBar()
BOOL LLNavigationBar::postBuild()
{
- mBtnBack = getChild<LLButton>("back_btn");
- mBtnForward = getChild<LLButton>("forward_btn");
+ mBtnBack = getChild<LLPullButton>("back_btn");
+ mBtnForward = getChild<LLPullButton>("forward_btn");
mBtnHome = getChild<LLButton>("home_btn");
mCmbLocation= getChild<LLLocationInputCtrl>("location_combo");
@@ -227,10 +300,12 @@ BOOL LLNavigationBar::postBuild()
mBtnBack->setEnabled(FALSE);
mBtnBack->setClickedCallback(boost::bind(&LLNavigationBar::onBackButtonClicked, this));
mBtnBack->setHeldDownCallback(boost::bind(&LLNavigationBar::onBackOrForwardButtonHeldDown, this,_1, _2));
-
+ mBtnBack->setClickDraggingCallback(boost::bind(&LLNavigationBar::showTeleportHistoryMenu, this,_1));
+
mBtnForward->setEnabled(FALSE);
mBtnForward->setClickedCallback(boost::bind(&LLNavigationBar::onForwardButtonClicked, this));
mBtnForward->setHeldDownCallback(boost::bind(&LLNavigationBar::onBackOrForwardButtonHeldDown, this, _1, _2));
+ mBtnForward->setClickDraggingCallback(boost::bind(&LLNavigationBar::showTeleportHistoryMenu, this,_1));
mBtnHome->setClickedCallback(boost::bind(&LLNavigationBar::onHomeButtonClicked, this));
diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h
index 55bbfa164a..9d0abc7a3a 100644
--- a/indra/newview/llnavigationbar.h
+++ b/indra/newview/llnavigationbar.h
@@ -34,14 +34,61 @@
#define LL_LLNAVIGATIONBAR_H
#include "llpanel.h"
+#include "llbutton.h"
-class LLButton;
class LLLocationInputCtrl;
class LLMenuGL;
class LLSearchEditor;
class LLSearchComboBox;
/**
+ * This button is able to handle click-dragging mouse event.
+ * It has appropriated signal for this event.
+ * Dragging direction can be set from xml by attribute called 'direction'
+ *
+ * *TODO: move to llui?
+ */
+
+class LLPullButton : public LLButton
+{
+ LOG_CLASS(LLPullButton);
+
+public:
+
+ struct Params : public LLInitParam::Block<Params, LLButton::Params>
+ {
+ Optional<std::string> direction; // left, right, down, up
+
+ Params()
+ : direction("direction","down")
+ {}
+ };
+
+ /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+
+ /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
+
+ /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+
+ boost::signals2::connection setClickDraggingCallback( const commit_signal_t::slot_type& cb );
+
+ /* virtual*/ ~LLPullButton()
+ {
+ delete mClickDraggingSignal;
+ }
+
+protected:
+ friend class LLUICtrlFactory;
+ // convert string name into direction vector
+ void setDirectionFromName(const std::string& name);
+ LLPullButton(const LLPullButton::Params& params);
+
+ commit_signal_t* mClickDraggingSignal;
+ LLVector2 mLastMouseDown;
+ LLVector2 mDraggingDirection;
+};
+
+/**
* Web browser-like navigation bar.
*/
class LLNavigationBar
@@ -95,8 +142,8 @@ private:
void fillSearchComboBox();
LLMenuGL* mTeleportHistoryMenu;
- LLButton* mBtnBack;
- LLButton* mBtnForward;
+ LLPullButton* mBtnBack;
+ LLPullButton* mBtnForward;
LLButton* mBtnHome;
LLSearchComboBox* mSearchComboBox;
LLLocationInputCtrl* mCmbLocation;
diff --git a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
index 5fe5db892a..02eddc9212 100644
--- a/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_navigation_bar.xml
@@ -39,8 +39,9 @@
layout="topleft"
name="navigation_panel"
width="600">
- <button
+ <pull_button
follows="left|top"
+ direction="down"
height="23"
image_overlay="Arrow_Left_Off"
layout="topleft"
@@ -49,8 +50,9 @@
tool_tip="Go back to previous location"
top="2"
width="31" />
- <button
+ <pull_button
follows="left|top"
+ direction="down"
height="23"
image_overlay="Arrow_Right_Off"
layout="topleft"