diff options
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index c0058d534d..199574629f 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -33,7 +33,6 @@ #include "llcommandmanager.h" #include "llmenugl.h" #include "lltrans.h" -#include "lltoolbarview.h" // uncomment this and remove the one in llui.cpp when there is an external reference to this translation unit // thanks, MSVC! @@ -108,6 +107,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_ONLY] = p.button_icon; + mUUID = LLUUID::LLUUID::generateNewID(p.name); } LLToolBar::~LLToolBar() @@ -528,6 +528,8 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) cbParam.function_name = commandp->functionName(); cbParam.parameter = commandp->parameter(); button->setCommitCallback(cbParam); + button->setStartDragCallback(mStartDragItemCallback); + button->setHandleDragCallback(mHandleDragItemCallback); } button->setCommandId(id); @@ -535,9 +537,30 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) } -// -// LLToolBarButton -// +BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", tooltip = " << tooltip_msg << llendl; + // If we have a drop callback, that means that we can handle the drop + BOOL handled = (mHandleDropCallback ? TRUE : FALSE); + + // if drop, time to call the drop callback to get the operation done + if (handled && drop) + { + handled = mHandleDropCallback(cargo_type,cargo_data,mUUID); + } + + // We accept multi drop by default + *accept = (handled ? ACCEPT_YES_MULTI : ACCEPT_NO); + + // We'll use that flag to change the visual aspect of the target on draw() + mDragAndDropTarget = handled; + + return handled; +} LLToolBarButton::LLToolBarButton(const Params& p) : LLButton(p), @@ -547,8 +570,9 @@ LLToolBarButton::LLToolBarButton(const Params& p) mMaxWidth(p.max_button_width), mDesiredHeight(p.desired_height), mId("") -{} - +{ + mUUID = LLUUID::LLUUID::generateNewID(p.name); +} BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) { @@ -557,24 +581,28 @@ BOOL LLToolBarButton::handleMouseDown(S32 x, S32 y, MASK mask) return LLButton::handleMouseDown(x, y, mask); } -BOOL LLToolBarButton::handleHover(S32 x, S32 y, MASK mask) +BOOL LLToolBarButton::handleHover( S32 x, S32 y, MASK mask ) { - if (hasMouseCapture()) +// llinfos << "Merov debug: handleHover, x = " << x << ", y = " << y << ", mouse = " << hasMouseCapture() << llendl; + BOOL handled = FALSE; + + if (hasMouseCapture() && mStartDragItemCallback && mHandleDragItemCallback) { - S32 dist_squared = (x - mMouseDownX) * (x - mMouseDownX) + (y - mMouseDownY) * (y - mMouseDownY); - S32 threshold = LLUI::sSettingGroups["config"]->getS32("DragAndDropDistanceThreshold"); - S32 threshold_squared = threshold * threshold; - if (dist_squared > threshold_squared) + if (!mIsDragged) { - // start drag and drop - LLToolBarView* view = getParentByType<LLToolBarView>(); - LLToolBar* bar = getParentByType<LLToolBar>(); - if (view) - { - //view->startDrag(bar->createButton(mId)); - //setVisible(FALSE); - } + mStartDragItemCallback(x,y,mUUID); + mIsDragged = true; + handled = TRUE; } + else + { + handled = mHandleDragItemCallback(x,y,mUUID,LLAssetType::AT_WIDGET); + } + } + else + { + handled = LLButton::handleHover(x, y, mask); } - return LLButton::handleHover(x, y, mask); + return handled; } + |