calligraphy-toolbar.cpp revision eb4caa8f4cdc2955b58dcd2de06fe770533414c8
/**
* @file
* Calligraphy aux toolbar
*/
/* Authors:
* MenTaLguY <mental@rydia.net>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Frank Felfe <innerspace@iname.com>
* John Cliff <simarilius@yahoo.com>
* David Turner <novalis@gnu.org>
* Josh Andler <scislac@scislac.com>
* Jon A. Cruz <jon@joncruz.org>
* Maximilian Albert <maximilian.albert@gmail.com>
* Tavmjong Bah <tavmjong@free.fr>
* Abhishek Sharma
* Kris De Gussem <Kris.DeGussem@gmail.com>
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
* Copyright (C) 1999-2011 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "../ui/dialog/calligraphic-profile-rename.h"
#include "toolbox.h"
#include "calligraphy-toolbar.h"
#include "../desktop.h"
#include "../desktop-handles.h"
#include "document-undo.h"
#include "../verbs.h"
#include "../inkscape.h"
#include "../ege-adjustment-action.h"
#include "../ege-output-action.h"
#include "../ege-select-one-action.h"
#include "../ink-action.h"
#include "../ink-comboboxentry-action.h"
#include "../widgets/spinbutton-events.h"
#include "ui/widget/spinbutton.h"
#include "../widgets/spw-utilities.h"
#include "../widgets/widget-sizes.h"
//#include "../xml/attribute-record.h"
#include "../xml/node-event-vector.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
#include "../helper/unit-menu.h"
#include "../helper/unit-tracker.h"
#include "../pen-context.h"
using Inkscape::UnitTracker;
using Inkscape::DocumentUndo;
//########################
//## Calligraphy ##
//########################
{
return;
}
EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
if (!sel) {
// WTF!? This will cause a segfault if ever reached
//ege_select_one_action_set_active(sel, 0);
return;
}
int ege_index = 1;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++ege_index) {
bool match = true;
for (std::vector<Inkscape::Preferences::Entry>::iterator j = preset.begin(); j != preset.end(); ++j) {
continue;
}
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
double v = j->getDouble();
//std::cout << "compared adj " << attr_name << gtk_adjustment_get_value(adj) << " to " << v << "\n";
match = false;
break;
}
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
bool v = j->getBool();
//std::cout << "compared toggle " << attr_name << gtk_toggle_action_get_active(toggle) << " to " << v << "\n";
match = false;
break;
}
}
}
}
if (match) {
// newly added item is at the same index as the
// save command, so we need to change twice for it to take effect
return;
}
}
// no match found
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
// TODO merge into PrefPusher
if (calligraphy_angle ) {
}
}
static gchar const *const widget_names[] = {
"width",
"mass",
"wiggle",
"angle",
"thinning",
"tremor",
"flatness",
"cap_rounding",
"usepressure",
"tracebackground",
"usetilt"
};
{
EgeSelectOneAction* selector = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
{
}
// iterate over all presets to populate the list
int ii=1;
}
{
}
}
{
if (! desktop) {
return;
}
return;
}
if ( !CalligraphicProfileRename::applied()) {
// dialog cancelled
return;
}
if (profile_name.empty()) {
// empty name entered
return;
}
// If there's a preset with the given name, find it and set save_path appropriately
int new_index = -1;
int temp_index = 0;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) {
save_path = *i;
break;
}
}
if (new_index == -1) {
// no preset with this name, create
}
for (unsigned i = 0; i < G_N_ELEMENTS(widget_names); ++i) {
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
//std::cout << "wrote adj " << widget_name << ": " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
//std::cout << "wrote tog " << widget_name << ": " << v << "\n";
} else {
}
} else {
}
}
}
{
// This is necessary because EgeSelectOneAction spams us with GObject "changed" signal calls
// even when the preset is not changed. It would be good to replace it with something more
// modern. Index 0 means "No preset", so we don't do anything.
if (preset_index == 0) {
return;
}
if (preset_index == save_presets_index) {
// this is the Save command
return;
}
return;
}
// preset_index is one-based so we subtract 1
if (!preset_path.empty()) {
g_object_set_data(tbl, "presets_blocked", GINT_TO_POINTER(TRUE)); //temporarily block the selector so no one will updadte it while we're reading it
// Shouldn't this be std::map?
for (std::vector<Inkscape::Preferences::Entry>::iterator i = preset.begin(); i != preset.end(); ++i) {
continue;
}
if (widget) {
if (GTK_IS_ADJUSTMENT(widget)) {
//std::cout << "set adj " << attr_name << " to " << v << "\n";
} else if (GTK_IS_TOGGLE_ACTION(widget)) {
//std::cout << "set toggle " << attr_name << " to " << v << "\n";
} else {
}
} else {
}
}
}
}
{
{
{
/* Width */
gchar const* labels[] = {_("(hairline)"), 0, 0, 0, _("(default)"), 0, 0, 0, 0, _("(broad stroke)")};
_("Pen Width"), _("Width:"),
_("The width of the calligraphic pen (relative to the visible canvas area)"),
"/tools/calligraphic/width", 15,
1, 100, 1.0, 10.0,
sp_ddc_width_value_changed, 1, 0 );
}
{
/* Thinning */
gchar const* labels[] = {_("(speed blows up stroke)"), 0, 0, _("(slight widening)"), _("(constant width)"), _("(slight thinning, default)"), 0, 0, _("(speed deflates stroke)")};
_("Stroke Thinning"), _("Thinning:"),
_("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"),
"/tools/calligraphic/thinning", 10,
-100, 100, 1, 10.0,
sp_ddc_velthin_value_changed, 1, 0);
}
{
/* Angle */
gchar const* labels[] = {_("(left edge up)"), 0, 0, _("(horizontal)"), _("(default)"), 0, _("(right edge up)")};
_("Pen Angle"), _("Angle:"),
_("The angle of the pen's nib (in degrees; 0 = horizontal; has no effect if fixation = 0)"),
"/tools/calligraphic/angle", 30,
-90.0, 90.0, 1.0, 10.0,
sp_ddc_angle_value_changed, 1, 0 );
}
{
/* Fixation */
gchar const* labels[] = {_("(perpendicular to stroke, \"brush\")"), 0, 0, 0, _("(almost fixed, default)"), _("(fixed by Angle, \"pen\")")};
_("Fixation"), _("Fixation:"),
_("Angle behavior (0 = nib always perpendicular to stroke direction, 100 = fixed angle)"),
"/tools/calligraphic/flatness", 90,
0.0, 100, 1.0, 10.0,
sp_ddc_flatness_value_changed, 1, 0);
}
{
/* Cap Rounding */
gchar const* labels[] = {_("(blunt caps, default)"), _("(slightly bulging)"), 0, 0, _("(approximately round)"), _("(long protruding caps)")};
// TRANSLATORS: "cap" means "end" (both start and finish) here
_("Cap rounding"), _("Caps:"),
_("Increase to make caps at the ends of strokes protrude more (0 = no caps, 1 = round caps)"),
"/tools/calligraphic/cap_rounding", 0.0,
0.0, 5.0, 0.01, 0.1,
}
{
/* Tremor */
gchar const* labels[] = {_("(smooth line)"), _("(slight tremor)"), _("(noticeable tremor)"), 0, 0, _("(maximum tremor)")};
_("Stroke Tremor"), _("Tremor:"),
_("Increase to make strokes rugged and trembling"),
"/tools/calligraphic/tremor", 0.0,
0.0, 100, 1, 10.0,
sp_ddc_tremor_value_changed, 1, 0);
}
{
/* Wiggle */
gchar const* labels[] = {_("(no wiggle)"), _("(slight deviation)"), 0, 0, _("(wild waves and curls)")};
_("Pen Wiggle"), _("Wiggle:"),
_("Increase to make the pen waver and wiggle"),
"/tools/calligraphic/wiggle", 0.0,
0.0, 100, 1, 10.0,
sp_ddc_wiggle_value_changed, 1, 0);
}
{
/* Mass */
gchar const* labels[] = {_("(no inertia)"), _("(slight smoothing, default)"), _("(noticeable lagging)"), 0, 0, _("(maximum inertia)")};
_("Pen Mass"), _("Mass:"),
_("Increase to make the pen drag behind, as if slowed by inertia"),
"/tools/calligraphic/mass", 2.0,
0.0, 100, 1, 10.0,
sp_ddc_mass_value_changed, 1, 0);
}
/* Trace Background button */
{
_("Trace Background"),
_("Trace the lightness of the background by the width of the pen (white - minimum width, black - maximum width)"),
INKSCAPE_ICON("draw-trace-background"),
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/tracebackground", update_presets_list, holder);
}
/* Use Pressure button */
{
_("Pressure"),
_("Use the pressure of the input device to alter the width of the pen"),
INKSCAPE_ICON("draw-use-pressure"),
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usepressure", update_presets_list, holder);
}
/* Use Tilt button */
{
_("Tilt"),
_("Use the tilt of the input device to alter the angle of the pen's nib"),
INKSCAPE_ICON("draw-use-tilt"),
PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/calligraphic/usetilt", update_presets_list, holder);
gtk_action_set_sensitive( GTK_ACTION(calligraphy_angle), !prefs->getBool("/tools/calligraphic/usetilt", true) );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/calligraphic/usetilt", true) );
}
/*calligraphic profile */
{
EgeSelectOneAction* act1 = ege_select_one_action_new ("SetProfileAction", "" , (_("Choose a preset")), NULL, GTK_TREE_MODEL(model));
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :