From 4a8e3193a9c44292df6458fc63106b4605179f6e Mon Sep 17 00:00:00 2001 From: Ryan Huffman <ryanhuffman@gmail.com> Date: Thu, 19 Feb 2015 12:01:27 -0800 Subject: [PATCH] Add more comments to UIUtil::scaleWidgetFontSizes --- interface/src/UIUtil.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/interface/src/UIUtil.cpp b/interface/src/UIUtil.cpp index c907c2b8e9..19d3a51917 100644 --- a/interface/src/UIUtil.cpp +++ b/interface/src/UIUtil.cpp @@ -37,6 +37,12 @@ int UIUtil::getWindowTitleBarHeight(const QWidget* window) { // font sizes need to be scaled based on the system DPI. // This function will scale the font size of widget and all // of its children recursively. +// +// When creating widgets, if a font size isn't explicitly set Qt will choose a +// reasonable, but often different font size across platforms. This means +// YOU SHOUD EXPLICITLY SET ALL FONT SIZES and call this function OR not use +// this function at all. If you mix both you will end up with inconsistent results +// across platforms. void UIUtil::scaleWidgetFontSizes(QWidget* widget) { auto glCanvas = DependencyManager::get<GLCanvas>(); @@ -57,6 +63,8 @@ void UIUtil::scaleWidgetFontSizes(QWidget* widget) { internalScaleWidgetFontSizes(widget, fontScale); } +// Depth-first traversal through widget hierarchy. It is important to do a depth-first +// traversal because modifying the font size of a parent node can affect children. void UIUtil::internalScaleWidgetFontSizes(QWidget* widget, float scale) { for (auto child : widget->findChildren<QWidget*>()) { if (child->parent() == widget) {