summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Serdjuk <dserduk@productengine.com>2010-02-04 15:58:49 +0200
committerDenis Serdjuk <dserduk@productengine.com>2010-02-04 15:58:49 +0200
commit7b62c80060184690ac28d34e4653472179f0cf13 (patch)
tree9a4d82f299e046e70c44cc5185bf52a419fcdb1d
parent667ae0b9a31318d43d36cb6c8cb73a83e1470009 (diff)
Additional commit for low Bug EXT-4242 . No logic had been affected. code cleaning up.
--HG-- branch : product-engine
-rw-r--r--indra/newview/llnavigationbar.cpp57
-rw-r--r--indra/newview/llnavigationbar.h37
2 files changed, 48 insertions, 46 deletions
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index 59708fcfb5..46cab0d868 100644
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -185,43 +185,46 @@ void LLTeleportHistoryMenuItem::onMouseLeave(S32 x, S32 y, MASK mask)
static LLDefaultChildRegistry::Register<LLPullButton> menu_button("pull_button");
-LLPullButton::LLPullButton(const LLPullButton::Params& params):
- LLButton(params)
- , mClickDraggingSignal(NULL)
+LLPullButton::LLPullButton(const LLPullButton::Params& params) :
+ LLButton(params)
{
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);
+boost::signals2::connection LLPullButton::setClickDraggingCallback(const commit_signal_t::slot_type& cb)
+{
+ return mClickDraggingSignal.connect(cb);
}
/*virtual*/
void LLPullButton::onMouseLeave(S32 x, S32 y, MASK mask)
{
LLButton::onMouseLeave(x, y, mask);
-
- if(mMouseDownTimer.getStarted() )
+
+ if (mMouseDownTimer.getStarted()) //an user have done a mouse down, if the timer started. see LLButton::handleMouseDown for details
{
- 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());
- }
- }
+ const LLVector2 cursor_direction = LLVector2(F32(x), F32(y)) - mLastMouseDown;
+ /* For now cursor_direction points to the direction of mouse movement
+ * Need to decide whether should we fire a signal.
+ * We fire if angle between mDraggingDirection and cursor_direction is less that 45 degree
+ * Note:
+ * 0.5 * F_PI_BY_TWO equals to PI/4 radian that equals to angle of 45 degrees
+ */
+ if (angle_between(mDraggingDirection, cursor_direction) < 0.5 * F_PI_BY_TWO)//call if angle < pi/4
+ {
+ mClickDraggingSignal(this, LLSD());
+ }
}
}
/*virtual*/
BOOL LLPullButton::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+ BOOL handled = LLButton::handleMouseDown(x, y, mask);
+ if (handled)
{
- BOOL handled = LLButton::handleMouseDown(x,y, mask);
- if(handled)
- {
+ //if mouse down was handled by button,
+ //capture mouse position to calculate the direction of mouse move after mouseLeave event
mLastMouseDown.set(F32(x), F32(y));
}
return handled;
@@ -230,27 +233,31 @@ BOOL LLPullButton::handleMouseDown(S32 x, S32 y, MASK mask)
/*virtual*/
BOOL LLPullButton::handleMouseUp(S32 x, S32 y, MASK mask)
{
+ // reset data to get ready for next circle
mLastMouseDown.clear();
return LLButton::handleMouseUp(x, y, mask);
}
-
+/**
+ * this function is setting up dragging direction vector.
+ * Last one is just unit vector. It points to direction of mouse drag that we need to handle
+ */
void LLPullButton::setDirectionFromName(const std::string& name)
{
if (name == "left")
{
- mDraggingDirection.set(F32(-1), F32(0));
+ mDraggingDirection.set(F32(-1), F32(0));
}
else if (name == "right")
{
- mDraggingDirection.set(F32(0), F32(1));
+ mDraggingDirection.set(F32(0), F32(1));
}
else if (name == "down")
{
- mDraggingDirection.set(F32(0), F32(-1));
+ mDraggingDirection.set(F32(0), F32(-1));
}
else if (name == "up")
{
- mDraggingDirection.set(F32(0), F32(1));
+ mDraggingDirection.set(F32(0), F32(1));
}
}
diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h
index 9d0abc7a3a..b512f2a79c 100644
--- a/indra/newview/llnavigationbar.h
+++ b/indra/newview/llnavigationbar.h
@@ -44,46 +44,41 @@ 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'
+ * Dragging direction can be set from xml attribute called 'direction'
*
* *TODO: move to llui?
*/
-class LLPullButton : public LLButton
+class LLPullButton: public LLButton
{
LOG_CLASS(LLPullButton);
-
+
public:
-
- struct Params : public LLInitParam::Block<Params, LLButton::Params>
+ struct Params: public LLInitParam::Block<Params, LLButton::Params>
{
- Optional<std::string> direction; // left, right, down, up
-
- Params()
- : direction("direction","down")
- {}
+ 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;
- }
-
+ boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
+
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;
+
+ commit_signal_t mClickDraggingSignal;
LLVector2 mLastMouseDown;
LLVector2 mDraggingDirection;
};