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"); mDelay = Settings::Manager::getFloat("tooltip delay", "GUI");
mRemainingDelay = mDelay; mRemainingDelay = mDelay;
for (unsigned int i=0; i < mMainWidget->getChildCount(); ++i)
{
mMainWidget->getChildAt(i)->setVisible(false);
}
} }
void ToolTips::setEnabled(bool enabled) void ToolTips::setEnabled(bool enabled)
@ -115,7 +120,7 @@ void ToolTips::onFrame(float frameDuration)
} }
else else
{ {
mHorizontalScrollIndex = 0; mHorizontalScrollIndex = 0;
mRemainingDelay = mDelay; mRemainingDelay = mDelay;
} }
mLastMouseX = mousePos.left; mLastMouseX = mousePos.left;
@ -215,14 +220,6 @@ void ToolTips::onFrame(float frameDuration)
getWidget(tooltip, focus->getUserString("ToolTipLayout")); getWidget(tooltip, focus->getUserString("ToolTipLayout"));
tooltip->setVisible(true); 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(); std::map<std::string, std::string> userStrings = focus->getUserStrings();
for (std::map<std::string, std::string>::iterator it = userStrings.begin(); 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); w->setProperty(propertyKey, it->second);
} }
for (unsigned int i=0; i<tooltip->getChildCount(); ++i) tooltipSize = tooltip->getSize();
{
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);
}
}
}
tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height); tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height);
} }
else else
@ -509,20 +482,21 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
captionSize.height); captionSize.height);
//if its too long we do hscroll with the caption //if its too long we do hscroll with the caption
if (captionSize.width > maximumWidth){ if (captionSize.width > maximumWidth)
mHorizontalScrollIndex = mHorizontalScrollIndex + 2; {
if (mHorizontalScrollIndex > captionSize.width){ mHorizontalScrollIndex = mHorizontalScrollIndex + 2;
mHorizontalScrollIndex = -totalSize.width; if (mHorizontalScrollIndex > captionSize.width){
} mHorizontalScrollIndex = -totalSize.width;
int horizontal_scroll = mHorizontalScrollIndex; }
if (horizontal_scroll < 40){ int horizontal_scroll = mHorizontalScrollIndex;
horizontal_scroll = 40; if (horizontal_scroll < 40){
}else{ horizontal_scroll = 40;
horizontal_scroll = 80 - mHorizontalScrollIndex; }else{
} horizontal_scroll = 80 - mHorizontalScrollIndex;
captionWidget->setPosition (IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top)); }
captionWidget->setPosition (IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top));
} else { } 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 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() 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); return MyGUI::IntSize(getSize().width, getTextSize().height);
} }

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

Loading…
Cancel
Save