ui: added universal font size setting and shortcuts for changing it

This change adds font size and font family to the ApplicationSettings to have a single point for manipulating them. The
font size can also be changed via the menu or the zoomIn and zoomOut shortcuts on all platforms.
This commit is contained in:
Eberhard Graether
2015-07-15 00:38:10 +02:00
parent 7275082284
commit fb170cbd5d
46 changed files with 368 additions and 152 deletions
@@ -25,7 +25,7 @@ const uint CodeController::s_lineRadius = 2;
void CodeController::handleMessage(MessageActivateTokens* message)
{
if (message->isIgnorable())
if (message->isEdge && message->isIgnorable())
{
return;
}
@@ -1,8 +1,10 @@
#include "component/controller/FeatureController.h"
#include "utility/messaging/type/MessageActivateTokens.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "data/access/StorageAccess.h"
#include "settings/ApplicationSettings.h"
FeatureController::FeatureController(StorageAccess* storageAccess)
: m_storageAccess(storageAccess)
@@ -85,3 +87,12 @@ void FeatureController::handleMessage(MessageSearch* message)
m.undoRedoType = message->undoRedoType;
m.dispatchImmediately();
}
void FeatureController::handleMessage(MessageZoom* message)
{
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
settings->setFontSize(std::max(settings->getFontSize() + (message->zoomIn ? 1 : -1), 5));
settings->save();
MessageRefresh(true).dispatch();
}
@@ -7,6 +7,7 @@
#include "utility/messaging/type/MessageActivateNode.h"
#include "utility/messaging/type/MessageActivateTokenLocation.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageZoom.h"
#include "component/controller/Controller.h"
@@ -19,6 +20,7 @@ class FeatureController
, public MessageListener<MessageActivateNode>
, public MessageListener<MessageActivateTokenLocation>
, public MessageListener<MessageSearch>
, public MessageListener<MessageZoom>
{
public:
FeatureController(StorageAccess* storageAccess);
@@ -30,6 +32,7 @@ private:
virtual void handleMessage(MessageActivateNode* message);
virtual void handleMessage(MessageActivateTokenLocation* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageZoom* message);
StorageAccess* m_storageAccess;
};
@@ -712,7 +712,7 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
}
subNode.position.x = margins.left + x;
subNode.position.y = margins.top + y;
subNode.position.y = margins.top + margins.charHeight + y;
if (layoutHorizontal)
{
@@ -747,7 +747,7 @@ void GraphController::layoutNestingRecursive(DummyNode& node) const
}
node.size.x = margins.left + width + margins.right;
node.size.y = margins.top + y + height + margins.bottom;
node.size.y = margins.top + margins.charHeight + y + height + margins.bottom;
for (DummyNode& subNode : node.subNodes)
{
@@ -1,5 +1,7 @@
#include "component/controller/RefreshController.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "component/view/RefreshView.h"
RefreshController::RefreshController()
@@ -16,11 +18,6 @@ void RefreshController::handleMessage(MessageAutoRefreshChanged* message)
m_autoRefreshEnabled = message->enabled;
}
void RefreshController::handleMessage(MessageRefresh* message)
{
getView()->refreshView();
}
void RefreshController::handleMessage(MessageWindowFocus* message)
{
if (m_autoRefreshEnabled)
@@ -4,7 +4,6 @@
#include "component/controller/Controller.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageAutoRefreshChanged.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageWindowFocus.h"
class RefreshView;
@@ -12,7 +11,6 @@ class RefreshView;
class RefreshController
: public Controller
, public MessageListener<MessageAutoRefreshChanged>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageWindowFocus>
{
public:
@@ -21,7 +19,6 @@ public:
private:
virtual void handleMessage(MessageAutoRefreshChanged* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageWindowFocus* message);
RefreshView* getView();
@@ -99,6 +99,34 @@ void UndoRedoController::handleMessage(MessageRedo* message)
}
}
void UndoRedoController::handleMessage(MessageRefresh* message)
{
if (!m_lastCommand.message)
{
return;
}
if (m_lastCommand.order > 0)
{
replayCommands(false);
}
std::shared_ptr<MessageBase> msg = m_lastCommand.message;
if (m_undo.size())
{
m_lastCommand = m_undo.back();
m_undo.pop_back();
}
else
{
m_lastCommand.message.reset();
}
msg->undoRedoType = MessageBase::UNDOTYPE_REDO;
msg->dispatch();
}
void UndoRedoController::handleMessage(MessageSearch* message)
{
if (m_lastCommand.message && m_lastCommand.message->getType() == message->getType() &&
@@ -112,6 +140,11 @@ void UndoRedoController::handleMessage(MessageSearch* message)
}
void UndoRedoController::handleMessage(MessageUndo* message)
{
replayCommands(true);
}
void UndoRedoController::replayCommands(bool removeLast)
{
if (!m_undo.empty())
{
@@ -131,8 +164,17 @@ void UndoRedoController::handleMessage(MessageUndo* message)
}
m = m_undo.back().message;
m_undo.pop_back();
m->undoRedoType = MessageBase::UNDOTYPE_UNDO;
if (removeLast)
{
m_undo.pop_back();
m->undoRedoType = MessageBase::UNDOTYPE_UNDO;
}
else
{
m->undoRedoType = MessageBase::UNDOTYPE_IGNORE;
}
m->dispatch();
}
}
@@ -14,6 +14,7 @@
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageLoadSource.h"
#include "utility/messaging/type/MessageRedo.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageUndo.h"
@@ -32,6 +33,7 @@ class UndoRedoController
, public MessageListener<MessageLoadProject>
, public MessageListener<MessageLoadSource>
, public MessageListener<MessageRedo>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageSearch>
, public MessageListener<MessageUndo>
{
@@ -59,9 +61,12 @@ private:
virtual void handleMessage(MessageLoadProject* message);
virtual void handleMessage(MessageLoadSource* message);
virtual void handleMessage(MessageRedo* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageUndo* message);
void replayCommands(bool removeLast);
void processCommand(const Command& command);
void processNormalCommand(const Command& command);
void processRedoCommand(const Command& command);