From 8889bb4758fb888df93df73f9ada0f751e4914f7 Mon Sep 17 00:00:00 2001 From: codereader Date: Wed, 2 Dec 2020 15:11:58 +0100 Subject: [PATCH] #5436: Add preference option for the XYWnd font size --- install/user.xml | 1 + radiant/xyview/GlobalXYWnd.cpp | 15 +++++++++++++++ radiant/xyview/GlobalXYWnd.h | 2 ++ radiant/xyview/XYWnd.cpp | 9 ++++++++- radiant/xyview/XYWnd.h | 2 ++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/install/user.xml b/install/user.xml index 00e413defe..bef113a9b5 100644 --- a/install/user.xml +++ b/install/user.xml @@ -158,6 +158,7 @@ + diff --git a/radiant/xyview/GlobalXYWnd.cpp b/radiant/xyview/GlobalXYWnd.cpp index 61ac220b52..ea7f89df7c 100644 --- a/radiant/xyview/GlobalXYWnd.cpp +++ b/radiant/xyview/GlobalXYWnd.cpp @@ -45,6 +45,7 @@ namespace const std::string RKEY_SHOW_WORKZONE = RKEY_XYVIEW_ROOT + "/showWorkzone"; const std::string RKEY_DEFAULT_BLOCKSIZE = "user/ui/xyview/defaultBlockSize"; const std::string RKEY_TRANSLATE_CONSTRAINED = "user/ui/xyview/translateConstrained"; + const std::string RKEY_FONT_SIZE = "user/ui/xyview/fontSize"; const int DEFAULT_CHASE_MOUSE_CAP = 32; // pixels per chase moue timer interval } @@ -198,6 +199,7 @@ void XYWndManager::constructPreferences() page.appendCheckBox(_("Show Workzone"), RKEY_SHOW_WORKZONE); page.appendCheckBox(_("Translate Manipulator always constrained to Axis"), RKEY_TRANSLATE_CONSTRAINED); page.appendCheckBox(_("Higher Selection Priority for Entities"), RKEY_HIGHER_ENTITY_PRIORITY); + page.appendSpinner(_("Font Size"), RKEY_FONT_SIZE, 4, 48, 0); } // Load/Reload the values from the registry @@ -215,7 +217,14 @@ void XYWndManager::refreshFromRegistry() _showAxes = registry::getValue(RKEY_SHOW_AXES); _showWorkzone = registry::getValue(RKEY_SHOW_WORKZONE); _defaultBlockSize = registry::getValue(RKEY_DEFAULT_BLOCKSIZE); + _fontSize = registry::getValue(RKEY_FONT_SIZE); + updateAllViews(); + + for (const auto& xyWnd : _xyWnds) + { + xyWnd.second->updateFont(); + } } bool XYWndManager::chaseMouse() const { @@ -267,6 +276,11 @@ bool XYWndManager::showSizeInfo() const { return _showSizeInfo; } +int XYWndManager::fontSize() const +{ + return _fontSize; +} + void XYWndManager::updateAllViews(bool force) { for (const XYWndMap::value_type& i : _xyWnds) @@ -667,6 +681,7 @@ void XYWndManager::initialiseModule(const IApplicationContext& ctx) observeKey(RKEY_SHOW_AXES); observeKey(RKEY_SHOW_WORKZONE); observeKey(RKEY_DEFAULT_BLOCKSIZE); + observeKey(RKEY_FONT_SIZE); // Trigger loading the values of the observed registry keys refreshFromRegistry(); diff --git a/radiant/xyview/GlobalXYWnd.h b/radiant/xyview/GlobalXYWnd.h index eef27a54f6..5de88e70b9 100644 --- a/radiant/xyview/GlobalXYWnd.h +++ b/radiant/xyview/GlobalXYWnd.h @@ -43,6 +43,7 @@ class XYWndManager : bool _showWorkzone; unsigned int _defaultBlockSize; + int _fontSize; private: @@ -68,6 +69,7 @@ class XYWndManager : bool showAxes() const; bool showWorkzone() const; bool showSizeInfo() const; + int fontSize() const; unsigned int defaultBlockSize() const; diff --git a/radiant/xyview/XYWnd.cpp b/radiant/xyview/XYWnd.cpp index 0476fbce5a..bfc9136432 100644 --- a/radiant/xyview/XYWnd.cpp +++ b/radiant/xyview/XYWnd.cpp @@ -233,7 +233,7 @@ void XYWnd::releaseStates() void XYWnd::ensureFont() { - _font = GlobalOpenGL().getFont(IGLFont::Style::Sans, 14); + _font = GlobalOpenGL().getFont(IGLFont::Style::Sans, GlobalXYWnd().fontSize()); } const std::string XYWnd::getViewTypeTitle(EViewType viewtype) { @@ -288,6 +288,13 @@ void XYWnd::onSceneGraphChange() { queueDraw(); } +void XYWnd::updateFont() +{ + // Clear out the font reference, it will be re-acquired + // during the next draw call + _font.reset(); +} + void XYWnd::setActive(bool b) { _isActive = b; }; diff --git a/radiant/xyview/XYWnd.h b/radiant/xyview/XYWnd.h index 4fa3d9c2ab..63951ed6a3 100644 --- a/radiant/xyview/XYWnd.h +++ b/radiant/xyview/XYWnd.h @@ -154,6 +154,8 @@ class XYWnd : // greebo: This gets called upon scene change void onSceneGraphChange() override; + void updateFont(); + protected: // Disconnects all widgets and unsubscribes as observer void destroyXYView();