/**
* @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 "calligraphy-toolbar.h"
#include "desktop.h"
#include "document-undo.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
#include "preferences.h"
#include "toolbox.h"
#include "ui/icon-names.h"
#include "ui/uxmanager.h"
using Inkscape::DocumentUndo;
//########################
//## Calligraphy ##
//########################
return presets;
}
{
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;
}
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 ) {
}
}
"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
if (!preset_name.empty()) {
}
}
/* {
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter, 0, _("Save..."), 1, ii, -1 );
g_object_set_data(tbl, "save_presets_index", GINT_TO_POINTER(ii));
}*/
}
{
if (! desktop) {
return;
}
return;
}
EgeSelectOneAction *sel = static_cast<EgeSelectOneAction *>(g_object_get_data(tbl, "profile_selector"));
//gint preset_index = ege_select_one_action_get_active( sel );
if (ege_select_one_action_get_active_text( sel )) {
}
if (current_profile_name == _("No preset")) {
current_profile_name = "";
}
if ( !CalligraphicProfileRename::applied()) {
// dialog cancelled
return;
}
if (new_profile_name.empty()) {
// empty name entered
return;
}
// If there's a preset with the given name, find it and set save_path appropriately
int temp_index = 0;
for (std::vector<Glib::ustring>::iterator i = presets.begin(); i != presets.end(); ++i, ++temp_index) {
save_path = *i;
break;
}
}
return;
}
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;
}
/*
gint save_presets_index = GPOINTER_TO_INT(g_object_get_data(tbl, "save_presets_index"));
if (preset_index == save_presets_index) {
// this is the Save command
sp_dcc_save_profile(NULL, tbl);
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 {
}
}
} 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,
}
{
/* 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,
}
{
/* 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,
}
{
/* 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,
}
{
/* 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,
}
{
/* 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,
}
{
/* 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,
}
/* 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));
}
/*calligraphic profile editor */
{
_("Add or edit calligraphic profile"),
INKSCAPE_ICON("document-properties"),
g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_ddc_edit_profile), (GObject*)holder );
}
}
}
/*
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 :