/*
* A simple panel for layers
*
* Authors:
* Jon A. Cruz
* Abhishek Sharma
*
* Copyright (C) 2006,2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "layers.h"
#include <gtkmm/icontheme.h>
#include <gtkmm/imagemenuitem.h>
#include <gtkmm/separatormenuitem.h>
#include "desktop.h"
#include "desktop-style.h"
#include "document.h"
#include "document-undo.h"
#include "helper/action-context.h"
#include "inkscape.h"
#include "layer-fns.h"
#include "layer-manager.h"
#include "preferences.h"
#include "sp-item.h"
#include "sp-object.h"
#include "svg/css-ostringstream.h"
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
#include "verbs.h"
#include "sp-root.h"
#include "ui/tools/tool-base.h"
#include "selection-chemistry.h"
//#define DUMP_LAYERS 1
namespace Inkscape {
namespace UI {
namespace Dialog {
{
return *new LayersPanel();
}
enum {
};
enum {
BUTTON_NEW = 0,
};
{
public:
int _actionCode;
};
void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback )
{
bool set = false;
if ( iconName ) {
gtk_widget_show( child );
set = true;
}
if ( desktop ) {
if ( verb ) {
gtk_widget_show( child );
set = true;
}
}
}
}
}
}
Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id )
{
const char* label = 0;
if ( iconName ) {
}
if ( desktop ) {
if ( verb ) {
}
if ( action ) {
}
}
}
}
if ( iconWidget ) {
}
if (wrapped) {
} else {
}
return *item;
}
{
if ( _desktop ) {
if ( verb ) {
if ( action ) {
// } else {
// g_message("no action");
}
// } else {
// g_message("no verb for %u", code);
}
// } else {
// g_message("no active desktop");
}
}
// SP_VERB_LAYER_NEXT,
// SP_VERB_LAYER_PREV,
{
if ( !_pending ) {
_pending = new InternalUIBounce();
}
}
{
// Make sure selected layer hasn't changed since the action was triggered
if ( _pending
&& (
)
)
) {
// SPObject* target = _pending->_target;
switch ( val ) {
case BUTTON_NEW:
{
}
break;
case BUTTON_RENAME:
{
}
break;
case BUTTON_TOP:
{
}
break;
case BUTTON_BOTTOM:
{
}
break;
case BUTTON_UP:
{
}
break;
case BUTTON_DOWN:
{
}
break;
case BUTTON_DUPLICATE:
{
}
break;
case BUTTON_DELETE:
{
}
break;
case BUTTON_SOLO:
{
}
break;
case BUTTON_SHOW_ALL:
{
}
break;
case BUTTON_HIDE_ALL:
{
}
break;
case BUTTON_LOCK_OTHERS:
{
}
break;
case BUTTON_LOCK_ALL:
{
}
break;
case BUTTON_UNLOCK_ALL:
{
}
break;
case DRAGNDROP:
{
_doTreeMove( );
}
break;
}
delete _pending;
_pending = 0;
}
return false;
}
{
public:
{
}
virtual ~ModelColumns() {}
};
_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 stopGoing = false;
{
/*
* We get notified of layer update here (from layer->setLabel()) before layer->label() is set
* with the correct value (sp-object bug?). So use the inkscape:label attribute instead which
* has the correct value (bug #168351)
*/
//row[_model->_colLabel] = layer->label() ? layer->label() : layer->getId();
stopGoing = true;
}
return stopGoing;
}
}
} else {
_store->foreach( sigc::bind<SPObject*>(sigc::mem_fun(*this, &LayersPanel::_checkForSelected), layer) );
}
}
bool LayersPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer)
{
bool stopGoing = false;
{
stopGoing = true;
}
return stopGoing;
}
{
// g_message("_layersChanged()");
if (_desktop) {
if ( root ) {
#if DUMP_LAYERS
#endif // DUMP_LAYERS
}
}
}
}
void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level )
{
for ( unsigned int i = 0; i < counter; i++ ) {
if ( child ) {
#if DUMP_LAYERS
#endif // DUMP_LAYERS
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
}
}
}
}
}
{
if ( iter ) {
}
return obj;
}
{
// TODO hunt down the possible API abuse in getting NULL
if ( inTree ) {
}
} else {
}
}
}
{
bool sensitive = false;
bool sensitiveNonTop = false;
bool sensitiveNonBottom = false;
sensitive = true;
if ( inTree ) {
}
}
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
}
}
{
if ( _toggleEvent ) {
_toggleEvent = 0;
}
// Make a copy so we can keep it around.
}
}
{
if ( item ) {
switch ( targetCol ) {
case COL_VISIBLE:
{
item->updateRepr();
}
break;
case COL_LOCKED:
{
item->updateRepr();
}
break;
}
}
}
{
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_F2: {
// Edit the layer label
_text_renderer->property_editable() = true;
grab_focus();
return true;
}
}
break;
}
return false;
}
{
static unsigned doubleclick = 0;
// TODO - fix to a better is-popup function
}
}
int x2 = 0;
int y2 = 0;
return true;
}
}
}
int x2 = 0;
int y2 = 0;
}
DocumentUndo::maybeDone(_desktop->doc(), "layer:lockothers", SP_VERB_LAYER_LOCK_OTHERS, _("Lock other layers"));
}
}
}
}
}
doubleclick = 1;
}
doubleclick = 0;
int x2 = 0;
int y2 = 0;
// Double click on the Layer name, enable editing
_text_renderer->property_editable() = true;
grab_focus();
}
}
return false;
}
/*
* Drap and drop within the tree
* Save the drag source and drop target SPObjects and if its a drag between layers or into (sublayer) a layer
*/
bool LayersPanel::_handleDragDrop(const Glib::RefPtr<Gdk::DragContext>& /*context*/, int x, int y, guint /*time*/)
{
_dnd_into = false;
_dnd_target = NULL;
// Are we before, inside or after the drop layer
} else {
// Dragging to the "end"
// Drop into parent
_dnd_into = true;
} else {
// Drop into the top level
_dnd_target = NULL;
}
}
}
}
}
return false;
}
/*
* Move a layer in response to a drag & drop action
*/
{
if(!_dnd_target){
_dnd_source->doWriteTransform(_dnd_source->getRepr(), _dnd_source->i2doc_affine() * _dnd_source->document->getRoot()->i2doc_affine().inverse());
}else{
if(parent){
}
}
_dnd_source = NULL;
_("Move layer"));
}
}
{
_text_renderer->property_editable() = false;
}
{
_text_renderer->property_editable() = false;
}
{
if ( obj ) {
_("Rename layer"));
}
}
}
}
bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*model*/, Gtk::TreeModel::Path const & /*path*/, bool currentlySelected )
{
bool val = true;
if ( !currentlySelected && _toggleEvent )
{
if ( event ) {
// (keep these checks separate, so we know when to call gdk_event_free()
)
{
// Ooooh! It's a magic one
val = false;
}
}
}
}
return val;
}
/**
* Constructor
*/
deskTrack(),
_maxNestDepth(20),
_desktop(0),
_model(0),
_pending(0),
_toggleEvent(0),
{
_tree.set_headers_visible(false);
_tree.set_reorderable(true);
Inkscape::UI::Widget::ImageToggler *eyeRenderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler(
eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) );
eyeRenderer->property_activatable() = true;
if ( col ) {
}
Inkscape::UI::Widget::ImageToggler * renderer = Gtk::manage( new Inkscape::UI::Widget::ImageToggler(
renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) );
renderer->property_activatable() = true;
if ( col ) {
}
_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) );
_text_renderer->signal_editing_canceled().connect( sigc::mem_fun(*this, &LayersPanel::_handleEditingCancelled) );
_tree.signal_button_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false );
_tree.signal_button_release_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent), false );
_tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleKeyEvent), false );
#if WITH_GTKMM_3_0
#else
#endif
// Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar
}
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_NEW, INKSCAPE_ICON("list-add"), C_("Layers", "New") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, INKSCAPE_ICON("go-bottom"), C_("Layers", "Bot") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("go-down"), C_("Layers", "Dn") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("go-up"), C_("Layers", "Up") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_TOP, INKSCAPE_ICON("go-top"), C_("Layers", "Top") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
// btn = Gtk::manage( new Gtk::Button("Dup") );
// btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DUPLICATE) );
// _buttonsRow.add( *btn );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DELETE) );
// -------------------------------------------------------
{
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_NEW, 0, "New", (int)BUTTON_NEW ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RENAME, 0, "Rename", (int)BUTTON_RENAME ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SOLO, 0, "Solo", (int)BUTTON_SOLO ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SHOW_ALL, 0, "Show All", (int)BUTTON_SHOW_ALL ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_HIDE_ALL, 0, "Hide All", (int)BUTTON_HIDE_ALL ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_OTHERS, 0, "Lock Others", (int)BUTTON_LOCK_OTHERS ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOCK_ALL, 0, "Lock All", (int)BUTTON_LOCK_ALL ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_UNLOCK_ALL, 0, "Unlock All", (int)BUTTON_UNLOCK_ALL ) );
_watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, INKSCAPE_ICON("layer-raise"), "Up", (int)BUTTON_UP ) );
_watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, INKSCAPE_ICON("layer-lower"), "Down", (int)BUTTON_DOWN ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_DUPLICATE, 0, "Duplicate", (int)BUTTON_DUPLICATE ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_DELETE, 0, "Delete", (int)BUTTON_DELETE ) );
}
// -------------------------------------------------------
(*it)->set_sensitive( false );
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonTop.begin(); it != _watchingNonTop.end(); ++it ) {
(*it)->set_sensitive( false );
}
for ( std::vector<Gtk::Widget*>::iterator it = _watchingNonBottom.begin(); it != _watchingNonBottom.end(); ++it ) {
(*it)->set_sensitive( false );
}
// restorePanelPrefs();
// Connect this up last
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &LayersPanel::setDesktop) );
}
{
if ( _model )
{
delete _model;
_model = 0;
}
if (_pending) {
delete _pending;
_pending = 0;
}
if ( _toggleEvent )
{
_toggleEvent = 0;
}
}
{
if ( _desktop ) {
_desktop = 0;
}
if ( _desktop ) {
//setLabel( _desktop->doc()->name );
if ( mgr ) {
_layerChangedConnection = mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
_layerUpdatedConnection = mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );
}
}
}
}
} //namespace Dialogs
} //namespace UI
} //namespace Inkscape
/*
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 :