1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 05:53:50 +00:00

Fix window formatting on tool tip with too log titles

This commit is contained in:
eduard 2012-12-02 14:08:22 +01:00
parent 4e4d15f8ac
commit 7e7e6e2bcb
2 changed files with 32 additions and 6 deletions

View file

@ -31,6 +31,7 @@ ToolTips::ToolTips(MWBase::WindowManager* windowManager) :
, mRemainingDelay(0.0) , mRemainingDelay(0.0)
, mLastMouseX(0) , mLastMouseX(0)
, mLastMouseY(0) , mLastMouseY(0)
, mHorizontalScrollIndex(0)
{ {
getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
@ -52,6 +53,7 @@ void ToolTips::setEnabled(bool enabled)
void ToolTips::onFrame(float frameDuration) void ToolTips::onFrame(float frameDuration)
{ {
while (mDynamicToolTipBox->getChildCount()) while (mDynamicToolTipBox->getChildCount())
{ {
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0));
@ -103,7 +105,7 @@ void ToolTips::onFrame(float frameDuration)
else 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 if (mousePos == lastPressed) // mouseclick makes tooltip disappear
return; return;
@ -114,11 +116,13 @@ void ToolTips::onFrame(float frameDuration)
} }
else else
{ {
mHorizontalScrollIndex = 0;
mRemainingDelay = mDelay; mRemainingDelay = mDelay;
} }
mLastMouseX = mousePos.left; mLastMouseX = mousePos.left;
mLastMouseY = mousePos.top; mLastMouseY = mousePos.top;
if (mRemainingDelay > 0) if (mRemainingDelay > 0)
return; return;
@ -149,6 +153,7 @@ void ToolTips::onFrame(float frameDuration)
return; return;
} }
// special handling for markers on the local map: the tooltip should only be visible // 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 the marker is not hidden due to the fog of war.
if (focus->getUserString ("IsMarker") == "true") if (focus->getUserString ("IsMarker") == "true")
@ -384,6 +389,8 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
const IntPoint padding(8, 8); const IntPoint padding(8, 8);
const int maximumWidth = 500;
const int imageCaptionHPadding = (caption != "" ? 8 : 0); const int imageCaptionHPadding = (caption != "" ? 8 : 0);
const int imageCaptionVPadding = (caption != "" ? 4 : 0); const int imageCaptionVPadding = (caption != "" ? 4 : 0);
@ -406,7 +413,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
IntSize textSize = textWidget->getTextSize(); IntSize textSize = textWidget->getTextSize();
captionSize += IntSize(imageSize, 0); // adjust for image 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 ); ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
if (!info.effects.empty()) if (!info.effects.empty())
@ -495,7 +502,23 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
captionSize.width-imageSize, captionSize.width-imageSize,
captionSize.height); 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 textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter
if (image != "") if (image != "")

View file

@ -91,6 +91,9 @@ namespace MWGui
float mFocusToolTipX; float mFocusToolTipX;
float mFocusToolTipY; float mFocusToolTipY;
int mHorizontalScrollIndex;
float mDelay; float mDelay;
float mRemainingDelay; // remaining time until tooltip will show float mRemainingDelay; // remaining time until tooltip will show