EXP-1504 : Move the tab opening stuff to lltabcontainer and out of llbutton. Added an xui param to allow drill through tabs. Set that param for build panel only.

meow-7.2.2
Merov Linden 2011-11-11 09:31:07 -08:00
parent 7d78c63c05
commit 4afb450225
5 changed files with 62 additions and 74 deletions

View File

@ -104,7 +104,6 @@ LLButton::Params::Params()
use_draw_context_alpha("use_draw_context_alpha", true),
badge("badge"),
handle_right_mouse("handle_right_mouse"),
click_on_drag_and_drop("click_on_drag_and_drop", false),
held_down_delay("held_down_delay"),
button_flash_count("button_flash_count"),
button_flash_rate("button_flash_rate")
@ -172,7 +171,6 @@ LLButton::LLButton(const LLButton::Params& p)
mHeldDownSignal(NULL),
mUseDrawContextAlpha(p.use_draw_context_alpha),
mHandleRightMouse(p.handle_right_mouse),
mClickOnDragAndDrop(p.click_on_drag_and_drop), // if true, hovering on button while dragging -> click
mButtonFlashCount(p.button_flash_count),
mButtonFlashRate(p.button_flash_rate)
{
@ -1236,35 +1234,8 @@ void LLButton::resetMouseDownTimer()
mMouseDownTimer.reset();
}
BOOL LLButton::handleDoubleClick(S32 x, S32 y, MASK mask)
{
// just treat a double click as a second click
return handleMouseDown(x, y, mask);
}
// virtual
BOOL LLButton::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType type, void* cargo_data, EAcceptance *accept, std::string &tooltip)
{
const F32 CLICK_ON_DAD_DELAY_TIME = 0.5f;
if (mClickOnDragAndDrop)
{
// In that case, though the button doesn't really handles drops, it'll "click" if hovering on it
// while dragging something. That allows for instance drilling into tabbed containers.
// Note: we use the same timer as mouse down just as convenience and to avoid duplication.
if (mMouseDownTimer.getStarted())
{
if (mMouseDownTimer.getElapsedTimeF32() > CLICK_ON_DAD_DELAY_TIME )
{
onCommit();
mMouseDownTimer.stop();
}
}
else
{
mMouseDownTimer.start();
}
}
// The true DaD effect is handled at the View level if any.
return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip);
}

View File

@ -132,7 +132,6 @@ public:
Optional<LLBadge::Params> badge;
Optional<bool> handle_right_mouse;
Optional<bool> click_on_drag_and_drop;
Optional<S32> button_flash_count;
Optional<F32> button_flash_rate;
@ -160,11 +159,6 @@ public:
virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type,
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
virtual void draw();
/*virtual*/ BOOL postBuild();
@ -382,7 +376,6 @@ protected:
LLFrameTimer mFlashingTimer;
bool mHandleRightMouse;
bool mClickOnDragAndDrop;
};
// Build time optimization, generate once in .cpp file

View File

