[Scummvm-git-logs] scummvm branch-2-7 -> df02a71cd49b4a71c60c07235740f26592df922a

sev- noreply at scummvm.org
Sun Mar 26 12:20:29 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
df02a71cd4 GUI: Added close button to the TextViewer dialog


Commit: df02a71cd49b4a71c60c07235740f26592df922a
    https://github.com/scummvm/scummvm/commit/df02a71cd49b4a71c60c07235740f26592df922a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-03-26T14:20:01+02:00

Commit Message:
GUI: Added close button to the TextViewer dialog

Changed paths:
    gui/textviewer.cpp
    gui/textviewer.h
    po/POTFILES


diff --git a/gui/textviewer.cpp b/gui/textviewer.cpp
index c3a7b386c1b..30e54c17a98 100644
--- a/gui/textviewer.cpp
+++ b/gui/textviewer.cpp
@@ -21,6 +21,7 @@
 
 #include "common/file.h"
 #include "common/tokenizer.h"
+#include "common/translation.h"
 
 #include "graphics/font.h"
 #include "graphics/fontman.h"
@@ -45,10 +46,12 @@ TextViewerDialog::TextViewerDialog(Common::String fname)
 	_lineHeight = _font->getFontHeight() + 2;
 
 	// Add scrollbar
-	_scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
-	_scrollBar = new ScrollBarWidget(this, _w - _scrollbarWidth - 1, 0, _scrollbarWidth, _h);
+	_scrollBar = new ScrollBarWidget(this, 0, 0, 1, 1);
 	_scrollBar->setTarget(this);
 
+	// I18N: Close dialog button
+	_closeButton = new ButtonWidget(this, 0, 0, 1, 1, _("Close"), Common::U32String(), kCloseCmd);
+
 	_currentPos = 0;
 	_scrollLine = _linesPerPage - 1;
 
@@ -107,12 +110,25 @@ void TextViewerDialog::reflowLayout() {
 	_padX = _w * kPadX;
 	_padY = _h * kPadY;
 
+	int16 bW = g_gui.xmlEval()->getVar("Globals.Button.Width", 0);
+	int16 bH = g_gui.xmlEval()->getVar("Globals.Button.Height", 0);
+	int16 padR = g_gui.xmlEval()->getVar("Globals.Padding.Right", 5);
+	int16 padB = g_gui.xmlEval()->getVar("Globals.Padding.Bottom", 5);
+	int16 scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
+
+	int16 buttonOffset = bH + padB;
+
+	_closeButton->setPos(_w - bW - padR, _h - buttonOffset);
+	_closeButton->setSize(bW, bH);
+
 	// Calculate depending values
-	_lineWidth = (_w - _scrollbarWidth - _padX * 2) / _charWidth;
-	_linesPerPage = (_h - _padY * 2) / _lineHeight;
+	_lineWidth = (_w - scrollbarWidth - _padX * 2) / _charWidth;
+	_linesPerPage = (_h - _padY * 2 - buttonOffset) / _lineHeight;
 
-	_scrollBar->setPos(_w - _scrollbarWidth - 1, 0);
-	_scrollBar->setSize(_scrollbarWidth, _h);
+	warning("Lines: %d", _linesPerPage);
+
+	_scrollBar->setPos(_w - scrollbarWidth - 1, 0);
+	_scrollBar->setSize(scrollbarWidth, _h - buttonOffset);
 }
 
 void TextViewerDialog::open() {
@@ -167,6 +183,9 @@ void TextViewerDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 d
 
 		drawDialog(kDrawLayerForeground);
 		break;
+	case kCloseCmd:
+		close();
+		break;
 	default:
 		return;
 	}
diff --git a/gui/textviewer.h b/gui/textviewer.h
index d12acee8099..250c1a82e1b 100644
--- a/gui/textviewer.h
+++ b/gui/textviewer.h
@@ -42,7 +42,6 @@ private:
 	int	_currentPos;
 	int	_scrollLine;
 
-	int _scrollbarWidth;
 	int _charWidth;
 	int _lineHeight;
 	int _padX, _padY;
@@ -50,6 +49,7 @@ private:
 	Common::StringArray _linesArray;
 
 	ScrollBarWidget *_scrollBar;
+	ButtonWidget *_closeButton;
 
 	Common::String _fname;
 	const Graphics::Font *_font = nullptr;
diff --git a/po/POTFILES b/po/POTFILES
index e6deb0d17f5..8d877da3faf 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -20,6 +20,7 @@ gui/recorderdialog.cpp
 gui/remotebrowser.cpp
 gui/saveload-dialog.cpp
 gui/shaderbrowser-dialog.cpp
+gui/textviewer.cpp
 gui/themebrowser.cpp
 gui/ThemeEngine.cpp
 gui/unknown-game-dialog.cpp




More information about the Scummvm-git-logs mailing list