summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad83b52)
raw | patch | inline | side by side (parent: ad83b52)
author | mental <mental@users.sourceforge.net> | |
Tue, 1 Jan 2008 04:40:23 +0000 (04:40 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Tue, 1 Jan 2008 04:40:23 +0000 (04:40 +0000) |
index 36105c41c0de9d7d4b4268393b350608a613f0ad..1034cd3ff7c293a09c1d13389c32e435e525d08f 100644 (file)
sensitiveNonTop = (Inkscape::next_layer(inTree->parent, inTree) != 0);
sensitiveNonBottom = (Inkscape::previous_layer(inTree->parent, inTree) != 0);
- if ( inTree->repr ) {
- SPCSSAttr *css = sp_repr_css_attr(inTree->repr, "style");
- if ( css ) {
- _opacityConnection.block();
- _opacity.set_value( sp_repr_css_double_property( css, "opacity", 1.0 ) * 100 );
- _opacityConnection.unblock();
- }
- }
}
}
@@ -670,35 +662,6 @@ bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*mod
return val;
}
-
-void LayersPanel::_opacityChanged()
-{
- SPObject* layer = _selectedLayer();
-
- if ( _desktop && layer && !_opacityConnection.blocked() ) {
- _opacityConnection.block();
-
- Gtk::Adjustment* adj = _opacity.get_adjustment();
- SPCSSAttr *css = sp_repr_css_attr_new();
-
- Inkscape::CSSOStringStream os;
- os << CLAMP( adj->get_value() / 100, 0.0, 1.0 );
- sp_repr_css_set_property( css, "opacity", os.str().c_str() );
-
- sp_desktop_apply_css_recursive( layer, css, true );
- layer->updateRepr();
-
- sp_repr_css_attr_unref( css );
-
- sp_document_maybe_done( _desktop->doc(), "layers:opacity", SP_VERB_DIALOG_LAYERS,
- _("Change layer opacity"));
-
- _opacityConnection.unblock();
- }
-}
-
-
-
/**
* Constructor
*/
_tree.set_expander_column( *_tree.get_column(nameColNum) );
+ _compositeSettings.setSubject(&_subject);
_selectedConnection = _tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) );
_tree.get_selection()->set_select_function( sigc::mem_fun(*this, &LayersPanel::_rowSelectFunction) );
_scroller.add( _tree );
_scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
-
- _opacityBox.pack_start( *manage( new Gtk::Label(_("Opacity, %:"))), Gtk::PACK_SHRINK );
-
- _opacity.set_draw_value(false);
- _opacity.set_value(100.0);
- _opacity.set_range(0.0, 100.0);
- _opacity.set_increments(1, 10);
- _opacityBox.pack_start( _opacity, Gtk::PACK_EXPAND_WIDGET );
-
- _spinBtn.configure(*_opacity.get_adjustment(), 0, 1);
-
- _spinBtn.set_width_chars(5);
- _opacityBox.pack_end( _spinBtn, Gtk::PACK_SHRINK );
- _watching.push_back( &_opacityBox );
+ _watching.push_back( &_compositeSettings );
_getContents()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET );
- _getContents()->pack_end(_opacityBox, Gtk::PACK_SHRINK);
+ _getContents()->pack_end(_compositeSettings, Gtk::PACK_SHRINK);
_getContents()->pack_end(_buttonsRow, Gtk::PACK_SHRINK);
- _opacityConnection = _opacity.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &LayersPanel::_opacityChanged) );
-
SPDesktop* targetDesktop = getDesktop();
_buttonsRow.set_child_min_width( 16 );
LayersPanel::~LayersPanel()
{
+ _compositeSettings.setSubject(NULL);
+
if ( _model )
{
delete _model;
index 7f56b3f7e7cee0baf8a4d34fdf864b34d7328d0a..e554ad0bfc0a35a11e7fb8f5773a62a462d199fb 100644 (file)
//#include "ui/previewholder.h"
#include "ui/widget/panel.h"
+#include "ui/widget/object-composite-settings.h"
class SPObject;
void _layersChanged();
void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
- void _opacityChanged();
-
SPObject* _selectedLayer();
// Hooked to the layer manager:
sigc::connection _changedConnection;
sigc::connection _addedConnection;
sigc::connection _removedConnection;
- sigc::connection _opacityConnection;
// Internal
sigc::connection _selectedConnection;
Gtk::TreeView _tree;
Gtk::HButtonBox _buttonsRow;
Gtk::ScrolledWindow _scroller;
- Gtk::HBox _opacityBox;
- Gtk::HScale _opacity;
Gtk::Menu _popupMenu;
Gtk::SpinButton _spinBtn;
+
+ UI::Widget::StyleSubject::CurrentLayer _subject;
+ UI::Widget::ObjectCompositeSettings _compositeSettings;
};
index d4c2161870d40f95691cd631dc2cb92f3d093309..b9e1754ba08cc4e13ed61da1bdd0862d34dc28a2 100644 (file)
contents->pack_start(_composite_settings, false, false, 0);
show_all_children();
+
+ _composite_settings.setSubject(&_subject);
}
FillAndStroke::~FillAndStroke()
{
+ _composite_settings.setSubject(NULL);
}
void
index ee8c32b4f251a84eb08758c2977c65e917203efd..37aa4ccc885dbf53c87fa4094d1e304cb4248ba7 100644 (file)
NotebookPage _page_stroke_paint;
NotebookPage _page_stroke_style;
+ StyleSubject::Selection _subject;
ObjectCompositeSettings _composite_settings;
Gtk::HBox &_createPageTabLabel(const Glib::ustring &label,
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index b9a88b8daff9649d3bf21c5f118939c806c03847..aeb6a263a00fdf73f9edf47baaf6d694ff7c3b89 100644 (file)
SPDesktop *desktop,
ObjectCompositeSettings *w
) {
- w->_subject.setDesktop(desktop);
+ if (w->_subject) {
+ w->_subject->setDesktop(desktop);
+ }
}
ObjectCompositeSettings::ObjectCompositeSettings()
show_all_children();
_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_switch), this );
- _subject.connectChanged(sigc::mem_fun(*this, &ObjectCompositeSettings::_subjectChanged));
- _subject.setDesktop(SP_ACTIVE_DESKTOP);
}
ObjectCompositeSettings::~ObjectCompositeSettings() {
+ setSubject(NULL);
g_signal_handler_disconnect(G_OBJECT(INKSCAPE), _desktop_activated);
}
+void ObjectCompositeSettings::setSubject(StyleSubject *subject) {
+ _subject_changed.disconnect();
+ if (subject) {
+ _subject = subject;
+ _subject_changed = _subject->connectChanged(sigc::mem_fun(*this, &ObjectCompositeSettings::_subjectChanged));
+ _subject->setDesktop(SP_ACTIVE_DESKTOP);
+ }
+}
+
void
ObjectCompositeSettings::_blendBlurValueChanged()
{
- SPDesktop *desktop = _subject.getDesktop();
+ if (!_subject) {
+ return;
+ }
+
+ SPDesktop *desktop = _subject->getDesktop();
if (!desktop) {
return;
}
// 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);
- NR::Maybe<NR::Rect> bbox = _subject.getBounds();
+ NR::Maybe<NR::Rect> bbox = _subject->getBounds();
if (!bbox) {
return;
}
SPDocument *document = sp_desktop_document (desktop);
//apply created filter to every selected item
- for (StyleSubject::iterator i = _subject.begin() ; i != _subject.end() ; ++i ) {
+ for (StyleSubject::iterator i = _subject->begin() ; i != _subject->end() ; ++i ) {
if (!SP_IS_ITEM(*i)) {
continue;
}
void
ObjectCompositeSettings::_opacityValueChanged()
{
- SPDesktop *desktop = _subject.getDesktop();
+ if (!_subject) {
+ return;
+ }
+
+ SPDesktop *desktop = _subject->getDesktop();
if (!desktop) {
return;
}
os << CLAMP (_opacity_adjustment.get_value() / 100, 0.0, 1.0);
sp_repr_css_set_property (css, "opacity", os.str().c_str());
- _subject.setCSS(css);
+ _subject->setCSS(css);
sp_repr_css_attr_unref (css);
void
ObjectCompositeSettings::_subjectChanged() {
- SPDesktop *desktop = _subject.getDesktop();
+ if (!_subject) {
+ return;
+ }
+
+ SPDesktop *desktop = _subject->getDesktop();
if (!desktop) {
return;
}
_blocked = true;
SPStyle *query = sp_style_new (sp_desktop_document(desktop));
- int result = _subject.queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
+ int result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
switch (result) {
case QUERY_STYLE_NOTHING:
}
//query now for current filter mode and average blurring of selection
- const int blend_result = _subject.queryStyle(query, QUERY_STYLE_PROPERTY_BLEND);
+ const int blend_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLEND);
switch(blend_result) {
case QUERY_STYLE_NOTHING:
_fe_cb.set_sensitive(false);
}
if(blend_result == QUERY_STYLE_SINGLE || blend_result == QUERY_STYLE_MULTIPLE_SAME) {
- int blur_result = _subject.queryStyle(query, QUERY_STYLE_PROPERTY_BLUR);
+ int blur_result = _subject->queryStyle(query, QUERY_STYLE_PROPERTY_BLUR);
switch (blur_result) {
case QUERY_STYLE_NOTHING: //no blurring
_fe_cb.set_blur_sensitive(false);
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
- NR::Maybe<NR::Rect> bbox = _subject.getBounds();
+ NR::Maybe<NR::Rect> bbox = _subject->getBounds();
if (bbox) {
double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y);
_fe_cb.set_blur_sensitive(true);
index 6cbcc82af2a9759c841e7abf4d3bb0884c7571c5..801ef76af934bf5cfe1ff5518ab975e4c8af7ec4 100644 (file)
ObjectCompositeSettings();
~ObjectCompositeSettings();
+ void setSubject(StyleSubject *subject);
+
private:
Gtk::VBox _opacity_vbox;
Gtk::HBox _opacity_label_box;
Gtk::HScale _opacity_hscale;
Gtk::SpinButton _opacity_spin_button;
- StyleSubject::Selection _subject;
+ StyleSubject *_subject;
SimpleFilterModifier _fe_cb;
Gtk::VBox _fe_vbox;
static void _on_desktop_switch(Inkscape::Application *application, SPDesktop *desktop, ObjectCompositeSettings *w);
void _subjectChanged();
+ sigc::connection _subject_changed;
void _blendBlurValueChanged();
void _opacityValueChanged();