object-composite-settings.cpp revision 073e18ad60852ae12d4c4c28abed5c86004a3967
/*
* A widget for controlling object compositing (filter, opacity, etc.)
*
* Authors:
* Bryce W. Harrington <bryce@bryceharrington.org>
* Gustav Broberg <broberg@kth.se>
* Niko Kiirala <niko@kiirala.com>
* Abhishek Sharma
*
* Copyright (C) 2004--2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "ui/widget/object-composite-settings.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "document.h"
#include "document-undo.h"
#include "filter-chemistry.h"
#include "inkscape.h"
#include "selection.h"
#include "style.h"
#include "sp-item.h"
#include "svg/css-ostringstream.h"
#include "verbs.h"
#include "ui/icon-names.h"
#include "display/sp-canvas.h"
#include "ui/widget/style-subject.h"
namespace Inkscape {
namespace UI {
namespace Widget {
/*void ObjectCompositeSettings::_on_desktop_activate(
Inkscape::Application *application,
SPDesktop *desktop,
ObjectCompositeSettings *w
) {
if (w->_subject) {
w->_subject->setDesktop(desktop);
}
}
void ObjectCompositeSettings::_on_desktop_deactivate(
Inkscape::Application *application,
SPDesktop *desktop,
ObjectCompositeSettings *w
) {
if (w->_subject) {
w->_subject->setDesktop(NULL);
}
}*/
ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char const *history_prefix, int flags)
: _verb_code(verb_code),
_opacity_vbox(false, 0),
_opacity_label(_("Opacity:")),
_opacity_label_unit(_("%")),
#if WITH_GTKMM_3_0
#else
#endif
_fe_vbox(false, 0),
_blocked(false)
{
// Filter Effects
_fe_cb.signal_blend_blur_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_blendBlurValueChanged));
// Opacity
//_opacity_vbox.pack_start(_opacity_label_box, false, false, 0);
_opacity_hscale.set_draw_value(false);
#if WITH_GTKMM_3_0
_opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
#else
_opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectCompositeSettings::_opacityValueChanged));
#endif
/* SizeGroup keeps the blur and opacity labels aligned in Fill & Stroke dlg */
// These signals dont properly detect change in desktop, rely on owner dialog to call setSubject() from setTargetDesktop()
//_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_activate), this );
//_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "deactivate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_deactivate), this );
}
}
if (subject) {
_subject_changed = _subject->connectChanged(sigc::mem_fun(*this, &ObjectCompositeSettings::_subjectChanged));
}
}
void
{
if (!_subject) {
return;
}
if (!desktop) {
return;
}
if (_blocked)
return;
_blocked = true;
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
//sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
double radius;
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
} else {
radius = 0;
}
//apply created filter to every selected item
if (!SP_IS_ITEM(*i)) {
continue;
}
if (blendmode != "normal") {
} else {
}
remove_filter(item, false);
}
else if (radius != 0) {
}
//request update
}
_("Change blur"));
// resume interruptibility
//sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
_blocked = false;
}
void
{
if (!_subject) {
return;
}
if (!desktop) {
return;
}
if (_blocked)
return;
_blocked = true;
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
// UPDATE: crash fixed in GTK+ 2.10.7 (bug 374378), remove this as soon as it's reasonably common
// (though this only fixes the crash, not the multiple change events)
//sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
#if WITH_GTKMM_3_0
#else
#endif
_("Change opacity"));
// resume interruptibility
//sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
_blocked = false;
}
void
if (!_subject) {
return;
}
if (!desktop) {
return;
}
if (_blocked)
return;
_blocked = true;
switch (result) {
case QUERY_STYLE_NOTHING:
_opacity_hbox.set_sensitive(false);
// gtk_widget_set_sensitive (opa, FALSE);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently
_opacity_hbox.set_sensitive(true);
#if WITH_GTKMM_3_0
#else
#endif
break;
}
//query now for current filter mode and average blurring of selection
switch(blend_result) {
case QUERY_STYLE_NOTHING:
_fe_cb.set_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
_fe_cb.set_sensitive(true);
break;
// TODO: set text
_fe_cb.set_sensitive(false);
break;
}
switch (blur_result) {
case QUERY_STYLE_NOTHING: //no blurring
_fe_cb.set_blur_sensitive(false);
break;
case QUERY_STYLE_SINGLE:
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
_fe_cb.set_blur_sensitive(true);
//update blur widget value
}
break;
}
}
_blocked = false;
}
}
}
}
/*
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 :