Skip to content

Commit

Permalink
#5436: Add preference option for the XYWnd font size
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 2, 2020
1 parent ce89bf0 commit 8889bb4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions install/user.xml
Expand Up @@ -158,6 +158,7 @@
<showOutline value="0" />
<showAxes value="1" />
<showWorkzone value="0" />
<fontSize value="14" />
<overlay>
<visible value="0" />
<transparency value="0.3" />
Expand Down
15 changes: 15 additions & 0 deletions radiant/xyview/GlobalXYWnd.cpp
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -215,7 +217,14 @@ void XYWndManager::refreshFromRegistry()
_showAxes = registry::getValue<bool>(RKEY_SHOW_AXES);
_showWorkzone = registry::getValue<bool>(RKEY_SHOW_WORKZONE);
_defaultBlockSize = registry::getValue<int>(RKEY_DEFAULT_BLOCKSIZE);
_fontSize = registry::getValue<int>(RKEY_FONT_SIZE);

updateAllViews();

for (const auto& xyWnd : _xyWnds)
{
xyWnd.second->updateFont();
}
}

bool XYWndManager::chaseMouse() const {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions radiant/xyview/GlobalXYWnd.h
Expand Up @@ -43,6 +43,7 @@ class XYWndManager :
bool _showWorkzone;

unsigned int _defaultBlockSize;
int _fontSize;

private:

Expand All @@ -68,6 +69,7 @@ class XYWndManager :
bool showAxes() const;
bool showWorkzone() const;
bool showSizeInfo() const;
int fontSize() const;

unsigned int defaultBlockSize() const;

Expand Down
9 changes: 8 additions & 1 deletion radiant/xyview/XYWnd.cpp
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
};
Expand Down
2 changes: 2 additions & 0 deletions radiant/xyview/XYWnd.h
Expand Up @@ -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();
Expand Down

0 comments on commit 8889bb4

Please sign in to comment.