diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-29 10:55:38 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-31 11:30:20 +0200 |
commit | 7df86c159a1c069cd1ffb59f8ec3f4273b84c42a (patch) | |
tree | a92fbd123e94d4d97584344eb598661b7302305f /src/gui/widgets/browserbox.cpp | |
parent | e2fb719501c41356f632e6f8838c91d888239037 (diff) | |
download | mana-7df86c159a1c069cd1ffb59f8ec3f4273b84c42a.tar.gz mana-7df86c159a1c069cd1ffb59f8ec3f4273b84c42a.tar.bz2 mana-7df86c159a1c069cd1ffb59f8ec3f4273b84c42a.tar.xz mana-7df86c159a1c069cd1ffb59f8ec3f4273b84c42a.zip |
Some margin and indentation tweaks in news and NPC dialogs
* Apply indentation after wrapping only in NPC dialogs and chat window,
since we don't want this in the updater window / news.
* Added some margin around the text in the updater window and NPC
dialogs, using gcn::Widget::setFrameSize.
* Cosmetic changes to BrowserBox implementation.
Diffstat (limited to 'src/gui/widgets/browserbox.cpp')
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 7b77721c..a0c361d0 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -66,7 +66,7 @@ LayoutContext::LayoutContext(gcn::Font *font) } -BrowserBox::BrowserBox(unsigned int mode): +BrowserBox::BrowserBox(Mode mode): mMode(mode) { setFocusable(true); @@ -148,15 +148,10 @@ void BrowserBox::addRow(const std::string &row) for (auto &row : mTextRows) { for (auto &part : row.parts) - { part.y -= removedHeight; - } for (auto &link : row.links) - { - link.y1 -= removedHeight; - link.y2 -= removedHeight; - } + link.rect.y -= removedHeight; } } @@ -207,25 +202,21 @@ void BrowserBox::draw(gcn::Graphics *graphics) { auto &link = *mHoveredLink; + const gcn::Rectangle &rect = link.rect; + if (mHighlightMode & BACKGROUND) { graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT)); - graphics->fillRectangle(gcn::Rectangle( - link.x1, - link.y1, - link.x2 - link.x1, - link.y2 - link.y1 - )); + graphics->fillRectangle(rect); } if (mHighlightMode & UNDERLINE) { graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK)); - graphics->drawLine( - link.x1, - link.y2, - link.x2, - link.y2); + graphics->drawLine(rect.x, + rect.y + rect.height, + rect.x + rect.width, + rect.y + rect.height); } } @@ -332,7 +323,7 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) if (wrapped) { context.y += context.lineHeight; - x = 15; + x = mWrapIndent; wrapped = false; } @@ -388,12 +379,11 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) if (c == '<' && linkIndex < row.links.size()) { auto &link = row.links[linkIndex]; - const int size = context.font->getWidth(link.caption) + 1; - link.x1 = x; - link.y1 = context.y; - link.x2 = link.x1 + size; - link.y2 = context.y + context.fontHeight - 1; + link.rect.x = x; + link.rect.y = context.y; + link.rect.width = context.font->getWidth(link.caption) + 1; + link.rect.height = context.fontHeight - 1; linkIndex++; } @@ -416,7 +406,7 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) // Auto wrap mode if (mMode == AUTO_WRAP && getWidth() > 0 && partWidth > 0 - && (x + partWidth + 10) > getWidth()) + && (x + partWidth) > getWidth()) { bool forced = false; @@ -447,7 +437,7 @@ void BrowserBox::layoutTextRow(TextRow &row, LayoutContext &context) partWidth = context.font->getWidth(part); } while (end > start && partWidth > 0 - && (x + partWidth + 10) > getWidth()); + && (x + partWidth) > getWidth()); if (forced) { |