index e89e5050d8bd0166a6f792edbd77d0d2fdb8de12..ebb6d989d2086a7bd86259f8356dad284ab15da9 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"
namespace UI {
namespace Dialogs {
-LayersPanel* LayersPanel::instance = 0;
-
-LayersPanel& LayersPanel::getInstance()
+LayersPanel&
+LayersPanel::getInstance()
{
- if ( !instance ) {
- instance = new LayersPanel();
- }
-
- return *instance;
+ return *new LayersPanel();
}
enum {
BUTTON_UP,
BUTTON_DOWN,
// BUTTON_DUPLICATE,
- BUTTON_DELETE
+ BUTTON_DELETE,
+ BUTTON_SOLO
};
class ImageToggler : public Gtk::CellRendererPixbuf {
}
virtual bool activate_vfunc(GdkEvent* event,
- Gtk::Widget& widget,
+ Gtk::Widget& /*widget*/,
const Glib::ustring& path,
- const Gdk::Rectangle& background_area,
- const Gdk::Rectangle& cell_area,
- Gtk::CellRendererState flags)
+ const Gdk::Rectangle& /*background_area*/,
+ const Gdk::Rectangle& /*cell_area*/,
+ Gtk::CellRendererState /*flags*/)
{
_signal_pre_toggle.emit(event);
_signal_toggled.emit(path);
SPObject* _target;
};
-static gboolean layers_panel_activated( GtkObject *object, GdkEvent * /*event*/, gpointer data )
+static gboolean layers_panel_activated( GtkObject */*object*/, GdkEvent * /*event*/, gpointer data )
{
if ( data )
{
LayersPanel* panel = reinterpret_cast<LayersPanel*>(data);
- panel->setDesktop( SP_ACTIVE_DESKTOP );
+ panel->setDesktop(panel->getDesktop());
}
return FALSE;
{
_fireAction( SP_VERB_LAYER_DELETE );
}
+ case BUTTON_SOLO:
+ {
+ _fireAction( SP_VERB_LAYER_SOLO );
+ }
break;
}
_store->foreach( sigc::bind<SPObject*>(sigc::mem_fun(*this, &LayersPanel::_checkForUpdated), layer) );
}
-bool LayersPanel::_checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer)
+bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::TreeIter& iter, SPObject* layer)
{
bool stopGoing = false;
Gtk::TreeModel::Row row = *iter;
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 ) );
- }
- }
}
}
row[_model->_colVisible] = newValue;
item->setHidden( !newValue );
item->updateRepr();
- sp_document_done( _desktop->doc() );
+ sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
+ newValue? _("Unhide layer") : _("Hide layer"));
}
break;
row[_model->_colLocked] = newValue;
item->setLocked( newValue );
item->updateRepr();
- sp_document_done( _desktop->doc() );
+ sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS,
+ newValue? _("Lock layer") : _("Unlock layer"));
}
break;
}
}
}
-void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter )
+void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& /*path*/, Gtk::TreeModel::iterator const& iter )
{
Gtk::TreeModel::Row row = *iter;
if ( row ) {
@@ -644,7 +639,7 @@ void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeM
}
}
-bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool currentlySelected )
+bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*model*/, Gtk::TreeModel::Path const & /*path*/, bool currentlySelected )
{
bool val = true;
if ( !currentlySelected && _toggleEvent )
@@ -672,46 +667,18 @@ 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
*/
LayersPanel::LayersPanel() :
- Inkscape::UI::Widget::Panel( Glib::ustring(), "dialogs.layers" ),
+ UI::Widget::Panel("", "dialogs.layers", SP_VERB_DIALOG_LAYERS),
_maxNestDepth(20),
_mgr(0),
_desktop(0),
_model(0),
_pending(0),
- _toggleEvent(0)
+ _toggleEvent(0),
+ _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND)
{
_maxNestDepth = prefs_get_int_attribute_limited("dialogs.layers", "maxDepth", 20, 1, 1000);
_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(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 );
+ _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 = SP_ACTIVE_DESKTOP;
+ SPDesktop* targetDesktop = getDesktop();
_buttonsRow.set_child_min_width( 16 );
{
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RENAME, 0, "Rename", (int)BUTTON_RENAME ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_NEW, 0, "New", (int)BUTTON_NEW ) );
+ _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SOLO, 0, "Solo", (int)BUTTON_SOLO ) );
_popupMenu.items().push_back( Gtk::Menu_Helpers::SeparatorElem() );
}
g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this );
-
-
setDesktop( targetDesktop );
-
-
show_all_children();
- restorePanelPrefs();
+ // restorePanelPrefs();
}
LayersPanel::~LayersPanel()
{
+ _compositeSettings.setSubject(NULL);
+
if ( _model )
{
delete _model;
void LayersPanel::setDesktop( SPDesktop* desktop )
{
+ Panel::setDesktop(desktop);
+
if ( desktop != _desktop ) {
_layerChangedConnection.disconnect();
_layerUpdatedConnection.disconnect();
_desktop = 0;
}
- _desktop = SP_ACTIVE_DESKTOP;
+ _desktop = getDesktop();
if ( _desktop ) {
- setLabel( _desktop->doc()->name );
+ //setLabel( _desktop->doc()->name );
_mgr = _desktop->layer_manager;
if ( _mgr ) {