summaryrefslogtreecommitdiff
path: root/indra/llui/lltooltip.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2023-10-03 19:28:18 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-10-03 19:42:47 +0300
commit13f1273c1d0cd7af382b282bd54da2b7efcc70b3 (patch)
tree31a0e89bd7fe86a91b0fccf3f33642af0741c7bc /indra/llui/lltooltip.cpp
parent78f5dbd95f1295af14093807ca125b92e6f5a9d3 (diff)
parent2465470817957c8378e81ec1a7e32551fbac7b26 (diff)
Merge branch 'main' into DRTVWR-588-maint-W
# Conflicts: # indra/llui/lltooltip.h # indra/newview/llinventoryfunctions.cpp # indra/newview/llvovolume.cpp # indra/newview/skins/default/textures/textures.xml
Diffstat (limited to 'indra/llui/lltooltip.cpp')
-rw-r--r--indra/llui/lltooltip.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index c4b132317f..75fc86b226 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -164,6 +164,7 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p)
: LLPanel(p),
mHasClickCallback(p.click_callback.isProvided()),
mPadding(p.padding),
+ mMaxWidth(p.max_width),
mTextBox(NULL),
mInfoButton(NULL),
mPlayMediaButton(NULL),
@@ -274,7 +275,7 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
// do this *after* we've had our size set in LLPanel::initFromParams();
const S32 REALLY_LARGE_HEIGHT = 10000;
- mTextBox->reshape(p.max_width, REALLY_LARGE_HEIGHT);
+ mTextBox->reshape(mMaxWidth, REALLY_LARGE_HEIGHT);
if (p.styled_message.isProvided())
{
@@ -290,16 +291,21 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
mTextBox->setText(p.message());
}
- S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth() + 1);
+ mIsTooltipPastable = p.allow_paste_tooltip;
+
+ updateTextBox();
+ snapToChildren();
+}
+
+void LLToolTip::updateTextBox()
+{
+ S32 text_width = llmin(mMaxWidth, mTextBox->getTextPixelWidth() + 1);
S32 text_height = mTextBox->getTextPixelHeight();
mTextBox->reshape(text_width, text_height);
- if (mInfoButton)
- {
- LLRect text_rect = mTextBox->getRect();
- LLRect icon_rect = mInfoButton->getRect();
- mTextBox->translate(0, icon_rect.getCenterY() - text_rect.getCenterY());
- }
-
+}
+
+void LLToolTip::snapToChildren()
+{
// reshape tooltip panel to fit text box
LLRect tooltip_rect = calcBoundingRect();
tooltip_rect.mTop += mPadding;
@@ -307,11 +313,16 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
tooltip_rect.mBottom = 0;
tooltip_rect.mLeft = 0;
- mTextBox->reshape(mTextBox->getRect().getWidth(), llmax(mTextBox->getRect().getHeight(), tooltip_rect.getHeight() - 2 * mPadding));
+ if (mInfoButton)
+ {
+ mTextBox->reshape(mTextBox->getRect().getWidth(), llmax(mTextBox->getRect().getHeight(), tooltip_rect.getHeight() - 2 * mPadding));
- setShape(tooltip_rect);
+ LLRect text_rect = mTextBox->getRect();
+ LLRect icon_rect = mInfoButton->getRect();
+ mInfoButton->translate(0, text_rect.getCenterY() - icon_rect.getCenterY());
+ }
- mIsTooltipPastable = p.allow_paste_tooltip;
+ setShape(tooltip_rect);
}
void LLToolTip::setVisible(BOOL visible)
@@ -432,7 +443,10 @@ void LLToolTipMgr::createToolTip(const LLToolTip::Params& params)
}
tooltip_params.rect = LLRect (0, 1, 1, 0);
- mToolTip = LLUICtrlFactory::create<LLToolTip> (tooltip_params);
+ if (tooltip_params.create_callback.isProvided())
+ mToolTip = tooltip_params.create_callback()(tooltip_params);
+ else
+ mToolTip = LLUICtrlFactory::create<LLToolTip> (tooltip_params);
gToolTipView->addChild(mToolTip);