diff options
-rw-r--r-- | UIManager.cpp | 15 | ||||
-rw-r--r-- | UIManager.h | 13 | ||||
-rw-r--r-- | Window.cpp | 13 | ||||
-rw-r--r-- | Window.h | 2 |
4 files changed, 34 insertions, 9 deletions
diff --git a/UIManager.cpp b/UIManager.cpp index d6216fd..c1b1e45 100644 --- a/UIManager.cpp +++ b/UIManager.cpp @@ -1,4 +1,5 @@ #include "UIManager.h" +#include "Window.h" const gchar* const UIManager::uiData = (const gchar*) @@ -23,12 +24,14 @@ const gchar* const UIManager::uiData = (const gchar*) void UIManager::handleAction(GtkAction *action, UIManager *uiManager) { - //const gchar* name = gtk_action_get_name(action); + const gchar* name = gtk_action_get_name(action); - /*if(!strcmp(name, "zoomIn")) - zoomInCentered(1.2f); + if(!strcmp(name, "zoomIn")) + uiManager->window->handleAction(ZOOM_IN); + //zoomInCentered(1.2f); else if(!strcmp(name, "zoomOut")) - zoomOutCentered(1.2f);*/ + uiManager->window->handleAction(ZOOM_OUT); + //zoomOutCentered(1.2f); } GtkActionGroup* UIManager::createActions() { @@ -77,7 +80,9 @@ GtkActionGroup* UIManager::createActions() { return actionGroup; } -UIManager::UIManager() { +UIManager::UIManager(Window *window) { + this->window = window; + uiManager = gtk_ui_manager_new(); gtk_ui_manager_add_ui_from_string(uiManager, uiData, -1, NULL); diff --git a/UIManager.h b/UIManager.h index 09000ac..4d833e0 100644 --- a/UIManager.h +++ b/UIManager.h @@ -4,18 +4,27 @@ #include <gtk/gtk.h> +class Window; + + class UIManager { private: static const gchar* const uiData; GtkUIManager *uiManager; + Window *window; + + GtkActionGroup* createActions(); static void handleAction(GtkAction *action, UIManager *uiManager); - GtkActionGroup* createActions(); public: - UIManager(); + enum Action { + ZOOM_IN, ZOOM_OUT + }; + + UIManager(Window *window); virtual ~UIManager(); GtkWidget* getMenu() { @@ -11,7 +11,7 @@ gboolean Window::deleteEvent(GtkWidget *widget, GdkEvent *event, Window *window) } Window::Window(GdkGLConfig *glconfig, WindowManager *manager) - : editor(this), drawer(this, glconfig), sidebar(&editor) + : uiManager(this), editor(this), drawer(this, glconfig), sidebar(&editor) { this->manager = manager; @@ -50,3 +50,14 @@ void Window::update() { drawer.update(); sidebar.update(); } + +void Window::handleAction(UIManager::Action action) { + switch(action) { + case UIManager::ZOOM_IN: + drawer.zoom(2); + break; + + case UIManager::ZOOM_OUT: + drawer.zoom(-2); + } +} @@ -38,8 +38,8 @@ class Window { virtual ~Window(); void show(); - void update(); + void handleAction(UIManager::Action action); EditManager& getEditManager() { return editor; |