select-toolbar.cpp revision 0b78b3f935d2de75ef952f2bafd0030aca9a077c
/*
* Selector aux toolbar
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2003-2005 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "ui/widget/spinbutton.h"
#include "widgets/spw-utilities.h"
#include "widgets/widget-sizes.h"
#include "widgets/spinbutton-events.h"
#include "widgets/sp-widget.h"
#include "preferences.h"
#include "selection-chemistry.h"
#include "document.h"
#include "document-undo.h"
#include "inkscape.h"
#include "desktop-style.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "sp-namedview.h"
#include "toolbox.h"
#include "helper/action-context.h"
#include "inkscape.h"
#include "verbs.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "sp-item-transform.h"
#include "message-stack.h"
#include "display/sp-canvas.h"
#include "ui/widget/unit-tracker.h"
#include "ege-adjustment-action.h"
#include "ege-output-action.h"
#include "ink-action.h"
#include "ui/icon-names.h"
#include "select-toolbar.h"
using Inkscape::DocumentUndo;
static void
{
return;
}
using Geom::X;
using Geom::Y;
if ( bbox ) {
};
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
}
} else {
for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) {
}
}
}
}
}
static void
sp_selection_layout_widget_modify_selection(SPWidget *spw, Inkscape::Selection *selection, guint flags, gpointer data)
{
&& (flags & (SP_OBJECT_MODIFIED_FLAG |
{
}
}
static void
sp_selection_layout_widget_change_selection(SPWidget *spw, Inkscape::Selection *selection, gpointer data)
{
std::vector<GtkAction*> *contextActions = reinterpret_cast<std::vector<GtkAction*> *>(g_object_get_data(G_OBJECT(spw), "contextActions"));
if ( contextActions ) {
}
}
}
}
}
static void
{
return;
}
/*
* When only units are being changed, don't treat changes
* to adjuster values as object changes.
*/
return;
}
document->ensureUpToDate ();
if ( !bbox_user ) {
return;
}
xrel = Quantity::convert(gtk_adjustment_get_value(a_w), &unit, &px) / bbox_user->dimensions()[Geom::X];
yrel = Quantity::convert(gtk_adjustment_get_value(a_h), &unit, &px) / bbox_user->dimensions()[Geom::Y];
} else {
}
// Keep proportions if lock is on
if ( gtk_toggle_action_get_active(lock) ) {
}
}
// scales and moves, in px
// unless the unit is %, convert the scales and moves to the unit
}
// digit in the spinbox (currently spinboxes have 3 fractional digits, so that makes 0.0005). If
// the value was changed by the user, the difference will be at least that much; otherwise it's
// just rounding difference between the spinbox value and actual value, so no action is
// performed
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed
scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1);
} else {
// 1) We could have use the newer get_scale_transform_for_variable_stroke() here, but to avoid regressions
// we'll just use the old get_scale_transform_for_uniform_stroke() for now.
// 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones!
// we'll trick it into using a geometric bounding box though, by setting the stroke width to zero
}
_("Transform by toolbar"));
// resume interruptibility
}
}
{
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits);
#else
Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits);
#endif
return widget;
}
// TODO create_adjustment_action appears to be a rogue tile copy from toolbox.cpp. Resolve it to be unified:
gchar const *shortLabel,
{
static bool init = false;
if ( !init ) {
init = true;
}
GtkAdjustment* adj = GTK_ADJUSTMENT( gtk_adjustment_new( 0.0, lower, 1e6, SPIN_STEP, SPIN_PAGE_STEP, 0 ) );
if (tracker) {
}
if ( spw ) {
}
EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3 );
if ( shortLabel ) {
}
g_signal_connect( G_OBJECT(adj), "value_changed", G_CALLBACK(sp_object_layout_any_value_changed), spw );
if ( focusTarget ) {
}
if ( altx ) { // this spinbutton will be activated by alt-x
}
// Using a cast just to make sure we pass in the right kind of function pointer
g_object_set( G_OBJECT(act), "tool-post", static_cast<EgeWidgetFixup>(sp_set_font_size_smaller), NULL );
return act;
}
// toggle button callbacks and updaters
{
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>scaled</b> when objects are scaled."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>stroke width</b> is <b>not scaled</b> when objects are scaled."));
}
}
{
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>scaled</b> when rectangles are scaled."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>rounded rectangle corners</b> are <b>not scaled</b> when rectangles are scaled."));
}
}
{
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>gradients</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
}
}
{
if ( active ) {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> are <b>transformed</b> along with their objects when those are transformed (moved, scaled, rotated, or skewed)."));
} else {
desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Now <b>patterns</b> remain <b>fixed</b> when objects are transformed (moved, scaled, rotated, or skewed)."));
}
}
if ( active ) {
} else {
}
}
{
if ( tracker ) {
delete tracker;
}
}
{
if ( targetAction ) {
}
}
static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::View::View* view, Inkscape::IconSize size )
{
InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size );
return act;
}
{
Inkscape::IconSize secondarySize = Inkscape::UI::ToolboxFactory::prefToSize("/toolbox/secondary", 1);
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CCW), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_ROTATE_90_CW), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_HORIZONTAL), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_OBJECT_FLIP_VERTICAL), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_BACK), view, secondarySize );
act = create_action_for_verb( Inkscape::Verb::get(SP_VERB_SELECTION_TO_FRONT), view, secondarySize );
// Create the parent widget for x y w h tracker.
// Remember the desktop's canvas widget, to be used for defocusing.
// The vb frame holds all other widgets and is used to set sensitivity depending on selection state.
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// Create the units menu.
//tracker->addUnit( SP_UNIT_PERCENT, 0 );
EgeAdjustmentAction* eact = 0;
// four spinbuttons
eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X",
_("Horizontal coordinate of selection"), TRUE );
eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y",
_("Vertical coordinate of selection"), FALSE );
eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width",
_("Width of selection"), FALSE );
// lock toggle
{
_("Lock width and height"),
_("When locked, change both width and height by the same proportion"),
INKSCAPE_ICON("object-unlocked"),
}
eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height",
_("Height of selection"), FALSE );
// Add the units menu.
// Force update when selection changes.
g_signal_connect(G_OBJECT(spw), "modify_selection", G_CALLBACK(sp_selection_layout_widget_modify_selection), desktop);
g_signal_connect(G_OBJECT(spw), "change_selection", G_CALLBACK(sp_selection_layout_widget_change_selection), desktop);
// Update now.
sp_selection_layout_widget_update(SP_WIDGET(spw), SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL);
if ( gtk_action_is_sensitive(*iter) ) {
}
}
// Insert spw into the toolbar.
if ( GTK_IS_BOX(holder) ) {
} else if ( GTK_IS_TOOLBAR(holder) ) {
} else {
g_warning("Unexpected holder type");
}
// "Transform with object" buttons
{
_("Scale stroke width"),
_("When scaling objects, scale the stroke width by the same proportion"),
INKSCAPE_ICON("transform-affect-stroke"),
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/stroke", true) );
}
{
_("Scale rounded corners"),
_("When scaling rectangles, scale the radii of rounded corners"),
INKSCAPE_ICON("transform-affect-rounded-corners"),
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/rectcorners", true) );
}
{
_("Move gradients"),
_("Move gradients (in fill or stroke) along with the objects"),
INKSCAPE_ICON("transform-affect-gradient"),
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/gradient", true) );
}
{
_("Move patterns"),
_("Move patterns (in fill or stroke) along with the objects"),
INKSCAPE_ICON("transform-affect-pattern"),
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(itact), prefs->getBool("/options/transform/pattern", true) );
}
}
/*
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 :