@ -214,6 +214,7 @@ LLTabContainer::Params::Params()
middle_tab("middle_tab"),
last_tab("last_tab"),
use_custom_icon_ctrl("use_custom_icon_ctrl", false),
open_tabs_on_drag_and_drop("open_tabs_on_drag_and_drop", false),
tab_icon_ctrl_pad("tab_icon_ctrl_pad", 0),
use_ellipses("use_ellipses"),
font_halign("halign")
@ -250,6 +251,7 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p)
mMiddleTabParams(p.middle_tab),
mLastTabParams(p.last_tab),
mCustomIconCtrlUsed(p.use_custom_icon_ctrl),
mOpenTabsOnDragAndDrop(p.open_tabs_on_drag_and_drop),
mTabIconCtrlPad(p.tab_icon_ctrl_pad),
mUseTabEllipses(p.use_ellipses)
{
@ -812,50 +814,62 @@ BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDrag
{
BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
if( !getTabsHidden()
&& mDragAndDropDelayTimer.getStarted()
&& mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME )
if(mOpenTabsOnDragAndDrop && !getTabsHidden())
{
if (has_scroll_arrows)
// In that case, we'll open the hovered tab while dragging and dropping items.
// This allows for drilling through tabs.
if (mDragAndDropDelayTimer.getStarted())
{
if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y))
if (mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME)
{
S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft;
S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom;
mJumpPrevArrowBtn->handleHover(local_x, local_y, mask);
}
if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft;
S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom;
mJumpNextArrowBtn->handleHover(local_x, local_y, mask);
}
if (mPrevArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mPrevArrowBtn->getRect().mLeft;
S32 local_y = y - mPrevArrowBtn->getRect().mBottom;
mPrevArrowBtn->handleHover(local_x, local_y, mask);
}
else if (mNextArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mNextArrowBtn->getRect().mLeft;
S32 local_y = y - mNextArrowBtn->getRect().mBottom;
mNextArrowBtn->handleHover(local_x, local_y, mask);
}
}
if (has_scroll_arrows)
{
if (mJumpPrevArrowBtn && mJumpPrevArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mJumpPrevArrowBtn->getRect().mLeft;
S32 local_y = y - mJumpPrevArrowBtn->getRect().mBottom;
mJumpPrevArrowBtn->handleHover(local_x, local_y, mask);
}
if (mJumpNextArrowBtn && mJumpNextArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mJumpNextArrowBtn->getRect().mLeft;
S32 local_y = y - mJumpNextArrowBtn->getRect().mBottom;
mJumpNextArrowBtn->handleHover(local_x, local_y, mask);
}
if (mPrevArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mPrevArrowBtn->getRect().mLeft;
S32 local_y = y - mPrevArrowBtn->getRect().mBottom;
mPrevArrowBtn->handleHover(local_x, local_y, mask);
}
else if (mNextArrowBtn->getRect().pointInRect(x, y))
{
S32 local_x = x - mNextArrowBtn->getRect().mLeft;
S32 local_y = y - mNextArrowBtn->getRect().mBottom;
mNextArrowBtn->handleHover(local_x, local_y, mask);
}
}
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
LLTabTuple* tuple = *iter;
tuple->mButton->setVisible( TRUE );
S32 local_x = x - tuple->mButton->getRect().mLeft;
S32 local_y = y - tuple->mButton->getRect().mBottom;
if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible())
{
tuple->mButton->onCommit();
for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
{
LLTabTuple* tuple = *iter;
tuple->mButton->setVisible( TRUE );
S32 local_x = x - tuple->mButton->getRect().mLeft;
S32 local_y = y - tuple->mButton->getRect().mBottom;
if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible())
{
tuple->mButton->onCommit();
}
}
// Stop the timer whether successful or not. Don't let it run forever.
mDragAndDropDelayTimer.stop();
}
}
else
{
// Start a timer so we don't open tabs as soon as we hover on them
mDragAndDropDelayTimer.start();
}
}
return LLView::handleDragAndDrop(x, y, mask, drop, type, cargo_data, accept, tooltip);
@ -1041,7 +1055,6 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
p.tab_stop(false);
p.label_shadow(false);
p.follows.flags = FOLLOWS_LEFT;
p.click_on_drag_and_drop(true);
if (mIsVertical)
{
@ -1246,6 +1259,10 @@ void LLTabContainer::enableTabButton(S32 which, BOOL enable)
{
mTabList[which]->mButton->setEnabled(enable);
}
// Stop the DaD timer as it might run forever
// enableTabButton() is typically called on refresh and draw when anything changed
// in the tab container so it's a good time to reset that.
mDragAndDropDelayTimer.stop();
}
void LLTabContainer::deleteAllTabs()

View File

@ -104,6 +104,11 @@ public:
*/
Optional<bool> use_custom_icon_ctrl;
/**
* Open tabs on hover in drag and drop situations
*/
Optional<bool> open_tabs_on_drag_and_drop;
/**
* Paddings for LLIconCtrl in case of LLCustomButtonIconCtrl usage(use_custom_icon_ctrl = true)
*/
@ -300,6 +305,7 @@ private:
TabParams mLastTabParams;
bool mCustomIconCtrlUsed;
bool mOpenTabsOnDragAndDrop;
S32 mTabIconCtrlPad;
bool mUseTabEllipses;
};

View File

@ -791,6 +791,7 @@
tab_min_width="40"
tab_position="top"
tab_height="25"
open_tabs_on_drag_and_drop="true"
top="173"
width="295">