summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/lltooltip.cpp32
-rw-r--r--indra/llui/lltooltip.h18
-rw-r--r--indra/newview/llviewerwindow.cpp31
3 files changed, 51 insertions, 30 deletions
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index fe1c2ba67c..376bef1434 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -168,7 +168,6 @@ LLToolTip::Params::Params()
LLToolTip::LLToolTip(const LLToolTip::Params& p)
: LLPanel(p),
- mMaxWidth(p.max_width),
mHasClickCallback(p.click_callback.isProvided()),
mPadding(p.padding),
mTextBox(NULL),
@@ -177,11 +176,9 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
mHomePageButton(NULL)
{
LLTextBox::Params params;
- params.initial_value = "tip_text";
params.name = params.initial_value().asString();
// bake textbox padding into initial rect
params.rect = LLRect (mPadding, mPadding + 1, mPadding + 1, mPadding);
- params.follows.flags = FOLLOWS_ALL;
params.h_pad = 0;
params.v_pad = 0;
params.mouse_opaque = false;
@@ -206,7 +203,6 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16);
icon_rect.setOriginAndSize(mPadding, mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
icon_params.rect = icon_rect;
- //icon_params.follows.flags = FOLLOWS_LEFT | FOLLOWS_BOTTOM;
icon_params.image_unselected(imagep);
icon_params.image_selected(imagep);
@@ -277,15 +273,30 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
}
}
-void LLToolTip::setValue(const LLSD& value)
+void LLToolTip::initFromParams(const LLToolTip::Params& p)
{
+ LLPanel::initFromParams(p);
+
+ // do this *after* we've had our size set in LLPanel::initFromParams();
const S32 REALLY_LARGE_HEIGHT = 10000;
- reshape(mMaxWidth, REALLY_LARGE_HEIGHT);
+ mTextBox->reshape(p.max_width, REALLY_LARGE_HEIGHT);
- mTextBox->setValue(value);
+ if (p.styled_message.isProvided())
+ {
+ for (LLInitParam::ParamIterator<LLToolTip::StyledText>::const_iterator text_it = p.styled_message().begin();
+ text_it != p.styled_message().end();
+ ++text_it)
+ {
+ mTextBox->appendText(text_it->text(), false, text_it->style);
+ }
+ }
+ else
+ {
+ mTextBox->setText(p.message());
+ }
LLRect text_contents_rect = mTextBox->getContentsRect();
- S32 text_width = llmin(mMaxWidth, text_contents_rect.getWidth());
+ S32 text_width = llmin(p.max_width(), text_contents_rect.getWidth());
S32 text_height = text_contents_rect.getHeight();
mTextBox->reshape(text_width, text_height);
@@ -296,7 +307,7 @@ void LLToolTip::setValue(const LLSD& value)
tooltip_rect.mBottom = 0;
tooltip_rect.mLeft = 0;
- setRect(tooltip_rect);
+ setShape(tooltip_rect);
}
void LLToolTip::setVisible(BOOL visible)
@@ -407,9 +418,8 @@ void LLToolTipMgr::createToolTip(const LLToolTip::Params& params)
}
tooltip_params.rect = LLRect (0, 1, 1, 0);
-
mToolTip = LLUICtrlFactory::create<LLToolTip> (tooltip_params);
- mToolTip->setValue(params.message());
+
gToolTipView->addChild(mToolTip);
if (params.pos.isProvided())
diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h
index 30d251266c..6e9cb8b434 100644
--- a/indra/llui/lltooltip.h
+++ b/indra/llui/lltooltip.h
@@ -37,6 +37,7 @@
#include "llsingleton.h"
#include "llinitparam.h"
#include "llpanel.h"
+#include "llstyle.h"
//
// Classes
@@ -65,11 +66,19 @@ public:
class LLToolTip : public LLPanel
{
public:
+
+ struct StyledText : public LLInitParam::Block<StyledText>
+ {
+ Mandatory<std::string> text;
+ Optional<LLStyle::Params> style;
+ };
+
struct Params : public LLInitParam::Block<Params, LLPanel::Params>
{
typedef boost::function<void(void)> click_callback_t;
- Mandatory<std::string> message;
+ Optional<std::string> message;
+ Multiple<StyledText> styled_message;
Optional<LLCoordGL> pos;
Optional<F32> delay_time,
@@ -85,8 +94,8 @@ public:
Optional<click_callback_t> click_callback,
click_playmedia_callback,
click_homepage_callback;
- Optional<S32> max_width;
- Optional<S32> padding;
+ Optional<S32> max_width,
+ padding;
Optional<bool> wrap;
Params();
@@ -94,7 +103,6 @@ public:
/*virtual*/ void draw();
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
- /*virtual*/ void setValue(const LLSD& value);
/*virtual*/ void setVisible(BOOL visible);
bool isFading();
@@ -102,6 +110,7 @@ public:
bool hasClickCallback();
LLToolTip(const Params& p);
+ void initFromParams(const LLToolTip::Params& params);
private:
class LLTextBox* mTextBox;
@@ -111,7 +120,6 @@ private:
LLFrameTimer mFadeTimer;
LLFrameTimer mVisibleTimer;
- S32 mMaxWidth;
bool mHasClickCallback;
S32 mPadding; // pixels
};
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 29ce2510f2..ce13c51df3 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2302,13 +2302,13 @@ void LLViewerWindow::moveCursorToCenter()
// Hover handlers
//
-void append_xui_tooltip(LLView* viewp, std::string& tool_tip_msg)
+void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params)
{
if (viewp)
{
- if (!tool_tip_msg.empty())
+ if (!params.styled_message().empty())
{
- tool_tip_msg.append("\n---------\n");
+ params.styled_message.add().text("\n---------\n");
}
LLView::root_to_view_iterator_t end_tooltip_it = viewp->endRootToView();
// NOTE: we skip "root" since it is assumed
@@ -2318,15 +2318,16 @@ void append_xui_tooltip(LLView* viewp, std::string& tool_tip_msg)
{
LLView* viewp = *tooltip_it;
- tool_tip_msg.append(viewp->getName());
+ params.styled_message.add().text(viewp->getName());
+
LLPanel* panelp = dynamic_cast<LLPanel*>(viewp);
if (panelp && !panelp->getXMLFilename().empty())
{
- tool_tip_msg.append("(");
- tool_tip_msg.append(panelp->getXMLFilename());
- tool_tip_msg.append(")");
+ params.styled_message.add()
+ .text("(" + panelp->getXMLFilename() + ")")
+ .style.color(LLColor4(0.7f, 0.7f, 1.f, 1.f));
}
- tool_tip_msg.append("/");
+ params.styled_message.add().text("/");
}
}
}
@@ -2567,6 +2568,8 @@ void LLViewerWindow::updateUI()
if (gSavedSettings.getBOOL("DebugShowXUINames"))
{
+ LLToolTip::Params params;
+
LLView* tooltip_view = mRootView;
LLView::tree_iterator_t end_it = mRootView->endTreeDFS();
for (LLView::tree_iterator_t it = mRootView->beginTreeDFS(); it != end_it; ++it)
@@ -2599,20 +2602,20 @@ void LLViewerWindow::updateUI()
// NOTE: this emulates visiting only the leaf nodes that meet our criteria
if (!viewp->hasAncestor(tooltip_view))
{
- append_xui_tooltip(tooltip_view, tool_tip_msg);
+ append_xui_tooltip(tooltip_view, params);
screen_sticky_rect.intersectWith(tooltip_view->calcScreenRect());
}
tooltip_view = viewp;
}
}
- append_xui_tooltip(tooltip_view, tool_tip_msg);
+ append_xui_tooltip(tooltip_view, params);
screen_sticky_rect.intersectWith(tooltip_view->calcScreenRect());
- LLToolTipMgr::instance().show(LLToolTip::Params()
- .message(tool_tip_msg)
- .sticky_rect(screen_sticky_rect)
- .max_width(400));
+ params.sticky_rect = screen_sticky_rect;
+ params.max_width = 400;
+
+ LLToolTipMgr::instance().show(params);
}
// if there is a mouse captor, nothing else gets a tooltip
else if (mouse_captor)