1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Merge pull request #5199 from Laserlicht/fix_long_texts

[1.6.x] fix long texts in popup
This commit is contained in:
Ivan Savenko
2025-01-04 22:24:43 +02:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -28,6 +28,7 @@
#include "../../lib/texts/TextOperations.h" #include "../../lib/texts/TextOperations.h"
constexpr int RIGHT_CLICK_POPUP_MIN_SIZE = 100; constexpr int RIGHT_CLICK_POPUP_MIN_SIZE = 100;
constexpr int RIGHT_CLICK_POPUP_MAX_HEIGHT_TEXTONLY = 450;
constexpr int SIDE_MARGIN = 11; constexpr int SIDE_MARGIN = 11;
constexpr int TOP_MARGIN = 20; constexpr int TOP_MARGIN = 20;
constexpr int BOTTOM_MARGIN = 16; constexpr int BOTTOM_MARGIN = 16;
@@ -260,9 +261,11 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, PlayerColor play
if(ret->buttons.empty() && !ret->components) if(ret->buttons.empty() && !ret->components)
{ {
// use more compact form for right-click popup with no buttons / components // use more compact form for right-click popup with no buttons / components
if(ret->text->slider)
ret->text->resize(Point(ret->text->pos.w, std::min(ret->text->label->textSize.y, RIGHT_CLICK_POPUP_MAX_HEIGHT_TEXTONLY)));
ret->pos.w = std::max(RIGHT_CLICK_POPUP_MIN_SIZE, ret->text->label->textSize.x + 2 * SIDE_MARGIN); ret->pos.w = std::max(RIGHT_CLICK_POPUP_MIN_SIZE, ret->text->pos.w + 2 * SIDE_MARGIN);
ret->pos.h = std::max(RIGHT_CLICK_POPUP_MIN_SIZE, ret->text->label->textSize.y + TOP_MARGIN + BOTTOM_MARGIN); ret->pos.h = std::max(RIGHT_CLICK_POPUP_MIN_SIZE, ret->text->pos.h + TOP_MARGIN + BOTTOM_MARGIN);
} }
else else
{ {

View File

@@ -408,6 +408,7 @@ TeleporterPopup::TeleporterPopup(const Point & position, const CGTeleport * tele
} }
center(position); center(position);
fitToScreen(10);
} }
std::shared_ptr<WindowBase> std::shared_ptr<WindowBase>