#include "SidebarManager.h" SidebarManager::SidebarManager(EditManager *editor) : sidebarToolbox(editor), sidebarView(editor), sidebarAdd(editor), toolAddPolygon(editor) { this->editor = editor; activeSidebar = NULL; sidebar = gtk_vbox_new(FALSE, 0); g_object_ref_sink(G_OBJECT(sidebar)); gtk_box_pack_start(GTK_BOX(sidebar), sidebarToolbox.getWidget(), FALSE, FALSE, 0); scrolledWindow = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_box_pack_end_defaults(GTK_BOX(sidebar), scrolledWindow); gtk_widget_show(scrolledWindow); viewport = gtk_viewport_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(scrolledWindow), viewport); gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); sidebarToolbox.addTool(&toolAddPolygon); gtk_widget_show(sidebar); } SidebarManager::~SidebarManager() { g_object_unref(G_OBJECT(sidebar)); } void SidebarManager::update() { Sidebar *newSidebar = activeSidebar; switch(editor->getMode()) { case EditManager::VIEW: newSidebar = &sidebarView; break; case EditManager::ADD: newSidebar = &sidebarAdd; } if(activeSidebar != newSidebar) { if(activeSidebar) gtk_container_remove(GTK_CONTAINER(viewport), gtk_bin_get_child(GTK_BIN(viewport))); gtk_container_add(GTK_CONTAINER(viewport), newSidebar->getWidget()); activeSidebar = newSidebar; } sidebarToolbox.update(); activeSidebar->update(); }