index c15337e0db4772de6ae4da82c9749f725c76d576..9801c9f48876c056fe53b0370b611d9275d45c09 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "node-context.h"
#include "shape-editor.h"
#include "sp-rect.h"
+#include "box3d.h"
#include "box3d-context.h"
#include "sp-star.h"
#include "sp-spiral.h"
typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
+static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_zoom_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
} const tools[] = {
{ "SPSelectContext", "select_tool", SP_VERB_CONTEXT_SELECT, SP_VERB_CONTEXT_SELECT_PREFS},
{ "SPNodeContext", "node_tool", SP_VERB_CONTEXT_NODE, SP_VERB_CONTEXT_NODE_PREFS },
+ { "SPTweakContext", "tweak_tool", SP_VERB_CONTEXT_TWEAK, SP_VERB_CONTEXT_TWEAK_PREFS },
{ "SPZoomContext", "zoom_tool", SP_VERB_CONTEXT_ZOOM, SP_VERB_CONTEXT_ZOOM_PREFS },
{ "SPRectContext", "rect_tool", SP_VERB_CONTEXT_RECT, SP_VERB_CONTEXT_RECT_PREFS },
+// { "SP3DBoxContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS },
{ "SPArcContext", "arc_tool", SP_VERB_CONTEXT_ARC, SP_VERB_CONTEXT_ARC_PREFS },
{ "SPStarContext", "star_tool", SP_VERB_CONTEXT_STAR, SP_VERB_CONTEXT_STAR_PREFS },
{ "SPSpiralContext", "spiral_tool", SP_VERB_CONTEXT_SPIRAL, SP_VERB_CONTEXT_SPIRAL_PREFS },
{ "SPDynaDrawContext", "dyna_draw_tool", SP_VERB_CONTEXT_CALLIGRAPHIC, SP_VERB_CONTEXT_CALLIGRAPHIC_PREFS },
{ "SPFloodContext", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
{ "SPTextContext", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
-// { "SP3DBoxContext", "3dbox_tool", SP_VERB_CONTEXT_3DBOX, SP_VERB_CONTEXT_3DBOX_PREFS },
{ "SPConnectorContext","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
{ "SPGradientContext", "gradient_tool", SP_VERB_CONTEXT_GRADIENT, SP_VERB_CONTEXT_GRADIENT_PREFS },
{ "SPDropperContext", "dropper_tool", SP_VERB_CONTEXT_DROPPER, SP_VERB_CONTEXT_DROPPER_PREFS },
SP_VERB_INVALID, 0, 0},
{ "SPNodeContext", "node_toolbox", 0, sp_node_toolbox_prep, "NodeToolbar",
SP_VERB_INVALID, 0, 0},
+ { "SPTweakContext", "tweak_toolbox", 0, sp_tweak_toolbox_prep, "TweakToolbar",
+ SP_VERB_INVALID, 0, 0},
{ "SPZoomContext", "zoom_toolbox", 0, sp_zoom_toolbox_prep, "ZoomToolbar",
SP_VERB_INVALID, 0, 0},
{ "SPStarContext", "star_toolbox", 0, sp_star_toolbox_prep, "StarToolbar",
" <toolitem action='NodesShowHandlesAction' />"
" </toolbar>"
+ " <toolbar name='TweakToolbar'>"
+ " <toolitem action='TweakWidthAction' />"
+ " <toolitem action='TweakForceAction' />"
+ " <separator />"
+ " <toolitem action='TweakModeAction' />"
+ " <separator />"
+ " <toolitem action='TweakFidelityAction' />"
+ " <toolitem action='TweakPressureAction' />"
+ " </toolbar>"
+
" <toolbar name='ZoomToolbar'>"
" <toolitem action='ZoomIn' />"
" <toolitem action='ZoomOut' />"
" <toolitem action='3DBoxVPXAction' />"
" <toolitem action='3DBoxVPYAction' />"
" <toolitem action='3DBoxVPZAction' />"
+ " <separator />"
" </toolbar>"
" <toolbar name='SpiralToolbar'>"
@@ -2106,36 +2122,18 @@ static void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
static void sp_3dbox_toggle_vp_changed( GtkToggleAction *act, gpointer data )
{
- guint dir = GPOINTER_TO_UINT(data);
- Box3D::PerspDir axis;// = (Box3D::PerspDir) data;
+ SPDocument *document = sp_desktop_document (inkscape_active_desktop ());
+ Box3D::Axis axis = (Box3D::Axis) GPOINTER_TO_INT(data);
- GString *pstring;
- switch (dir) {
- case 0:
- pstring = g_string_new("togglevpx");
- axis = Box3D::X;
- break;
- case 1:
- pstring = g_string_new("togglevpy");
- axis = Box3D::Y;
- break;
- case 2:
- pstring = g_string_new("togglevpz");
- axis = Box3D::Z;
- break;
- }
-
- if (SP3DBoxContext::current_perspective) {
- Box3D::VanishingPoint *vp = SP3DBoxContext::current_perspective->get_vanishing_point(axis);
- vp->toggle_parallel();
- vp->draw(axis);
- prefs_set_int_attribute( "tools.shapes.3dbox", pstring->str, vp->is_finite() ? 0 : 1);
+ if (document->current_perspective) {
+ document->current_perspective->toggle_boxes (axis);
}
}
static void sp_3dbox_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
+ SPDocument *document = sp_desktop_document (desktop);
bool toggled = false;
/* toggle VP in X direction */
{
@@ -2145,11 +2143,12 @@ static void sp_3dbox_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
"toggle_vp_x",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GUINT_TO_POINTER(0));
- if (SP3DBoxContext::current_perspective) {
- toggled = SP3DBoxContext::current_perspective->get_vanishing_point(Box3D::X)->is_finite();
+ if (document->current_perspective) {
+ toggled = !document->current_perspective->get_vanishing_point(Box3D::X)->is_finite();
}
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), toggled );
+ /* we connect the signal after setting the state to avoid switching the state again */
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GINT_TO_POINTER(Box3D::X));
}
/* toggle VP in Y direction */
@@ -2160,11 +2159,12 @@ static void sp_3dbox_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
"toggle_vp_y",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GUINT_TO_POINTER(1));
- if (SP3DBoxContext::current_perspective) {
- toggled = SP3DBoxContext::current_perspective->get_vanishing_point(Box3D::Y)->is_finite();
+ if (document->current_perspective) {
+ toggled = !document->current_perspective->get_vanishing_point(Box3D::Y)->is_finite();
}
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), toggled );
+ /* we connect the signal after setting the state to avoid switching the state again */
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GINT_TO_POINTER(Box3D::Y));
}
/* toggle VP in Z direction */
@@ -2175,11 +2175,12 @@ static void sp_3dbox_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainAction
"toggle_vp_z",
Inkscape::ICON_SIZE_DECORATION );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GUINT_TO_POINTER(2));
- if (SP3DBoxContext::current_perspective) {
- toggled = SP3DBoxContext::current_perspective->get_vanishing_point(Box3D::Z)->is_finite();
+ if (document->current_perspective) {
+ toggled = !document->current_perspective->get_vanishing_point(Box3D::Z)->is_finite();
}
+ /* we connect the signal after setting the state to avoid switching the state again */
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), toggled );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_3dbox_toggle_vp_changed), GINT_TO_POINTER(Box3D::Z));
}
}
@@ -2431,6 +2432,148 @@ static void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
// Put stuff here
}
+//########################
+//## Tweak ##
+//########################
+
+static void sp_tweak_width_value_changed( GtkAdjustment *adj, GObject *tbl )
+{
+ prefs_set_double_attribute( "tools.tweak", "width", adj->value * 0.01 );
+}
+
+static void sp_tweak_force_value_changed( GtkAdjustment *adj, GObject *tbl )
+{
+ prefs_set_double_attribute( "tools.tweak", "force", adj->value * 0.01 );
+}
+
+static void sp_tweak_pressure_state_changed( GtkToggleAction *act, gpointer data )
+{
+ prefs_set_int_attribute( "tools.tweak", "usepressure", gtk_toggle_action_get_active( act ) ? 1 : 0);
+}
+
+static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
+{
+ prefs_set_int_attribute("tools.tweak", "mode", ege_select_one_action_get_active( act ));
+}
+
+static void sp_tweak_fidelity_value_changed( GtkAdjustment *adj, GObject *tbl )
+{
+ prefs_set_double_attribute( "tools.tweak", "fidelity", adj->value * 0.01 );
+}
+
+
+static void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
+{
+ {
+ /* Width */
+ gchar const* labels[] = {_("(pinch tweak)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad tweak)")};
+ gdouble values[] = {1, 3, 5, 10, 15, 20, 30, 50, 75, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "TweakWidthAction",
+ _("Width:"), _("The width of the tweak area (relative to the visible canvas area)"),
+ "tools.tweak", "width", 15,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "altx-tweak",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_tweak_width_value_changed, 0.01, 0, 100 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+
+
+ {
+ /* Force */
+ gchar const* labels[] = {_("(minimum force)"), 0, 0, _("(default)"), 0, 0, 0, _("(maximum force)")};
+ gdouble values[] = {1, 5, 10, 20, 30, 50, 70, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "TweakForceAction",
+ _("Force:"), _("The force of the tweak action"),
+ "tools.tweak", "force", 20,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-force",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_tweak_force_value_changed, 0.01, 0, 100 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+
+ /* Mode */
+ {
+ GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
+
+ GtkTreeIter iter;
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Push mode"),
+ 1, _("Switch to Push mode"),
+ 2, "tweak_push_mode",
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Melt mode"),
+ 1, _("Switch to Melt mode"),
+ 2, "tweak_suck_mode",
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Blow mode"),
+ 1, _("Switch to Blow mode"),
+ 2, "tweak_blow_mode",
+ -1 );
+
+ gtk_list_store_append( model, &iter );
+ gtk_list_store_set( model, &iter,
+ 0, _("Roughen mode"),
+ 1, _("Switch to Roughen mode"),
+ 2, "tweak_roughen_mode",
+ -1 );
+
+ EgeSelectOneAction* act = ege_select_one_action_new( "TweakModeAction", _(""), _(""), NULL, GTK_TREE_MODEL(model) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ g_object_set_data( holder, "mode_action", act );
+
+ ege_select_one_action_set_appearance( act, "full" );
+ ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
+ g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
+ ege_select_one_action_set_icon_column( act, 2 );
+ ege_select_one_action_set_tooltip_column( act, 1 );
+
+ gint mode = prefs_get_int_attribute("tools.tweak", "mode", 0);
+ ege_select_one_action_set_active( act, mode );
+ g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_tweak_mode_changed), holder );
+
+ g_object_set_data( G_OBJECT(holder), "tweak_tool_mode", act);
+ }
+
+ { /* Fidelity */
+ gchar const* labels[] = {_("(rough, simplified)"), 0, 0, _("(default)"), 0, 0, _("(fine, but many nodes)")};
+ gdouble values[] = {10, 25, 35, 50, 60, 80, 100};
+ EgeAdjustmentAction *eact = create_adjustment_action( "TweakFidelityAction",
+ _("Fidelity:"), _("Low fidelity simplifies paths; high fidelity preserves path features but may generate a lot of new nodes"),
+ "tools.tweak", "fidelity", 50,
+ GTK_WIDGET(desktop->canvas), NULL, holder, TRUE, "tweak-fidelity",
+ 1, 100, 1.0, 10.0,
+ labels, values, G_N_ELEMENTS(labels),
+ sp_tweak_fidelity_value_changed, 0.01, 0, 100 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
+ }
+
+
+ /* Use Pressure button */
+ {
+ InkToggleAction* act = ink_toggle_action_new( "TweakPressureAction",
+ _("Pressure"),
+ _("Use the pressure of the input device to alter the width of the area"),
+ "use_pressure",
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_tweak_pressure_state_changed), NULL);
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.tweak", "usepressure", 1 ) );
+ }
+
+}
+
//########################
//## Calligraphy ##
@@ -2690,7 +2833,7 @@ static void sp_calligraphy_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
{
GtkAction* act = gtk_action_new( "CalligraphyResetAction",
_("Defaults"),
- _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
+ _("Reset all parameters to defaults"),
GTK_STOCK_CLEAR );
g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_ddc_defaults), holder );
gtk_action_group_add_action( mainActions, act );
sp_text_toolbox_selection_changed (Inkscape::Selection *selection, GObject *tbl)
{
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_family =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
gtk_entry_set_text (GTK_ENTRY (entry), family);
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
}
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
free (text);
SPStyle *query =
- sp_style_new ();
+ sp_style_new (SP_ACTIVE_DOCUMENT);
int result_numbers =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);