From: Jon A. Cruz Date: Mon, 11 Jan 2010 09:09:52 +0000 (-0800) Subject: Implemented dynamic repositioning of toolboxes. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d34b2a875c91cad7ba5866d51d6c2afeb087eff;p=inkscape.git Implemented dynamic repositioning of toolboxes. --- diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 48ff9dca0..2153606c1 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -58,15 +58,19 @@ UXManager::~UXManager() void UXManager::setTask(SPDesktop* dt, gint val) { - GtkOrientation orientation = (val == 0)? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL; for (vector::iterator it = dtws.begin(); it != dtws.end(); ++it) { - if ((*it)->desktop == dt) { - vector& boxes = trackedBoxes[dt]; - for (vector::iterator it2 = boxes.begin(); it2 != boxes.end(); ++it2) { - gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(*it2), "BarIdValue")); - if (id != 1) { - //ToolboxFactory::setOrientation(*it2, orientation); - } + SPDesktopWidget* dtw = *it; + if (dtw->desktop == dt) { + if (val == 0) { + dtw->setToolboxPosition("ToolToolbar", GTK_POS_LEFT); + dtw->setToolboxPosition("CommandsToolbar", GTK_POS_TOP); + dtw->setToolboxPosition("SnapToolbar", GTK_POS_TOP); + // for now skip "AuxToolbar"; + } else { + dtw->setToolboxPosition("ToolToolbar", GTK_POS_TOP); + dtw->setToolboxPosition("CommandsToolbar", GTK_POS_LEFT); + dtw->setToolboxPosition("SnapToolbar", GTK_POS_RIGHT); + // for now skip "AuxToolbar"; } break; } @@ -95,8 +99,8 @@ void UXManager::connectToDesktop( vector const & toolboxes, SPDeskt for (vector::const_iterator it = toolboxes.begin(); it != toolboxes.end(); ++it ) { GtkWidget* toolbox = *it; - ToolboxFactory::setToolboxDesktop( toolbox, desktop ); + ToolboxFactory::setToolboxDesktop( toolbox, desktop ); vector& tracked = trackedBoxes[desktop]; if (find(tracked.begin(), tracked.end(), toolbox) == tracked.end()) { tracked.push_back(toolbox); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index f70ade5a3..6655df3eb 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -292,7 +292,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) GtkWidget *tbl; GtkWidget *canvas_tbl; - GtkWidget *hbox; GtkWidget *eventbox; GtkStyle *style; @@ -323,25 +322,25 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 ); } - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_end (GTK_BOX (dtw->vbox), hbox, TRUE, TRUE, 0); - gtk_widget_show (hbox); + dtw->hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 ); + gtk_widget_show(dtw->hbox); dtw->aux_toolbox = ToolboxFactory::createAuxToolbox(); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0); dtw->snap_toolbox = ToolboxFactory::createSnapToolbox(); ToolboxFactory::setOrientation( dtw->snap_toolbox, GTK_ORIENTATION_VERTICAL ); - gtk_box_pack_end (GTK_BOX (hbox), dtw->snap_toolbox, FALSE, TRUE, 0); + gtk_box_pack_end( GTK_BOX(dtw->hbox), dtw->snap_toolbox, FALSE, TRUE, 0 ); dtw->commands_toolbox = ToolboxFactory::createCommandsToolbox(); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->commands_toolbox, FALSE, TRUE, 0); dtw->tool_toolbox = ToolboxFactory::createToolToolbox(); - gtk_box_pack_start (GTK_BOX (hbox), dtw->tool_toolbox, FALSE, TRUE, 0); + gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 ); tbl = gtk_table_new (2, 3, FALSE); - gtk_box_pack_start (GTK_BOX (hbox), tbl, TRUE, TRUE, 1); + gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 ); canvas_tbl = gtk_table_new (3, 3, FALSE); @@ -1341,6 +1340,47 @@ SPDesktopWidget::isToolboxButtonActive (const gchar* id) return isActive; } +void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionType pos) +{ + // Note - later on these won't be individual member variables. + GtkWidget* toolbox = 0; + if (id == "ToolToolbar") { + toolbox = tool_toolbox; + } else if (id == "AuxToolbar") { + toolbox = aux_toolbox; + } else if (id == "CommandsToolbar") { + toolbox = commands_toolbox; + } else if (id == "SnapToolbar") { + toolbox = snap_toolbox; + } + + + if (toolbox) { + switch(pos) { + case GTK_POS_TOP: + case GTK_POS_BOTTOM: + if ( gtk_widget_is_ancestor(toolbox, hbox) ) { + gtk_widget_reparent( toolbox, vbox ); + gtk_box_set_child_packing(GTK_BOX(vbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); + } + ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_HORIZONTAL); + break; + case GTK_POS_LEFT: + case GTK_POS_RIGHT: + if ( !gtk_widget_is_ancestor(toolbox, hbox) ) { + gtk_widget_reparent( toolbox, hbox ); + gtk_box_set_child_packing(GTK_BOX(hbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START); + if (pos == GTK_POS_LEFT) { + gtk_box_reorder_child( GTK_BOX(hbox), toolbox, 0 ); + } + } + ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_VERTICAL); + break; + } + } +} + + SPViewWidget *sp_desktop_widget_new( SPNamedView *namedview ) { SPDesktopWidget* dtw = SPDesktopWidget::createInstance(namedview); diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index c9bedb1ab..33f2a6ae7 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -76,6 +76,8 @@ struct SPDesktopWidget { // The root vbox of the window layout. GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *menubar, *statusbar; Inkscape::UI::Dialogs::SwatchesPanel *panels; @@ -218,6 +220,7 @@ struct SPDesktopWidget { void setToolboxAdjustmentValue (gchar const * id, double value); void setToolboxSelectOneValue (gchar const * id, gint value); bool isToolboxButtonActive (gchar const *id); + void setToolboxPosition(Glib::ustring const& id, GtkPositionType pos); void setCoordinateStatus(Geom::Point p); void requestCanvasUpdate(); void requestCanvasUpdateAndWait(); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 25014160d..c12896d70 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -102,6 +102,8 @@ #include "toolbox.h" +//#define ENABLE_TASK_SUPPORT 1 + using Inkscape::UnitTracker; using Inkscape::UI::UXManager;