Feature Request: Add a clear button to drop targets (except where not needed).
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <boost/signals2/shared_connection_block.hpp>
|
||||
|
||||
#include "llbutton.h"
|
||||
#include "llinventorymodel.h"
|
||||
#include "llstartup.h"
|
||||
#include "lltextbox.h"
|
||||
@@ -58,6 +59,7 @@ std::string currently_set_to(const LLInventoryItem* item)
|
||||
|
||||
LLDropTarget::LLDropTarget(const LLDropTarget::Params& p)
|
||||
: LLView(p)
|
||||
, mReset(NULL)
|
||||
{
|
||||
setToolTip(std::string(p.tool_tip));
|
||||
|
||||
@@ -76,6 +78,11 @@ LLDropTarget::LLDropTarget(const LLDropTarget::Params& p)
|
||||
mBorder->setMouseOpaque(false);
|
||||
if (!p.border_visible) mBorder->setBorderWidth(0);
|
||||
|
||||
if (p.show_reset)
|
||||
{
|
||||
addChild(mReset = new LLButton("reset", LLRect(), "icn_clear_lineeditor.tga", "icn_clear_lineeditor.tga", "", boost::bind(&LLDropTarget::setValue, this, _2)));
|
||||
}
|
||||
|
||||
// Now set the rects of the children
|
||||
p.fill_parent ? fillParent(getParent()) : setChildRects(p.rect);
|
||||
}
|
||||
@@ -98,6 +105,16 @@ void LLDropTarget::initFromXML(LLXMLNodePtr node, LLView* parent)
|
||||
LLView::initFromXML(node, parent);
|
||||
|
||||
const LLRect& rect = getRect();
|
||||
if (node->hasAttribute("show_reset"))
|
||||
{
|
||||
bool show;
|
||||
node->getAttribute_bool("show_reset", show);
|
||||
if (!show)
|
||||
{
|
||||
delete mReset;
|
||||
mReset = NULL;
|
||||
}
|
||||
}
|
||||
setChildRects(LLRect(0, rect.getHeight(), rect.getWidth(), 0));
|
||||
|
||||
if (node->hasAttribute("name")) // Views can't have names, but drop targets can
|
||||
@@ -171,6 +188,17 @@ void LLDropTarget::setControlName(const std::string& control_name, LLView* conte
|
||||
void LLDropTarget::setChildRects(LLRect rect)
|
||||
{
|
||||
mBorder->setRect(rect);
|
||||
if (mReset)
|
||||
{
|
||||
// Reset button takes rightmost part of the text area.
|
||||
S32 height(rect.getHeight());
|
||||
rect.mRight -= height;
|
||||
mText->setRect(rect);
|
||||
rect.mLeft = rect.mRight;
|
||||
rect.mRight += height;
|
||||
mReset->setRect(rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
mText->setRect(rect);
|
||||
}
|
||||
|
||||
@@ -47,11 +47,13 @@ public:
|
||||
Optional<bool> border_visible; // Whether or not to display the border
|
||||
Optional<std::string> control_name; // Control to change on item drop (Per Account only)
|
||||
Optional<std::string> label; // Label for the LLTextBox, used when label doesn't dynamically change on drop
|
||||
Optional<bool> show_reset; // Whether or not to show the reset button
|
||||
Optional<bool> fill_parent; // Whether or not to fill the direct parent, to have a larger drop target. If true, the next sibling must explicitly define its rect without deltas.
|
||||
Params()
|
||||
: border_visible("border_visible", true)
|
||||
, control_name("control_name", "")
|
||||
, label("label", "")
|
||||
, show_reset("show_reset", true)
|
||||
, fill_parent("fill_parent", false)
|
||||
{
|
||||
changeDefault(mouse_opaque, false);
|
||||
@@ -85,6 +87,7 @@ protected:
|
||||
LLControlVariable* mControl;
|
||||
boost::signals2::scoped_connection mConnection;
|
||||
class LLTextBox* mText;
|
||||
class LLButton* mReset;
|
||||
};
|
||||
|
||||
#endif // LLDROPTARGET_H
|
||||
|
||||
@@ -71,7 +71,14 @@ const S32 NOTICE_DATE_STRING_SIZE = 30;
|
||||
class LLGroupDropTarget : public LLDropTarget
|
||||
{
|
||||
public:
|
||||
LLGroupDropTarget(const LLDropTarget::Params& p = LLDropTarget::Params());
|
||||
struct Params : public LLInitParam::Block<Params, LLDropTarget::Params>
|
||||
{
|
||||
Params()
|
||||
{
|
||||
changeDefault(show_reset, false); // We have a button for this
|
||||
}
|
||||
};
|
||||
LLGroupDropTarget(const Params& p = Params());
|
||||
~LLGroupDropTarget() {};
|
||||
|
||||
//
|
||||
@@ -92,14 +99,14 @@ protected:
|
||||
LLPanelGroupNotices* mGroupNoticesPanel;
|
||||
};
|
||||
|
||||
LLGroupDropTarget::LLGroupDropTarget(const LLDropTarget::Params& p)
|
||||
LLGroupDropTarget::LLGroupDropTarget(const LLGroupDropTarget::Params& p)
|
||||
: LLDropTarget(p)
|
||||
{}
|
||||
|
||||
// static
|
||||
LLView* LLGroupDropTarget::fromXML(LLXMLNodePtr node, LLView* parent, LLUICtrlFactory* factory)
|
||||
{
|
||||
LLGroupDropTarget* target = new LLGroupDropTarget();
|
||||
LLGroupDropTarget* target = new LLGroupDropTarget;
|
||||
target->initFromXML(node, parent);
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
mouse_opaque="true" name="Give item:" v_pad="0" width="75">
|
||||
Give item:
|
||||
</text>
|
||||
<drop_target bottom="-427" height="17" left_delta="79" width="321" fill_parent="true" name="drop_target_rect" label="Drop inventory item here." tool_tip="Drop inventory items here to give them to this person."/>
|
||||
<drop_target bottom="-427" height="17" left_delta="79" width="321" fill_parent="true" show_reset="false" name="drop_target_rect" label="Drop inventory item here." tool_tip="Drop inventory items here to give them to this person."/>
|
||||
<check_box bottom="-447" follows="left|top" font="SansSerifSmall" height="16"
|
||||
initial_value="false" label="Show in search" left="75" mouse_opaque="true"
|
||||
name="allow_publish"
|
||||
|
||||
Reference in New Issue
Block a user