Rewrote layout tooltips to use the new box layout system, fixes word wrapping delay

actorid
scrawl 12 years ago
parent 4c588cbab6
commit fdcbdbf35d

@ -44,6 +44,11 @@ ToolTips::ToolTips(MWBase::WindowManager* windowManager) :
mDelay = Settings::Manager::getFloat("tooltip delay", "GUI");
mRemainingDelay = mDelay;
for (unsigned int i=0; i < mMainWidget->getChildCount(); ++i)
{
mMainWidget->getChildAt(i)->setVisible(false);
}
}
void ToolTips::setEnabled(bool enabled)
@ -115,7 +120,7 @@ void ToolTips::onFrame(float frameDuration)
}
else
{
mHorizontalScrollIndex = 0;
mHorizontalScrollIndex = 0;
mRemainingDelay = mDelay;
}
mLastMouseX = mousePos.left;
@ -215,14 +220,6 @@ void ToolTips::onFrame(float frameDuration)
getWidget(tooltip, focus->getUserString("ToolTipLayout"));
tooltip->setVisible(true);
if (!tooltip->isUserString("DontResize"))
{
tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping
tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height);
}
else
tooltipSize = tooltip->getSize();
std::map<std::string, std::string> userStrings = focus->getUserStrings();
for (std::map<std::string, std::string>::iterator it = userStrings.begin();
@ -243,32 +240,8 @@ void ToolTips::onFrame(float frameDuration)
w->setProperty(propertyKey, it->second);
}
for (unsigned int i=0; i<tooltip->getChildCount(); ++i)
{
MyGUI::Widget* w = tooltip->getChildAt(i);
if (w->isUserString("AutoResizeHorizontal"))
{
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
}
else if (!tooltip->isUserString("DontResize"))
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + w->getWidth() + 8);
if (w->isUserString("AutoResizeVertical"))
{
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
int height = text->getTextSize().height;
if (height > w->getHeight())
{
tooltipSize += MyGUI::IntSize(0, height - w->getHeight());
}
if (height < w->getHeight())
{
tooltipSize -= MyGUI::IntSize(0, w->getHeight() - height);
}
}
}
tooltipSize = tooltip->getSize();
tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height);
}
else
@ -509,20 +482,21 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
captionSize.height);
//if its too long we do hscroll with the caption
if (captionSize.width > maximumWidth){
mHorizontalScrollIndex = mHorizontalScrollIndex + 2;
if (mHorizontalScrollIndex > captionSize.width){
mHorizontalScrollIndex = -totalSize.width;
}
int horizontal_scroll = mHorizontalScrollIndex;
if (horizontal_scroll < 40){
horizontal_scroll = 40;
}else{
horizontal_scroll = 80 - mHorizontalScrollIndex;
}
captionWidget->setPosition (IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top));
if (captionSize.width > maximumWidth)
{
mHorizontalScrollIndex = mHorizontalScrollIndex + 2;
if (mHorizontalScrollIndex > captionSize.width){
mHorizontalScrollIndex = -totalSize.width;
}
int horizontal_scroll = mHorizontalScrollIndex;
if (horizontal_scroll < 40){
horizontal_scroll = 40;
}else{
horizontal_scroll = 80 - mHorizontalScrollIndex;
}
captionWidget->setPosition (IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top));
} else {
captionWidget->setPosition (captionWidget->getPosition() + padding);
captionWidget->setPosition (captionWidget->getPosition() + padding);
}
textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter

@ -588,6 +588,8 @@ void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::s
MyGUI::IntSize AutoSizedEditBox::getRequestedSize()
{
if (getAlign().isHStretch())
throw std::runtime_error("AutoSizedEditBox can't have HStretch align (" + getName() + ")");
return MyGUI::IntSize(getSize().width, getTextSize().height);
}

