index 59009253fb05c2450cd85541241758b723a6c117..e413aa39e04f4b0879a92c95d6046566aedbfa39 100644 (file)
#include "display/sp-canvas.h"
#include "helper/unit-tracker.h"
#include "ege-adjustment-action.h"
+#include "ege-output-action.h"
#include "ink-action.h"
+#include <2geom/rect.h>
using Inkscape::UnitTracker;
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
- bool setActive = false;
- using NR::X;
- using NR::Y;
+ using Geom::X;
+ using Geom::Y;
if ( sel && !sel->isEmpty() ) {
- NR::Maybe<NR::Rect> const bbox(sel->bounds());
+ int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
+ SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
+ SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ boost::optional<NR::Rect> const bbox(sel->bounds(bbox_type));
if ( bbox && !bbox->isEmpty() ) {
UnitTracker *tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(G_OBJECT(spw), "tracker"));
SPUnit const &unit = *tracker->getActiveUnit();
gtk_adjustment_set_value(a, sp_pixels_get_units(keyval[i].val, unit));
}
}
-
- setActive = true;
- } else {
- setActive = false;
}
- } else {
- setActive = false;
- }
-
- GtkActionGroup *selectionActions = GTK_ACTION_GROUP( g_object_get_data(G_OBJECT(spw), "selectionActions") );
- if ( selectionActions ) {
-// gtk_action_group_set_sensitive( selectionActions, setActive );
}
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *selection, gpointer data)
{
SPDesktop *desktop = (SPDesktop *) data;
- if (sp_desktop_selection(desktop) == selection) // only respond to changes in our desktop
+ if (sp_desktop_selection(desktop) == selection) { // only respond to changes in our desktop
+ gboolean setActive = (selection && !selection->isEmpty());
+ std::vector<GtkAction*> *contextActions = reinterpret_cast<std::vector<GtkAction*> *>(g_object_get_data(G_OBJECT(spw), "contextActions"));
+ if ( contextActions ) {
+ for ( std::vector<GtkAction*>::iterator iter = contextActions->begin();
+ iter != contextActions->end(); ++iter) {
+ if ( setActive != gtk_action_is_sensitive(*iter) ) {
+ gtk_action_set_sensitive( *iter, setActive );
+ }
+ }
+ }
+
sp_selection_layout_widget_update(spw, selection);
+ }
}
static void
SPDocument *document = sp_desktop_document(desktop);
sp_document_ensure_up_to_date (document);
- NR::Maybe<NR::Rect> bbox = selection->bounds();
+ int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0);
+ SPItem::BBoxType bbox_type = (prefs_bbox ==0)?
+ SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
+ boost::optional<NR::Rect> bbox = selection->bounds(bbox_type);
if ( !bbox || bbox->isEmpty() ) {
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
x0 = sp_units_get_pixels (a_x->value, unit);
y0 = sp_units_get_pixels (a_y->value, unit);
x1 = x0 + sp_units_get_pixels (a_w->value, unit);
- xrel = sp_units_get_pixels (a_w->value, unit) / bbox->extent(NR::X);
+ xrel = sp_units_get_pixels (a_w->value, unit) / bbox->extent(Geom::X);
y1 = y0 + sp_units_get_pixels (a_h->value, unit);
- yrel = sp_units_get_pixels (a_h->value, unit) / bbox->extent(NR::Y);
+ yrel = sp_units_get_pixels (a_h->value, unit) / bbox->extent(Geom::Y);
} else {
double const x0_propn = a_x->value * unit.unittobase;
- x0 = bbox->min()[NR::X] * x0_propn;
+ x0 = bbox->min()[Geom::X] * x0_propn;
double const y0_propn = a_y->value * unit.unittobase;
- y0 = y0_propn * bbox->min()[NR::Y];
+ y0 = y0_propn * bbox->min()[Geom::Y];
xrel = a_w->value * unit.unittobase;
- x1 = x0 + xrel * bbox->extent(NR::X);
+ x1 = x0 + xrel * bbox->extent(Geom::X);
yrel = a_h->value * unit.unittobase;
- y1 = y0 + yrel * bbox->extent(NR::Y);
+ y1 = y0 + yrel * bbox->extent(Geom::Y);
}
// Keep proportions if lock is on
GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") );
if ( gtk_toggle_action_get_active(lock) ) {
if (adj == a_h) {
- x1 = x0 + yrel * bbox->extent(NR::X);
+ x1 = x0 + yrel * bbox->extent(Geom::X);
} else if (adj == a_w) {
- y1 = y0 + xrel * bbox->extent(NR::Y);
+ y1 = y0 + xrel * bbox->extent(Geom::Y);
}
}
// scales and moves, in px
- double mh = fabs(x0 - bbox->min()[NR::X]);
- double sh = fabs(x1 - bbox->max()[NR::X]);
- double mv = fabs(y0 - bbox->min()[NR::Y]);
- double sv = fabs(y1 - bbox->max()[NR::Y]);
+ double mh = fabs(x0 - bbox->min()[Geom::X]);
+ double sh = fabs(x1 - bbox->max()[Geom::X]);
+ double mv = fabs(y0 - bbox->min()[Geom::Y]);
+ double sv = fabs(y1 - bbox->max()[Geom::Y]);
// unless the unit is %, convert the scales and moves to the unit
if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
static EgeAdjustmentAction * create_adjustment_action( gchar const *name,
gchar const *label,
+ gchar const *shortLabel,
gchar const *data,
gdouble lower,
GtkWidget* focusTarget,
}
EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3 );
+ if ( shortLabel ) {
+ g_object_set( act, "short_label", Q_(shortLabel), NULL );
+ }
gtk_signal_connect( GTK_OBJECT(adj), "value_changed", GTK_SIGNAL_FUNC(sp_object_layout_any_value_changed), spw );
if ( focusTarget ) {
}
}
-static void toggle_lock( GtkToggleAction *act, gpointer data ) {
+static void toggle_lock( GtkToggleAction *act, gpointer /*data*/ ) {
gboolean active = gtk_toggle_action_get_active( act );
if ( active ) {
g_object_set( G_OBJECT(act), "iconId", "width_height_lock", NULL );
}
}
-static void trigger_sp_action( GtkAction* act, gpointer user_data )
+static void trigger_sp_action( GtkAction* /*act*/, gpointer user_data )
{
SPAction* targetAction = SP_ACTION(user_data);
if ( targetAction ) {
@@ -366,28 +378,46 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi
void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
Inkscape::UI::View::View *view = desktop;
+ Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
GtkAction* act = 0;
GtkActionGroup* selectionActions = mainActions; // temporary
+ std::vector<GtkAction*>* contextActions = new std::vector<GtkAction*>();
+
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_EDIT_SELECT_ALL), view, secondarySize );
+ gtk_action_group_add_action( selectionActions, act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS), view, secondarySize );
+ gtk_action_group_add_action( selectionActions, act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_EDIT_DESELECT), view, secondarySize );
+ gtk_action_group_add_action( selectionActions, act );
+ contextActions->push_back( act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CCW), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CCW), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CW), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CW), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_HORIZONTAL), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_HORIZONTAL), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_VERTICAL), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_VERTICAL), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
+ contextActions->push_back( act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_BACK), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_BACK), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_LOWER), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_LOWER), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_RAISE), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_RAISE), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
- act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_FRONT), view, Inkscape::ICON_SIZE_SMALL_TOOLBAR );
+ contextActions->push_back( act );
+ act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_FRONT), view, secondarySize );
gtk_action_group_add_action( selectionActions, act );
+ contextActions->push_back( act );
// Create the parent widget for x y w h tracker.
GtkWidget *spw = sp_widget_new_global(INKSCAPE);
@@ -414,32 +444,36 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
- eact = create_adjustment_action( "XAction", _("select_toolbar|X"), "X",
+ eact = create_adjustment_action( "XAction", _("select_toolbar|X position"), _("select_toolbar|X"), "X",
-1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
_("Horizontal coordinate of selection"), TRUE );
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
+ contextActions->push_back( GTK_ACTION(eact) );
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
- eact = create_adjustment_action( "YAction", _("select_toolbar|Y"), "Y",
+ eact = create_adjustment_action( "YAction", _("select_toolbar|Y position"), _("select_toolbar|Y"), "Y",
-1e6, GTK_WIDGET(desktop->canvas), tracker, spw,
_("Vertical coordinate of selection"), FALSE );
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
+ contextActions->push_back( GTK_ACTION(eact) );
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
- eact = create_adjustment_action( "WidthAction", _("select_toolbar|W"), "width",
+ eact = create_adjustment_action( "WidthAction", _("select_toolbar|Width"), _("select_toolbar|W"), "width",
1e-3, GTK_WIDGET(desktop->canvas), tracker, spw,
_("Width of selection"), FALSE );
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
+ contextActions->push_back( GTK_ACTION(eact) );
// lock toggle
{
InkToggleAction* itact = ink_toggle_action_new( "LockAction",
- _("Lock"),
+ _("Lock width and height"),
_("When locked, change both width and height by the same proportion"),
"lock_unlocked",
Inkscape::ICON_SIZE_DECORATION );
+ g_object_set( itact, "short_label", "Lock", NULL );
g_object_set_data( G_OBJECT(spw), "lock", itact );
g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(toggle_lock), desktop) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(itact) );
@@ -447,16 +481,18 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
- eact = create_adjustment_action( "HeightAction", _("select_toolbar|H"), "height",
+ eact = create_adjustment_action( "HeightAction", _("select_toolbar|Height"), _("select_toolbar|H"), "height",
1e-3, GTK_WIDGET(desktop->canvas), tracker, spw,
_("Height of selection"), FALSE );
gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) );
+ contextActions->push_back( GTK_ACTION(eact) );
// Add the units menu.
- act = tracker->createAction( "UnitsAction", _("Units"), _("") );
+ act = tracker->createAction( "UnitsAction", _("Units"), ("") );
gtk_action_group_add_action( selectionActions, act );
g_object_set_data( G_OBJECT(spw), "selectionActions", selectionActions );
+ g_object_set_data( G_OBJECT(spw), "contextActions", contextActions );
// Force update when selection changes.
gtk_signal_connect(GTK_OBJECT(spw), "modify_selection", GTK_SIGNAL_FUNC(sp_selection_layout_widget_modify_selection), desktop);
@@ -465,14 +501,34 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
// Update now.
sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL);
+ for ( std::vector<GtkAction*>::iterator iter = contextActions->begin();
+ iter != contextActions->end(); ++iter) {
+ if ( gtk_action_is_sensitive(*iter) ) {
+ gtk_action_set_sensitive( *iter, FALSE );
+ }
+ }
+
// Insert spw into the toolbar.
- gtk_box_pack_start(GTK_BOX(holder), spw, FALSE, FALSE, 0);
+ if ( GTK_IS_BOX(holder) ) {
+ gtk_box_pack_start(GTK_BOX(holder), spw, FALSE, FALSE, 0);
+ } else if ( GTK_IS_TOOLBAR(holder) ) {
+ gtk_toolbar_append_widget( GTK_TOOLBAR(holder), spw, "Text", "priv" );
+ } else {
+ g_warning("Unexpected holder type");
+ }
// "Transform with object" buttons
+ {
+ EgeOutputAction* act = ege_output_action_new( "transform_affect_label", _("Affect:"), "", 0 );
+ ege_output_action_set_use_markup( act, TRUE );
+ g_object_set( act, "visible-overflown", FALSE, NULL );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ }
+
{
InkToggleAction* itact = ink_toggle_action_new( "transform_stroke",
- _("Stroke"),
+ _("Scale stroke width"),
_("When scaling objects, scale the stroke width by the same proportion"),
"transform_stroke",
Inkscape::ICON_SIZE_DECORATION );
@@ -483,7 +539,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
{
InkToggleAction* itact = ink_toggle_action_new( "transform_corners",
- _("Corners"),
+ _("Scale rounded corners"),
_("When scaling rectangles, scale the radii of rounded corners"),
"transform_corners",
Inkscape::ICON_SIZE_DECORATION );
@@ -494,7 +550,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
{
InkToggleAction* itact = ink_toggle_action_new( "transform_gradient",
- _("Gradient"),
+ _("Move gradients"),
_("Move gradients (in fill or stroke) along with the objects"),
"transform_gradient",
Inkscape::ICON_SIZE_DECORATION );
@@ -505,7 +561,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
{
InkToggleAction* itact = ink_toggle_action_new( "transform_pattern",
- _("Patterns"),
+ _("Move patterns"),
_("Move patterns (in fill or stroke) along with the objects"),
"transform_pattern",
Inkscape::ICON_SIZE_DECORATION );