mesh-toolbar.cpp revision 214a2dca4418a9937d7142e42ed91fdfdb86ae16
/*
* Gradient aux toolbar
*
* Authors:
* bulia byak <bulia@dr.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Abhishek Sharma
* Tavmjong Bah <tavjong@free.fr>
*
* Copyright (C) 2012 Tavmjong Bah
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 2005 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
// REVIEW THESE AT END OF REWRITE
#include "ui/widget/color-preview.h"
#include "toolbox.h"
#include "mesh-toolbar.h"
#include "verbs.h"
#include "macros.h"
#include "widgets/widget-sizes.h"
#include "widgets/spw-utilities.h"
#include "widgets/spinbutton-events.h"
#include "widgets/gradient-vector.h"
#include "widgets/gradient-image.h"
#include "style.h"
#include "preferences.h"
#include "document-private.h"
#include "document-undo.h"
#include "desktop.h"
#include "ui/tools/gradient-tool.h"
#include "ui/tools/mesh-tool.h"
#include "gradient-drag.h"
#include "sp-mesh-gradient.h"
#include "gradient-chemistry.h"
#include "gradient-selector.h"
#include "selection.h"
#include "ui/icon-names.h"
#include "widgets/ege-adjustment-action.h"
#include "widgets/ege-output-action.h"
#include "widgets/ege-select-one-action.h"
#include "widgets/ink-action.h"
#include "widgets/ink-comboboxentry-action.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "toolbox.h"
using Inkscape::DocumentUndo;
static bool blocked = false;
//########################
//## Mesh ##
//########################
/*
* Get the current selection and dragger status from the desktop
*/
bool &ms_selected_multi,
bool &ms_smooth_multi )
{
// Read desktop selection
bool first = true;
if ( SP_IS_MESHGRADIENT(server) ) {
if (gradient != ms_selected) {
if (ms_selected) {
ms_selected_multi = true;
} else {
}
}
ms_smooth_multi = true;
} else {
}
}
first = false;
}
}
if ( SP_IS_MESHGRADIENT(server) ) {
if (gradient != ms_selected) {
if (ms_selected) {
ms_selected_multi = true;
} else {
}
}
ms_smooth_multi = true;
} else {
}
}
first = false;
}
}
}
}
/*
* Core function, setup all the widgets whenever something changes on the desktop
*/
{
// std::cout << "ms_tb_selection_changed" << std::endl;
if (blocked)
return;
if (!desktop) {
return;
}
if (selection) {
// ToolBase *ev = sp_desktop_event_context(desktop);
// GrDrag *drag = NULL;
// if (ev) {
// drag = ev->get_drag();
// }
SPMeshGradient *ms_selected = 0;
bool ms_selected_multi = false;
bool ms_smooth_multi = false;
// std::cout << " smooth: " << ms_smooth << std::endl;
EgeSelectOneAction* smooth = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "mesh_select_smooth_action");
if (ms_selected) {
}
}
}
static void ms_tb_selection_modified(Inkscape::Selection *selection, guint /*flags*/, gpointer data)
{
}
{
}
{
}
{
}
{
SPMeshGradient *gradient = 0;
SPPaintServer *server = 0;
}
}
if ( SP_IS_MESHGRADIENT(server) ) {
}
}
if (gradient) {
}
}
/*
* Callback functions for user actions
*/
{
gint typemode = ege_select_one_action_get_active( act ) == 0 ? SP_GRADIENT_MESH_TYPE_NORMAL : SP_GRADIENT_MESH_TYPE_CONICAL;
}
{
Inkscape::PaintTarget fsmode = (ege_select_one_action_get_active( act ) == 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
}
{
if (blocked) {
return;
}
}
{
if (blocked) {
return;
}
}
{
// std::cout << "ms_smooth_changed" << std::endl;
if (blocked) {
return;
}
SPMeshGradient *gradient = 0;
if (gradient) {
// std::cout << " smooth: " << smooth << std::endl;
gradient->smooth_set = true;
gradient->updateRepr();
_("Set mesh smoothing"));
}
}
static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
/**
* Mesh auxiliary toolbar construction and setup.
*
*/
{
EgeAdjustmentAction* eact = 0;
/* New mesh: normal or conical */
{
EgeSelectOneAction* act = ege_select_one_action_new( "MeshNewTypeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
gint mode = prefs->getInt("/tools/mesh/mesh_type", SP_GRADIENT_MESH_TYPE_NORMAL) != SP_GRADIENT_MESH_TYPE_NORMAL;
}
/* New gradient on fill or stroke*/
{
EgeSelectOneAction* act = ege_select_one_action_new( "MeshNewFillStrokeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
/// @todo Convert to boolean?
}
/* Number of mesh rows */
{
_("Rows"), _("Rows:"), _("Number of rows in new mesh"),
1, 20, 1, 1,
1.0, 0 );
}
/* Number of mesh columns */
{
_("Columns"), _("Columns:"), _("Number of columns in new mesh"),
1, 20, 1, 1,
1.0, 0 );
}
/* Edit fill mesh */
{
_("Edit Fill"),
_("Edit fill mesh"),
INKSCAPE_ICON("object-fill"),
}
/* Edit stroke mesh */
{
_("Edit Stroke"),
_("Edit stroke mesh"),
INKSCAPE_ICON("object-stroke"),
}
{
_("Show Handles"),
_("Show side and tensor handles"),
INKSCAPE_ICON("show-node-handles"),
}
/* Warning */
{
}
/* Smoothing method */
{
_("If the mesh should be smoothed across patch boundaries."),
}
}
static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder)
{
if (SP_IS_MESH_CONTEXT(ec)) {
// connect to selection modified and changed signals
c_selection_changed = selection->connectChanged(sigc::bind(sigc::ptr_fun(&ms_tb_selection_changed), holder));
c_selection_modified = selection->connectModified(sigc::bind(sigc::ptr_fun(&ms_tb_selection_modified), holder));
c_subselection_changed = desktop->connectToolSubselectionChanged(sigc::bind(sigc::ptr_fun(&ms_drag_selection_changed), holder));
c_defs_release = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&ms_defs_release), holder));
c_defs_modified = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&ms_defs_modified), holder));
} else {
if (c_selection_changed)
if (c_selection_modified)
if (c_defs_release)
if (c_defs_modified)
}
}
/*
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 :