mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Fix window formatting on tool tip with too log titles
This commit is contained in:
parent
4e4d15f8ac
commit
7e7e6e2bcb
2 changed files with 32 additions and 6 deletions
|
@ -31,6 +31,7 @@ ToolTips::ToolTips(MWBase::WindowManager* windowManager) :
|
|||
, mRemainingDelay(0.0)
|
||||
, mLastMouseX(0)
|
||||
, mLastMouseY(0)
|
||||
, mHorizontalScrollIndex(0)
|
||||
{
|
||||
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
|
||||
|
||||
|
@ -52,6 +53,7 @@ void ToolTips::setEnabled(bool enabled)
|
|||
|
||||
void ToolTips::onFrame(float frameDuration)
|
||||
{
|
||||
|
||||
while (mDynamicToolTipBox->getChildCount())
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0));
|
||||
|
@ -103,7 +105,7 @@ void ToolTips::onFrame(float frameDuration)
|
|||
|
||||
else
|
||||
{
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
const MyGUI::IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
||||
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
|
||||
return;
|
||||
|
@ -114,11 +116,13 @@ void ToolTips::onFrame(float frameDuration)
|
|||
}
|
||||
else
|
||||
{
|
||||
mHorizontalScrollIndex = 0;
|
||||
mRemainingDelay = mDelay;
|
||||
}
|
||||
mLastMouseX = mousePos.left;
|
||||
mLastMouseY = mousePos.top;
|
||||
|
||||
|
||||
if (mRemainingDelay > 0)
|
||||
return;
|
||||
|
||||
|
@ -149,6 +153,7 @@ void ToolTips::onFrame(float frameDuration)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
// special handling for markers on the local map: the tooltip should only be visible
|
||||
// if the marker is not hidden due to the fog of war.
|
||||
if (focus->getUserString ("IsMarker") == "true")
|
||||
|
@ -384,6 +389,8 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
|
||||
const IntPoint padding(8, 8);
|
||||
|
||||
const int maximumWidth = 500;
|
||||
|
||||
const int imageCaptionHPadding = (caption != "" ? 8 : 0);
|
||||
const int imageCaptionVPadding = (caption != "" ? 4 : 0);
|
||||
|
||||
|
@ -406,7 +413,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
IntSize textSize = textWidget->getTextSize();
|
||||
|
||||
captionSize += IntSize(imageSize, 0); // adjust for image
|
||||
IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),
|
||||
IntSize totalSize = IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
|
||||
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
|
||||
if (!info.effects.empty())
|
||||
|
@ -495,7 +502,23 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
|
|||
captionSize.width-imageSize,
|
||||
captionSize.height);
|
||||
|
||||
captionWidget->setPosition (captionWidget->getPosition() + padding);
|
||||
//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));
|
||||
} else {
|
||||
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
|
||||
|
||||
if (image != "")
|
||||
|
|
|
@ -91,6 +91,9 @@ namespace MWGui
|
|||
float mFocusToolTipX;
|
||||
float mFocusToolTipY;
|
||||
|
||||
int mHorizontalScrollIndex;
|
||||
|
||||
|
||||
float mDelay;
|
||||
float mRemainingDelay; // remaining time until tooltip will show
|
||||
|
||||
|
|
Loading…
Reference in a new issue