Skip to content

Commit

Permalink
#5436: XYWnd font style is selectable too
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 2, 2020
1 parent 8889bb4 commit 8f1b717
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions install/user.xml
Expand Up @@ -159,6 +159,7 @@
<showAxes value="1" />
<showWorkzone value="0" />
<fontSize value="14" />
<fontStyle value="Sans" />
<overlay>
<visible value="0" />
<transparency value="0.3" />
Expand Down
9 changes: 9 additions & 0 deletions radiant/xyview/GlobalXYWnd.cpp
Expand Up @@ -46,6 +46,7 @@ namespace
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 std::string RKEY_FONT_STYLE = "user/ui/xyview/fontStyle";

const int DEFAULT_CHASE_MOUSE_CAP = 32; // pixels per chase moue timer interval
}
Expand Down Expand Up @@ -199,6 +200,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.appendCombo(_("Font Style"), RKEY_FONT_STYLE, { "Sans", "Mono" }, true);
page.appendSpinner(_("Font Size"), RKEY_FONT_SIZE, 4, 48, 0);
}

Expand All @@ -218,6 +220,7 @@ void XYWndManager::refreshFromRegistry()
_showWorkzone = registry::getValue<bool>(RKEY_SHOW_WORKZONE);
_defaultBlockSize = registry::getValue<int>(RKEY_DEFAULT_BLOCKSIZE);
_fontSize = registry::getValue<int>(RKEY_FONT_SIZE);
_fontStyle = registry::getValue<std::string>(RKEY_FONT_STYLE) == "Sans" ? IGLFont::Style::Sans : IGLFont::Style::Mono;

updateAllViews();

Expand Down Expand Up @@ -281,6 +284,11 @@ int XYWndManager::fontSize() const
return _fontSize;
}

IGLFont::Style XYWndManager::fontStyle() const
{
return _fontStyle;
}

void XYWndManager::updateAllViews(bool force)
{
for (const XYWndMap::value_type& i : _xyWnds)
Expand Down Expand Up @@ -682,6 +690,7 @@ void XYWndManager::initialiseModule(const IApplicationContext& ctx)
observeKey(RKEY_SHOW_WORKZONE);
observeKey(RKEY_DEFAULT_BLOCKSIZE);
observeKey(RKEY_FONT_SIZE);
observeKey(RKEY_FONT_STYLE);

// Trigger loading the values of the observed registry keys
refreshFromRegistry();
Expand Down
2 changes: 2 additions & 0 deletions radiant/xyview/GlobalXYWnd.h
Expand Up @@ -44,6 +44,7 @@ class XYWndManager :

unsigned int _defaultBlockSize;
int _fontSize;
IGLFont::Style _fontStyle;

private:

Expand All @@ -70,6 +71,7 @@ class XYWndManager :
bool showWorkzone() const;
bool showSizeInfo() const;
int fontSize() const;
IGLFont::Style fontStyle() const;

unsigned int defaultBlockSize() const;

Expand Down
3 changes: 2 additions & 1 deletion radiant/xyview/XYWnd.cpp
Expand Up @@ -233,7 +233,8 @@ void XYWnd::releaseStates()

void XYWnd::ensureFont()
{
_font = GlobalOpenGL().getFont(IGLFont::Style::Sans, GlobalXYWnd().fontSize());
const auto& manager = GlobalXYWnd();
_font = GlobalOpenGL().getFont(manager.fontStyle(), manager.fontSize());
}

const std::string XYWnd::getViewTypeTitle(EViewType viewtype) {
Expand Down

0 comments on commit 8f1b717

Please sign in to comment.