layers.cpp revision 1b3a8414f17dc95fc921d999ea715c99d10dd4aa
/*
* 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 "desktop.h"
#include "desktop-style.h"
#include "document.h"
#include "document-undo.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"
//#define DUMP_LAYERS 1
namespace Inkscape {
namespace UI {
namespace Dialog {
{
return *new LayersPanel();
}
enum {
COL_VISIBLE = 1,
};
enum {
BUTTON_NEW = 0,
};
class LayersPanel::InternalUIBounce
{
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 )
{
GtkWidget* iconWidget = 0;
const char* label = 0;
if ( iconName ) {
}
if ( desktop ) {
if ( verb ) {
}
if ( action ) {
}
}
}
}
if ( iconWidget ) {
}
if ( wrapped ) {
menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem( label, *wrapped, sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), id)) );
} else {
menulist.push_back( Gtk::Menu_Helpers::MenuElem( label, sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), id)) );
}
}
{
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();
}
}
bool LayersPanel::_executeAction()
{
// 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;
}
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;
{
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;
}
void LayersPanel::_layersChanged()
{
// 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 {
}
}
}
void LayersPanel::_checkTreeSelection()
{
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;
}
}
}
{
// TODO - fix to a better is-popup function
{
int x2 = 0;
int y2 = 0;
if ( _tree.get_path_at_pos( x, y,
}
}
}
}
void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& /*path*/, Gtk::TreeModel::iterator const& iter )
{
if ( obj ) {
}
}
}
}
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
*/
LayersPanel::LayersPanel() :
deskTrack(),
_maxNestDepth(20),
_desktop(0),
_model(0),
_pending(0),
_toggleEvent(0),
{
_tree.set_headers_visible(false);
eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) );
eyeRenderer->property_activatable() = true;
if ( col ) {
}
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) );
_tree.get_model()->signal_row_changed().connect( sigc::mem_fun(*this, &LayersPanel::_handleRowChange) );
_tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
int minHeight = 70;
// Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar
}
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_NEW) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_TOP) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_UP) );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_DOWN) );
_styleButton( *btn, targetDesktop, SP_VERB_LAYER_TO_BOTTOM, GTK_STOCK_GOTO_BOTTOM, C_("Layers", "Bot") );
btn->signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_takeAction), (int)BUTTON_BOTTOM) );
// btn = 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_RENAME, 0, "Rename", (int)BUTTON_RENAME ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_DUPLICATE, 0, "Duplicate", (int)BUTTON_DUPLICATE ) );
_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 ) );
_watchingNonTop.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RAISE, GTK_STOCK_GO_UP, "Up", (int)BUTTON_UP ) );
_watchingNonBottom.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_LOWER, GTK_STOCK_GO_DOWN, "Down", (int)BUTTON_DOWN ) );
}
// -------------------------------------------------------
(*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) );
}
}
}
/*
GSList const *layers = _desktop->doc()->getResourceList( "layer" );
g_message( "layers list starts at %p", layers );
for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
SPObject *layer=static_cast<SPObject *>(iter->data);
g_message(" {%s} [%s]", layer->id, layer->label() );
}
*/
}
} //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 :