summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ae47657)
raw | patch | inline | side by side (parent: ae47657)
author | joncruz <joncruz@users.sourceforge.net> | |
Thu, 1 Jun 2006 08:55:22 +0000 (08:55 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Thu, 1 Jun 2006 08:55:22 +0000 (08:55 +0000) |
ChangeLog | patch | blob | history | |
src/dialogs/layers-panel.cpp | patch | blob | history | |
src/dialogs/layers-panel.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index b471b225d953a14a295f1a940a0e227d01330068..7e1ce4a4da2327c1d0dad1688ef38e3d4bdd7b03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-06-01 Jon A. Cruz <jon@joncruz.org>
+
+ * src/dialogs/layers-panel.h, src/dialogs/layers-panel.cpp:
+
+ Added layer opacity slider.
+ Fixes RFE #1496569.
+
2006-05-31 Colin Marquardt <colin@marquardt-home.de>
* TRANSLATORS: Add vonHalenbach for tutorial translations.
index a09ce152724821604c93ba30dde9191a0a98aeae..4faaec2979c42919457310b17aa474caa26d7096 100644 (file)
#include "sp-item.h"
#include "widgets/icon.h"
#include <gtkmm/widget.h>
+#include <gtkmm/spinbutton.h>
#include "prefs-utils.h"
+#include "xml/repr.h"
+#include "svg/css-ostringstream.h"
+#include "desktop-style.h"
//#define DUMP_LAYERS 1
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 ) {
+ _opacity.set_value( sp_repr_css_double_property( css, "opacity", 1.0 ) );
+ }
+ }
}
}
+
for ( std::vector<Gtk::Widget*>::iterator it = _watching.begin(); it != _watching.end(); ++it ) {
(*it)->set_sensitive( sensitive );
}
@@ -654,6 +666,35 @@ bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model
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(), 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" );
+
+ _opacityConnection.unblock();
+ }
+}
+
+
+
/**
* Constructor
*/
_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(1.0);
+ _opacity.set_range(0.0, 1.0);
+ _opacity.set_increments(0.01, 0.1);
+ _opacityBox.pack_start( _opacity, Gtk::PACK_EXPAND_WIDGET );
+
+ Gtk::SpinButton* spinBtn = manage( new Gtk::SpinButton(*_opacity.get_adjustment(), 0.0, 3) );
+
+ _opacityBox.pack_end( *spinBtn, Gtk::PACK_SHRINK );
+ _watching.push_back( &_opacityBox );
+
_getContents()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET );
+
+ _getContents()->pack_end(_opacityBox, 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 = SP_ACTIVE_DESKTOP;
_buttonsRow.set_child_min_width( 16 );
index 263a0105cf2834c7c8122958fc60621de5b75ecf..76278fa4f6ff5ad14cc4c2cb2565bba38fb330f6 100644 (file)
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/tooltips.h>
+#include <gtkmm/scale.h>
#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/box.h>
#include <gtkmm/buttonbox.h>
#include "ui/widget/panel.h"
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;
int _maxNestDepth;
Inkscape::LayerManager* _mgr;
Gtk::TreeView _tree;
Gtk::HButtonBox _buttonsRow;
Gtk::ScrolledWindow _scroller;
+ Gtk::HBox _opacityBox;
+ Gtk::HScale _opacity;
Gtk::Menu _popupMenu;
};