ui: font size limits
Introduced font size limits and prevent ui refresh beyond those limits. Should prevent UI from freezing up with unlocked mouse wheel.
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
<font_name><!-- STRING: font name --></font_name>
|
||||
<font_size><!-- INTEGER: font size in pt --></font_size>
|
||||
<color_scheme><!-- STRING: color scheme path --></color_scheme>
|
||||
<font_size_max><!-- INTEGER: maximum font size in pt --></font_size_max>
|
||||
<font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min>
|
||||
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
|
||||
</application>
|
||||
|
||||
<code>
|
||||
|
||||
@@ -82,10 +82,11 @@ void FeatureController::handleMessage(MessageActivateTokenLocations* message)
|
||||
void FeatureController::handleMessage(MessageResetZoom* message)
|
||||
{
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
int fontSizeStd = settings->getFontSizeStd();
|
||||
|
||||
if (settings->getFontSize() != 12)
|
||||
if (settings->getFontSize() != fontSizeStd)
|
||||
{
|
||||
settings->setFontSize(12);
|
||||
settings->setFontSize(fontSizeStd);
|
||||
settings->save();
|
||||
|
||||
MessageRefresh().refreshUiOnly().dispatch();
|
||||
@@ -105,13 +106,26 @@ void FeatureController::handleMessage(MessageSwitchColorScheme* message)
|
||||
|
||||
void FeatureController::handleMessage(MessageZoom* message)
|
||||
{
|
||||
bool zoomIn = message->zoomIn;
|
||||
|
||||
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
|
||||
settings->setFontSize(std::max(settings->getFontSize() + (message->zoomIn ? 1 : -1), 5));
|
||||
settings->save();
|
||||
|
||||
int fontSize = settings->getFontSize();
|
||||
int standardSize = 12;
|
||||
int standardSize = settings->getFontSizeStd();
|
||||
int maxSize = settings->getFontSizeMax();
|
||||
int minSize = settings->getFontSizeMin();
|
||||
|
||||
if (fontSize >= maxSize && zoomIn
|
||||
|| fontSize <= minSize && !zoomIn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// settings->setFontSize(std::max(settings->getFontSize() + (message->zoomIn ? 1 : -1), 5));
|
||||
settings->setFontSize((settings->getFontSize() + (message->zoomIn ? 1 : -1)));
|
||||
settings->save();
|
||||
|
||||
fontSize = settings->getFontSize();
|
||||
int zoom = (fontSize * 100) / standardSize;
|
||||
|
||||
std::stringstream text;
|
||||
|
||||
@@ -87,6 +87,36 @@ void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath)
|
||||
setValue<std::string>("application/color_scheme", colorSchemePath);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSizeMax() const
|
||||
{
|
||||
return getValue<int>("application/font_size_max", 24);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setFontSizeMax(const int fontSizeMax)
|
||||
{
|
||||
setValue<int>("application/font_size_max", fontSizeMax);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSizeMin() const
|
||||
{
|
||||
return getValue<int>("application/font_size_min", 4);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setFontSizeMin(const int fontSizeMin)
|
||||
{
|
||||
setValue<int>("application/font_size_min", fontSizeMin);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getFontSizeStd() const
|
||||
{
|
||||
return getValue<int>("application/font_size_std", 12);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setFontSizeStd(const int fontSizeStd)
|
||||
{
|
||||
setValue<int>("application/font_size_std", fontSizeStd);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
{
|
||||
return getValue<int>("code/tab_width", 4);
|
||||
|
||||
@@ -38,6 +38,15 @@ public:
|
||||
std::string getColorSchemePath() const;
|
||||
void setColorSchemePath(const std::string& colorSchemePath);
|
||||
|
||||
int getFontSizeMax() const;
|
||||
void setFontSizeMax(const int fontSizeMax);
|
||||
|
||||
int getFontSizeMin() const;
|
||||
void setFontSizeMin(const int fontSizeMin);
|
||||
|
||||
int getFontSizeStd() const;
|
||||
void setFontSizeStd(const int fontSizeStd);
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
void setCodeTabWidth(int codeTabWidth);
|
||||
|
||||
@@ -28,7 +28,7 @@ void TaskParseCxx::exit()
|
||||
{
|
||||
m_client->finishParsing();
|
||||
|
||||
MessageFinishedParsing(0, 0, 0, 0).dispatch();
|
||||
MessageFinishedParsing(0, 0, 0, ErrorCountInfo()).dispatch();
|
||||
}
|
||||
|
||||
void TaskParseCxx::interrupt()
|
||||
|
||||
Reference in New Issue
Block a user