X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftags%2Fsynfigstudio_0_61_04%2Fsynfig-studio%2Fsrc%2Fgtkmm%2Fmod_palette%2Fdock_paledit.cpp;fp=synfig-studio%2Ftags%2Fsynfigstudio_0_61_04%2Fsynfig-studio%2Fsrc%2Fgtkmm%2Fmod_palette%2Fdock_paledit.cpp;h=0000000000000000000000000000000000000000;hb=3a6643238c67c043fc3592837a05d6d2861967f1;hp=94a3dcb74c59c940b28fc35c2401f00d541580fc;hpb=47fce282611fbba1044921d22ca887f9b53ad91a;p=synfig.git diff --git a/synfig-studio/tags/synfigstudio_0_61_04/synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp b/synfig-studio/tags/synfigstudio_0_61_04/synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp deleted file mode 100644 index 94a3dcb..0000000 --- a/synfig-studio/tags/synfigstudio_0_61_04/synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/* === S Y N F I G ========================================================= */ -/*! \file dialog_palette.cpp -** \brief Template File -** -** $Id: dock_paledit.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ -** -** \legal -** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** \endlegal -*/ -/* ========================================================================= */ - -/* === H E A D E R S ======================================================= */ - -#ifdef USING_PCH -# include "pch.h" -#else -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "dock_paledit.h" -#include "../widget_color.h" -#include -#include -#include -#include -#include -#include -#include "../widget_color.h" -#include -#include -#include -#include "../app.h" -#include "../dialog_color.h" - -#endif - -/* === U S I N G =========================================================== */ - -using namespace std; -using namespace etl; -using namespace synfig; -using namespace studio; - -/* === M A C R O S ========================================================= */ - -/* === G L O B A L S ======================================================= */ -/* -class studio::PaletteSettings : public synfigapp::Settings -{ - Dock_PalEdit* dialog_palette; - synfig::String name; -public: - PaletteSettings(Dock_PalEdit* window,const synfig::String& name): - dialog_palette(window), - name(name) - { - dialog_palette->dialog_settings.add_domain(this,name); - } - - virtual ~PaletteSettings() - { - dialog_palette->dialog_settings.remove_domain(name); - } - - virtual bool get_value(const synfig::String& key, synfig::String& value)const - { - int i(atoi(key.c_str())); - if(i<0 || i>=dialog_palette->size()) - return false; - Color c(dialog_palette->get_color(i)); - value=strprintf("%f %f %f %f",c.get_r(),c.get_g(),c.get_b(),c.get_a()); - return true; - } - - virtual bool set_value(const synfig::String& key,const synfig::String& value) - { - int i(atoi(key.c_str())); - if(i<0) - return false; - if(i>=dialog_palette->size()) - dialog_palette->palette_.resize(i+1); - float r,g,b,a; - if(!strscanf(value,"%f %f %f %f",&r,&g,&b,&a)) - return false; - dialog_palette->set_color(Color(r,g,b,a),i); - return true; - } - - virtual KeyList get_key_list()const - { - synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list()); - - int i; - for(i=0;isize();i++) - ret.push_back(strprintf("%03d",i)); - return ret; - } -}; -*/ -/* === P R O C E D U R E S ================================================= */ - -/* === M E T H O D S ======================================================= */ - -Dock_PalEdit::Dock_PalEdit(): - Dockable("pal_edit",_("Palette Editor"),Gtk::StockID("gtk-select-color")), - //palette_settings(new PaletteSettings(this,"colors")), - table(2,2,false) -{ - action_group=Gtk::ActionGroup::create(); - DEBUGPOINT(); - action_group->add(Gtk::Action::create( - "palette-add-color", - Gtk::StockID("gtk-add"), - _("Add Color"), - _("Add current foreground color\nto the palette") - ), - sigc::mem_fun( - *this, - &Dock_PalEdit::on_add_pressed - ) - ); - - App::ui_manager()->insert_action_group(action_group); - - Glib::ustring ui_info = - "" - " " - " " - " " - "" - ; - - App::ui_manager()->add_ui_from_string(ui_info); - - set_toolbar(*dynamic_cast(App::ui_manager()->get_widget("/toolbar-palette"))); - - /* - add_button( - Gtk::StockID("gtk-add"), - _("Add current foreground color\nto the palette") - )->signal_clicked().connect( - sigc::mem_fun( - *this, - &Dock_PalEdit::on_add_pressed - ) - ); - */ - - add(table); - table.set_homogeneous(true); - - set_default_palette(); - - show_all_children(); -} - -Dock_PalEdit::~Dock_PalEdit() -{ - //delete palette_settings; -} - -void -Dock_PalEdit::set_palette(const synfig::Palette& x) -{ - palette_=x; - refresh(); -} - -void -Dock_PalEdit::on_add_pressed() -{ - add_color(synfigapp::Main::get_foreground_color()); -} - -void -Dock_PalEdit::show_menu(int i) -{ - Gtk::Menu* menu(manage(new Gtk::Menu())); - - menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"), - sigc::bind( - sigc::mem_fun(*this,&studio::Dock_PalEdit::edit_color), - i - ) - )); - - menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"), - sigc::bind( - sigc::mem_fun(*this,&studio::Dock_PalEdit::erase_color), - i - ) - )); - - menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); - - menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Load Default Palette"), - sigc::mem_fun(*this,&studio::Dock_PalEdit::set_default_palette) - )); - - menu->popup(3,gtk_get_current_event_time()); -} - -int -Dock_PalEdit::add_color(const synfig::Color& x) -{ - palette_.push_back(x); - signal_changed()(); - refresh(); - return size()-1; -} - -void -Dock_PalEdit::set_color(synfig::Color x, int i) -{ - palette_[i].color=x; - signal_changed()(); - refresh(); -} - -Color -Dock_PalEdit::get_color(int i)const -{ - return palette_[i].color; -} - -void -Dock_PalEdit::erase_color(int i) -{ - palette_.erase(palette_.begin()+i); - signal_changed()(); - refresh(); -} - -void -Dock_PalEdit::refresh() -{ - const int width(12); - - // Clear the table - table.foreach(sigc::mem_fun(table,&Gtk::Table::remove)); - - for(int i=0;iset_value(get_color(i)); - widget_color->set_size_request(12,12); - widget_color->signal_activate().connect( - sigc::bind( - sigc::mem_fun(*this,&studio::Dock_PalEdit::select_color), - i - ) - ); - widget_color->signal_secondary().connect( - sigc::bind( - sigc::mem_fun(*this,&studio::Dock_PalEdit::show_menu), - i - ) - ); - int c(i%width),r(i/width); - table.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - } - table.show_all(); - queue_draw(); -} - - -void -Dock_PalEdit::edit_color(int i) -{ - App::dialog_color->reset(); - App::dialog_color->set_color(get_color(i)); - App::dialog_color->signal_edited().connect( - sigc::bind( - sigc::mem_fun(*this,&studio::Dock_PalEdit::set_color), - i - ) - ); - App::dialog_color->present(); -} - -void -Dock_PalEdit::select_color(int i) -{ - synfigapp::Main::set_foreground_color(get_color(i)); -} - -void -Dock_PalEdit::set_default_palette() -{ - int width=12; - - palette_.clear(); - - // Greys - palette_.push_back(Color::alpha()); - for(int i=0;i