summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorLeslie Linden <leslie@lindenlab.com>2011-10-11 09:10:33 -0700
committerLeslie Linden <leslie@lindenlab.com>2011-10-11 09:10:33 -0700
commit05b31ff3b235bdcf7e9bb0fe1ff701c006e8ec66 (patch)
tree4fd5e083694142609bd099cf71e092f9c7457e9f /indra/llui
parent0620e6a79149e455744131703e8bdb74864b69be (diff)
parentc845925eebb5cad3049ee0f3b1d0adea3e3a46b5 (diff)
Merge
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp2
-rw-r--r--indra/llui/llcommandmanager.h4
-rw-r--r--indra/llui/llfloater.cpp21
-rw-r--r--indra/llui/llfloater.h2
-rw-r--r--indra/llui/llfloaterreg.cpp6
-rw-r--r--indra/llui/llhelp.h1
-rw-r--r--indra/llui/llresizehandle.cpp12
-rw-r--r--indra/llui/llresizehandle.h7
-rw-r--r--indra/llui/llsdparam.cpp6
-rw-r--r--indra/llui/llsdparam.h3
-rw-r--r--indra/llui/lltoolbar.cpp88
-rw-r--r--indra/llui/lltoolbar.h10
12 files changed, 72 insertions, 90 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 68cb5164b6..ba3748a573 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -1002,7 +1002,7 @@ void LLButton::resize(LLUIString label)
if (mImageOverlay)
{
S32 overlay_width = mImageOverlay->getWidth();
- F32 scale_factor = getRect().getHeight() / (F32)mImageOverlay->getHeight();
+ F32 scale_factor = (getRect().getHeight() - (mImageOverlayBottomPad + mImageOverlayTopPad)) / (F32)mImageOverlay->getHeight();
overlay_width = llround((F32)overlay_width * scale_factor);
switch(mImageOverlayAlignment)
diff --git a/indra/llui/llcommandmanager.h b/indra/llui/llcommandmanager.h
index fdad7cd1b5..46e0fe6e69 100644
--- a/indra/llui/llcommandmanager.h
+++ b/indra/llui/llcommandmanager.h
@@ -68,8 +68,8 @@ public:
mUUID = LLUUID::generateNewID(p.name);
}
- LLCommandId(const std::string& name, const LLUUID& uuid)
- : mName(name),
+ LLCommandId(const LLUUID& uuid)
+ : mName(""),
mUUID(uuid)
{
}
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index cba14e21c3..90c41e99dc 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -459,15 +459,24 @@ void LLFloater::layoutResizeCtrls()
mResizeHandle[3]->setRect(rect);
}
-void LLFloater::enableResizeCtrls(bool enable)
+void LLFloater::enableResizeCtrls(bool enable, bool width, bool height)
{
+ mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
+ mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
+
+ mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
+ mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
+
+ mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
+ mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
+
+ mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
+ mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
+
for (S32 i = 0; i < 4; ++i)
{
- mResizeBar[i]->setVisible(enable);
- mResizeBar[i]->setEnabled(enable);
-
- mResizeHandle[i]->setVisible(enable);
- mResizeHandle[i]->setEnabled(enable);
+ mResizeHandle[i]->setVisible(enable && width && height);
+ mResizeHandle[i]->setEnabled(enable && width && height);
}
}
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 5aff542049..af9665e599 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -291,6 +291,7 @@ public:
void updateTransparency(ETypeTransparency transparency_type);
+ void enableResizeCtrls(bool enable, bool width = true, bool height = true);
protected:
virtual void applySavedVariables();
@@ -340,7 +341,6 @@ private:
BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index);
void addResizeCtrls();
void layoutResizeCtrls();
- void enableResizeCtrls(bool enable);
void addDragHandle();
void layoutDragHandle(); // repair layout
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index d0ae9413a3..ae06eb74ac 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -110,7 +110,11 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
int index = list.size();
res = build_func(key);
-
+ if (!res)
+ {
+ llwarns << "Failed to build floater type: '" << name << "'." << llendl;
+ return NULL;
+ }
bool success = res->buildFromFile(xui_file, NULL);
if (!success)
{
diff --git a/indra/llui/llhelp.h b/indra/llui/llhelp.h
index 83317bd03c..1726347a78 100644
--- a/indra/llui/llhelp.h
+++ b/indra/llui/llhelp.h
@@ -32,6 +32,7 @@ class LLHelp
{
public:
virtual void showTopic(const std::string &topic) = 0;
+ virtual std::string getURL(const std::string &topic) = 0;
// return default (fallback) topic name suitable for showTopic()
virtual std::string defaultTopic() = 0;
// return topic to use before the user logs in
diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp
index 942e84eeb6..c3a51c36c9 100644
--- a/indra/llui/llresizehandle.cpp
+++ b/indra/llui/llresizehandle.cpp
@@ -55,8 +55,6 @@ LLResizeHandle::LLResizeHandle(const LLResizeHandle::Params& p)
mImage( NULL ),
mMinWidth( p.min_width ),
mMinHeight( p.min_height ),
- mMaxWidth(S32_MAX),
- mMaxHeight(S32_MAX),
mCorner( p.corner )
{
if( RIGHT_BOTTOM == mCorner)
@@ -179,11 +177,6 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_width = mMinWidth;
delta_x = x_multiple * (mMinWidth - orig_rect.getWidth());
}
- else if (new_width > mMaxWidth)
- {
- new_width = mMaxWidth;
- delta_x = x_multiple * (mMaxWidth - orig_rect.getWidth());
- }
S32 new_height = orig_rect.getHeight() + y_multiple * delta_y;
if( new_height < mMinHeight )
@@ -191,11 +184,6 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask)
new_height = mMinHeight;
delta_y = y_multiple * (mMinHeight - orig_rect.getHeight());
}
- else if (new_height > mMaxHeight)
- {
- new_height = mMaxHeight;
- delta_y = y_multiple * (mMaxHeight - orig_rect.getHeight());
- }
switch( mCorner )
{
diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h
index 5cfe3fb63c..7541b9e6c0 100644
--- a/indra/llui/llresizehandle.h
+++ b/indra/llui/llresizehandle.h
@@ -55,10 +55,7 @@ public:
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; }
-
- void setMaxWidth(S32 width) { mMaxWidth = width;}
- void setMaxHeight(S32 height) { mMaxHeight = height;}
-
+
private:
BOOL pointInHandle( S32 x, S32 y );
@@ -69,9 +66,7 @@ private:
LLCoordGL mLastMouseDir;
LLPointer<LLUIImage> mImage;
S32 mMinWidth;
- S32 mMaxWidth;
S32 mMinHeight;
- S32 mMaxHeight;
const ECorner mCorner;
};
diff --git a/indra/llui/llsdparam.cpp b/indra/llui/llsdparam.cpp
index da50c0ff39..242b1fca7f 100644
--- a/indra/llui/llsdparam.cpp
+++ b/indra/llui/llsdparam.cpp
@@ -299,6 +299,12 @@ void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd, LLI
}
}
+//static
+void LLParamSDParserUtilities::readSDValues(read_sd_cb_t cb, const LLSD& sd)
+{
+ LLInitParam::Parser::name_stack_t stack = LLInitParam::Parser::name_stack_t();
+ readSDValues(cb, sd, stack);
+}
namespace LLInitParam
{
// LLSD specialization
diff --git a/indra/llui/llsdparam.h b/indra/llui/llsdparam.h
index 784358d038..c1cfa98399 100644
--- a/indra/llui/llsdparam.h
+++ b/indra/llui/llsdparam.h
@@ -36,7 +36,8 @@ struct LLParamSDParserUtilities
static LLSD& getSDWriteNode(LLSD& input, LLInitParam::Parser::name_stack_range_t& name_stack_range);
typedef boost::function<void (const LLSD&, LLInitParam::Parser::name_stack_t&)> read_sd_cb_t;
- static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack = LLInitParam::Parser::name_stack_t());
+ static void readSDValues(read_sd_cb_t cb, const LLSD& sd, LLInitParam::Parser::name_stack_t& stack);
+ static void readSDValues(read_sd_cb_t cb, const LLSD& sd);
};
class LLParamSDParser
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 6332b2674a..89184f781f 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -114,8 +114,6 @@ 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;
- mDraggedCommand = LLCommandId::null;
- mRank = 0;
}
LLToolBar::~LLToolBar()
@@ -211,19 +209,14 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
// Create the button and do the things that don't need ordering
LLToolBarButton* button = createButton(commandId);
mButtonPanel->addChild(button);
- LLCommandId temp_command = commandId;
- if (commandId.name() == "Drag Tool")
- {
- temp_command = LLCommandId("Drag Tool");
- }
- mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
+ mButtonMap.insert(std::make_pair(commandId.uuid(), button));
// Insert the command and button in the right place in their respective lists
- if ((rank >= mButtonCommands.size()) || (rank < 0))
+ if ((rank >= mButtonCommands.size()) || (rank == RANK_NONE))
{
// In that case, back load
- mButtonCommands.push_back(temp_command);
+ mButtonCommands.push_back(commandId);
mButtons.push_back(button);
}
else
@@ -238,7 +231,7 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
rank--;
}
// ...then insert
- mButtonCommands.insert(it_command,temp_command);
+ mButtonCommands.insert(it_command,commandId);
mButtons.insert(it_button,button);
}
@@ -247,27 +240,28 @@ bool LLToolBar::addCommand(const LLCommandId& commandId, int rank)
return true;
}
-bool LLToolBar::removeCommand(const LLCommandId& commandId)
+// Remove a command from the list
+// Returns the rank of the command in the original list so that doing addCommand(id,rank) right after
+// a removeCommand(id) would leave the list unchanged.
+// Returns RANK_NONE if the command is not found in the list
+int LLToolBar::removeCommand(const LLCommandId& commandId)
{
- if (!hasCommand(commandId)) return false;
+ if (!hasCommand(commandId)) return RANK_NONE;
llinfos << "Merov debug : removeCommand, " << commandId.name() << ", " << commandId.uuid() << llendl;
// First erase the map record
- LLCommandId temp_command = commandId;
- if (commandId.name() == "Drag Tool")
- {
- temp_command = LLCommandId("Drag Tool");
- }
- command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
+ command_id_map::iterator it = mButtonMap.find(commandId.uuid());
mButtonMap.erase(it);
// Now iterate on the commands and buttons to identify the relevant records
+ int rank = 0;
std::list<LLToolBarButton*>::iterator it_button = mButtons.begin();
command_id_list_t::iterator it_command = mButtonCommands.begin();
- while (*it_command != temp_command)
+ while (*it_command != commandId)
{
++it_button;
++it_command;
+ ++rank;
}
// Delete the button and erase the command and button records
@@ -277,7 +271,7 @@ bool LLToolBar::removeCommand(const LLCommandId& commandId)
mNeedsLayout = true;
- return true;
+ return rank;
}
void LLToolBar::clearCommandsList()
@@ -292,12 +286,7 @@ bool LLToolBar::hasCommand(const LLCommandId& commandId) const
{
if (commandId != LLCommandId::null)
{
- LLCommandId temp_command = commandId;
- if (commandId.name() == "Drag Tool")
- {
- temp_command = LLCommandId("Drag Tool");
- }
- command_id_map::const_iterator it = mButtonMap.find(temp_command.uuid());
+ command_id_map::const_iterator it = mButtonMap.find(commandId.uuid());
return (it != mButtonMap.end());
}
@@ -310,12 +299,7 @@ bool LLToolBar::enableCommand(const LLCommandId& commandId, bool enabled)
if (commandId != LLCommandId::null)
{
- LLCommandId temp_command = commandId;
- if (commandId.name() == "Drag Tool")
- {
- temp_command = LLCommandId("Drag Tool");
- }
- command_id_map::iterator it = mButtonMap.find(temp_command.uuid());
+ command_id_map::iterator it = mButtonMap.find(commandId.uuid());
if (it != mButtonMap.end())
{
it->second->setEnabled(enabled);
@@ -410,6 +394,10 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row
}
}
+// Returns the position of the coordinates as a rank in the button list.
+// The rank is the position a tool dropped in (x,y) would assume in the button list.
+// The value returned is between 0 and mButtons.size(), 0 being the first element to the left
+// (or top) and mButtons.size() the last one to the right (or bottom).
int LLToolBar::getRankFromPosition(S32 x, S32 y)
{
int rank = 0;
@@ -618,12 +606,6 @@ void LLToolBar::draw()
}
}
}
- // HACK!!!
- if (!mDragAndDropTarget)
- {
- removeCommand(mDraggedCommand);
- mDraggedCommand = LLCommandId::null;
- }
updateLayoutAsNeeded();
// rect may have shifted during layout
@@ -654,12 +636,7 @@ void LLToolBar::createButtons()
LLToolBarButton* button = createButton(command_id);
mButtons.push_back(button);
mButtonPanel->addChild(button);
- LLCommandId temp_command = command_id;
- if (command_id.name() == "Drag Tool")
- {
- temp_command = LLCommandId("Drag Tool");
- }
- mButtonMap.insert(std::make_pair(temp_command.uuid(), button));
+ mButtonMap.insert(std::make_pair(command_id.uuid(), button));
}
mNeedsLayout = true;
}
@@ -736,7 +713,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EAcceptance* accept,
std::string& tooltip_msg)
{
- //llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl;
+ llinfos << "Merov debug : handleDragAndDrop. drop = " << drop << ", x = " << x << ", y = " << y << llendl;
// If we have a drop callback, that means that we can handle the drop
BOOL handled = (mHandleDropCallback ? TRUE : FALSE);
@@ -761,19 +738,13 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
LLAssetType::EType type = inv_item->getType();
if (type == LLAssetType::AT_WIDGET)
{
- mRank = getRankFromPosition(x, y);
- mDraggedCommand = LLCommandId("Drag Tool",inv_item->getUUID());
- removeCommand(mDraggedCommand);
- addCommand(mDraggedCommand,mRank);
+ LLCommandId dragged_command(inv_item->getUUID());
+ int rank = getRankFromPosition(x, y);
+ removeCommand(dragged_command);
+ addCommand(dragged_command,rank);
mDragAndDropTarget = true;
}
}
- else
- {
- removeCommand(mDraggedCommand);
- mDraggedCommand = LLCommandId::null;
- }
-
}
return handled;
@@ -852,3 +823,8 @@ void LLToolBarButton::onMouseCaptureLost()
{
mIsDragged = false;
}
+
+void LLToolBarButton::reshape(S32 width, S32 height, BOOL called_from_parent)
+{
+ LLButton::reshape(mWidthRange.clamp(width), height, called_from_parent);
+}
diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h
index 84fa7ec0df..321064a0fd 100644
--- a/indra/llui/lltoolbar.h
+++ b/indra/llui/lltoolbar.h
@@ -62,6 +62,8 @@ public:
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
+ void reshape(S32 width, S32 height, BOOL called_from_parent = true);
+
void setCommandId(const LLCommandId& id) { mId = id; }
void setStartDragCallback(tool_startdrag_callback_t cb) { mStartDragItemCallback = cb; }
@@ -161,9 +163,11 @@ public:
void* cargo_data,
EAcceptance* accept,
std::string& tooltip_msg);
+
+ static const int RANK_NONE = -1;
- bool addCommand(const LLCommandId& commandId, int rank = -1);
- bool removeCommand(const LLCommandId& commandId);
+ bool addCommand(const LLCommandId& commandId, int rank = RANK_NONE);
+ int removeCommand(const LLCommandId& commandId); // Returns the rank the removed command was at, RANK_NONE if not found
bool hasCommand(const LLCommandId& commandId) const;
bool enableCommand(const LLCommandId& commandId, bool enabled);
@@ -184,8 +188,6 @@ protected:
tool_handledrag_callback_t mHandleDragItemCallback;
tool_handledrop_callback_t mHandleDropCallback;
bool mDragAndDropTarget;
- int mRank;
- LLCommandId mDraggedCommand;
public:
// Methods used in loading and saving toolbar settings