@ -5,124 +5,124 @@
<!-- Dynamically constructed tooltip goes here -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="DynamicToolTipBox">
<Property key="Visible" value="false"/>
</Widget>
<!-- Text tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="TextToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="TextToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="EditBox" skin="SandText" position="8 8 284 284" align="Left Top Stretch" name="Text">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 8 284 284" align="Left Top" name="Text">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Text with centered caption tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 56" align="Stretch" name="TextWithCenteredCaptionToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 56" align="Stretch" name="TextWithCenteredCaptionToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch" name="CenteredCaption">
<Widget type="AutoSizedTextBox" skin="NormalText" position="8 8 284 18" align="Left Top" name="CenteredCaption">
<Property key="TextAlign" value="Center"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 30 284 18" align="Left Top Stretch" name="CenteredCaptionText">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 30 330 18" align="Left Top" name="CenteredCaptionText">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Class tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 78" align="Stretch" name="ClassToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 78" align="Stretch" name="ClassToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch" name="ClassName">
<Widget type="AutoSizedTextBox" skin="NormalText" position="8 8 284 18" align="Left Top" name="ClassName">
<Property key="TextAlign" value="Center"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 30 284 18" align="Left Top Stretch" name="ClassDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 30 320 18" align="Left Top" name="ClassDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 52 284 18" align="Left Bottom HStretch" name="ClassSpecialisation">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 52 284 18" align="Left Bottom" name="ClassSpecialisation">
<Property key="TextAlign" value="Center"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
</Widget>
<!-- Health tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="HealthToolTip">
<Property key="Visible" value="false"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="HealthImage"/>
<Widget type="HBox" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="HealthToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="VBox">
<UserString key="VStretch" value="true"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="HealthImage"/>
<Widget type="Widget">
<UserString key="VStretch" value="true"/>
</Widget>
</Widget>
<Widget type="EditBox" skin="SandText" position="44 8 248 284" align="Left Top Stretch" name="HealthDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="44 8 248 284" align="Left Top" name="HealthDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Attribute tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="AttributeToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="AttributeToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="AttributeImage"/>
<Widget type="HBox">
<Property key="Spacing" value="4"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="AttributeImage"/>
<Widget type="TextBox" skin="NormalText" position="44 8 252 32" align="Left Top HStretch" name="AttributeName">
<Property key="TextAlign" value="Left VCenter"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<Widget type="AutoSizedEditBox" skin="NormalText" position="44 8 252 32" align="Left Top" name="AttributeName">
<Property key="TextAlign" value="Left VCenter"/>
</Widget>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 44 284 248" align="Left Top Stretch" name="AttributeDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 44 284 248" align="Left Top" name="AttributeDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Skill tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 98" align="Stretch" name="SkillToolTip">
<Property key="Visible" value="false"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="SkillImage"/>
<Widget type="TextBox" skin="NormalText" position="44 8 252 16" align="Left Top HStretch" name="SkillName">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="44 24 252 16" align="Left Top HStretch" name="SkillAttribute">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 98" align="Stretch" name="SkillToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="HBox">
<UserString key="HStretch" value="true"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="SkillImage"/>
<Widget type="VBox">
<Widget type="AutoSizedEditBox" skin="NormalText" position="44 8 252 16" align="Left Top" name="SkillName">
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="AutoSizedEditBox" skin="SandText" position="44 24 252 16" align="Left Top" name="SkillAttribute">
<Property key="TextAlign" value="Left"/>
</Widget>
</Widget>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 44 284 0" align="Left Top Stretch" name="SkillDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 44 320 0" align="Left Top" name="SkillDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
<Widget type="TextBox" skin="NormalText" position="8 48 284 18" align="Left Bottom HStretch">
<UserString key="AutoResizeHorizontal" value="true"/>
<Widget type="AutoSizedTextBox" skin="NormalText" position="8 48 284 18" align="Left Bottom">
<Property key="Caption" value="#{sSkillProgress}"/>
<Property key="TextAlign" value="Center"/>
</Widget>
@ -135,37 +135,36 @@
</Widget>
<!-- Skill tooltip (without progress bar) -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 52" align="Stretch" name="SkillNoProgressToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 52" align="Stretch" name="SkillNoProgressToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="SkillNoProgressImage"/>
<Widget type="HBox">
<UserString key="HStretch" value="true"/>
<Widget type="TextBox" skin="NormalText" position="44 8 252 16" align="Left Top HStretch" name="SkillNoProgressName">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="SkillNoProgressImage"/>
<Widget type="TextBox" skin="SandText" position="44 24 252 16" align="Left Top HStretch" name="SkillNoProgressAttribute">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<Widget type="VBox">
<Widget type="AutoSizedEditBox" skin="NormalText" position="44 8 252 16" align="Left Top" name="SkillNoProgressName">
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="AutoSizedEditBox" skin="SandText" position="44 24 252 16" align="Left Top" name="SkillNoProgressAttribute">
<Property key="TextAlign" value="Left"/>
</Widget>
</Widget>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 44 284 0" align="Left Top Stretch" name="SkillNoProgressDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 44 320 0" align="Left Top" name="SkillNoProgressDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Level tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 58" align="Left Top" name="LevelToolTip">
<Property key="Visible" value="false"/>
<UserString key="DontResize" value="true"/>
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch">
<UserString key="AutoResizeHorizontal" value="true"/>
<Property key="Caption" value="#{sLevelProgress}"/>
<Property key="TextAlign" value="Center"/>
</Widget>
@ -181,43 +180,43 @@
</Widget>
<!-- Birthsign tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="BirthSignToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 300" align="Stretch" name="BirthSignToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<!-- Birthsign image -->
<Widget type="Widget" skin="MW_Box" position="18 13 263 137" align="Top HCenter">
<Widget type="ImageBox" skin="ImageBox" position="2 2 259 133" name="BirthSignImage" align="ALIGN_LEFT ALIGN_TOP" />
</Widget>
<Widget type="TextBox" skin="NormalText" position="8 154 284 138" align="Top Stretch" name="BirthSignText">
<Widget type="AutoSizedTextBox" skin="NormalText" position="8 154 284 138" align="Top" name="BirthSignText">
<Property key="TextAlign" value="Top HCenter"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>
<!-- Magic effect tooltip -->
<Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 52" align="Stretch" name="MagicEffectToolTip">
<Property key="Visible" value="false"/>
<Widget type="VBox" skin="HUD_Box_NoTransp" position="0 0 300 52" align="Stretch" name="MagicEffectToolTip">
<Property key="AutoResize" value="true"/>
<Property key="Padding" value="8"/>
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="MagicEffectImage"/>
<Widget type="HBox">
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="MagicEffectImage"/>
<Widget type="TextBox" skin="NormalText" position="44 8 252 16" align="Left Top HStretch" name="MagicEffectName">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
</Widget>
<Widget type="VBox">
<Widget type="AutoSizedEditBox" skin="NormalText" position="44 8 252 16" align="Left Top" name="MagicEffectName">
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="44 24 252 16" align="Left Top HStretch" name="MagicEffectSchool">
<Property key="TextAlign" value="Left"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<Widget type="AutoSizedEditBox" skin="SandText" position="44 24 252 16" align="Left Top" name="MagicEffectSchool">
<Property key="TextAlign" value="Left"/>
</Widget>
</Widget>
</Widget>
<Widget type="EditBox" skin="SandText" position="8 44 284 0" align="Left Top Stretch" name="MagicEffectDescription">
<Widget type="AutoSizedEditBox" skin="SandText" position="8 44 284 0" align="Left Top" name="MagicEffectDescription">
<Property key="MultiLine" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="TextAlign" value="Left Top"/>
<UserString key="AutoResizeHorizontal" value="true"/>
<UserString key="AutoResizeVertical" value="true"/>
</Widget>
</Widget>

Loading…
Cancel
Save