-/* === S I N F G =========================================================== */
+/* === S Y N F I G ========================================================= */
/*! \file cellrenderer_value.cpp
** \brief Template File
**
-** $Id: cellrenderer_value.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
+** $Id$
**
** \legal
-** Copyright (c) 2002 Robert B. Quattlebaum Jr.
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
**
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** 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.
**
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** 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
*/
/* ========================================================================= */
#include "dialog_color.h"
#include <gtkmm/textview.h>
+#include "general.h"
+
#endif
-using namespace sinfg;
+using namespace synfig;
using namespace etl;
using namespace std;
using namespace studio;
#define DIGITS 15
-#define use_colorspace_gamma() App::use_colorspace_gamma
-#define colorspace_gamma() (2.2f)
-#define gamma_in(x) pow((float)x,1.0f/colorspace_gamma())
-#define gamma_out(x) pow((float)x,colorspace_gamma())
-
/* === G L O B A L S ======================================================= */
class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
//set_flags(Gtk::CAN_FOCUS);
//set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
-
+
/*
set_events(//(Gdk::ALL_EVENTS_MASK)
- ~( Gdk::EXPOSURE_MASK
- | Gdk::ENTER_NOTIFY_MASK
- | Gdk::LEAVE_NOTIFY_MASK
- | Gdk::FOCUS_CHANGE_MASK
- | Gdk::STRUCTURE_MASK
- | Gdk::PROPERTY_CHANGE_MASK
- | Gdk::VISIBILITY_NOTIFY_MASK
- | Gdk::PROXIMITY_IN_MASK
- | Gdk::PROXIMITY_OUT_MASK
+ ~( Gdk::EXPOSURE_MASK
+ | Gdk::ENTER_NOTIFY_MASK
+ | Gdk::LEAVE_NOTIFY_MASK
+ | Gdk::FOCUS_CHANGE_MASK
+ | Gdk::STRUCTURE_MASK
+ | Gdk::PROPERTY_CHANGE_MASK
+ | Gdk::VISIBILITY_NOTIFY_MASK
+ | Gdk::PROXIMITY_IN_MASK
+ | Gdk::PROXIMITY_OUT_MASK
| Gdk::SUBSTRUCTURE_MASK
)
);
//signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
show_all_children();
-
+
//signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
}
~ValueBase_Entry()
{
- DEBUGPOINT();
}
-
+
void on_editing_done()
{
hide();
}
else
{
- sinfg::error("on_editing_done(): Called twice!");
+ synfig::error("on_editing_done(): Called twice!");
}
}
void set_parent(Gtk::Widget*x) { parent=x; }
if(parent)parent->grab_focus();
Gtk::CellEditable::on_remove_widget();
}
- void start_editing_vfunc(GdkEvent *event)
+ void start_editing_vfunc(GdkEvent */*event*/)
{
valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
show();
{
path=p;
}
- void set_value(const sinfg::ValueBase &data)
+ void set_value(const synfig::ValueBase &data)
{
if(valuewidget)
valuewidget->set_value(data);
//valuewidget->grab_focus();
}
- void set_canvas(const etl::handle<sinfg::Canvas> &data)
+ void set_canvas(const etl::handle<synfig::Canvas> &data)
{
assert(data);
if(valuewidget)
valuewidget->set_canvas(data);
}
- void set_param_desc(const sinfg::ParamDesc &data)
+ void set_param_desc(const synfig::ParamDesc &data)
{
if(valuewidget)
valuewidget->set_param_desc(data);
}
-
- const sinfg::ValueBase &get_value()
+
+ const synfig::ValueBase &get_value()
{
if(valuewidget)
return valuewidget->get_value();
- return sinfg::ValueBase();
+
+ warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
+ return *(new synfig::ValueBase());
}
+
const Glib::ustring &get_path()
{
return path;
/* === P R O C E D U R E S ================================================= */
-bool get_paragraph(sinfg::String& text)
+bool get_paragraph(synfig::String& text)
{
Gtk::Dialog dialog(
_("Paragraph"), // Title
entry.set_activates_default(true);
dialog.get_vbox()->pack_start(entry);
*/
-
+
dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
dialog.set_default_response(Gtk::RESPONSE_OK);
-
+
//text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-
+
dialog.show();
if(dialog.run()!=Gtk::RESPONSE_OK)
CellRenderer_ValueBase::CellRenderer_ValueBase():
Glib::ObjectBase (typeid(CellRenderer_ValueBase)),
Gtk::CellRendererText (),
- property_value_ (*this,"value",sinfg::ValueBase()),
- property_canvas_(*this,"canvas",etl::handle<sinfg::Canvas>()),
- property_param_desc_(*this,"param_desc",sinfg::ParamDesc())
+ property_value_ (*this,"value",synfig::ValueBase()),
+ property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
+ property_param_desc_(*this,"param_desc",synfig::ParamDesc())
{
CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
value_entry=new ValueBase_Entry();
value_entry->hide();
-
+
Pango::AttrList attr_list;
{
Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
attr_list.change(pango_size);
}
property_attributes()=attr_list;
-
+
property_foreground()=Glib::ustring("#7f7f7f");
- property_inconsistant()=false;
+ property_inconsistent()=false;
}
CellRenderer_ValueBase::~CellRenderer_ValueBase()
{
-// sinfg::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): deleted");
+ if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+ synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
}
void
{
ValueBase old_value=property_value_.get_value();
ValueBase value;
-
+
if(old_value.get_type()==ValueBase::TYPE_TIME)
{
value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
}
- else
+ else
value=ValueBase((String)str);
-
+
if(old_value!=value)
signal_edited_(path,value);
}
switch(data.get_type())
{
case ValueBase::TYPE_REAL:
- if(((sinfg::ParamDesc)property_param_desc_).get_is_distance())
+ if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
{
Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
x.convert(App::distance_system,get_canvas()->rend_desc());
property_text()=(Glib::ustring)strprintf("%.2f DEG",(Real)Angle::deg(data.get(Angle())).get());
break;
case ValueBase::TYPE_INTEGER:
- if(((sinfg::ParamDesc)property_param_desc_).get_hint()!="enum")
+ if(((synfig::ParamDesc)property_param_desc_).get_hint()!="enum")
{
property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
}
else
{
property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
- std::list<sinfg::ParamDesc::EnumData> enum_list=((sinfg::ParamDesc)property_param_desc_).get_enum_list();
- std::list<sinfg::ParamDesc::EnumData>::iterator iter;
-
+ std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
+ std::list<synfig::ParamDesc::EnumData>::iterator iter;
+
for(iter=enum_list.begin();iter!=enum_list.end();iter++)
if(iter->value==data.get(int()))
{
break;
}
}
-
+
break;
case ValueBase::TYPE_VECTOR:
{
property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
}
break;
-
+
case ValueBase::TYPE_STRING:
-
+
if(data.get_type()==ValueBase::TYPE_STRING)
{
- if(!data.get(sinfg::String()).empty())
- property_text()=static_cast<Glib::ustring>(data.get(sinfg::String()));
+ if(!data.get(synfig::String()).empty())
+ property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
else
property_text()=Glib::ustring("<empty>");
}
break;
case ValueBase::TYPE_CANVAS:
- if(data.get(etl::handle<sinfg::Canvas>()))
+ if(data.get(etl::handle<synfig::Canvas>()))
{
- if(data.get(etl::handle<sinfg::Canvas>())->is_inline())
- property_text()="<Inline Canvas>";
+ if(data.get(etl::handle<synfig::Canvas>())->is_inline())
+ property_text()=_("<Inline Canvas>");
else
- property_text()=(Glib::ustring)data.get(etl::handle<sinfg::Canvas>())->get_id();
+ property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
}
else
property_text()="<No Image Selected>";
case ValueBase::TYPE_BOOL:
{
widget.get_style()->paint_check(
- Glib::RefPtr<Gdk::Window>::cast_static(window), state,
+ Glib::RefPtr<Gdk::Window>::cast_static(window), state,
data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
ca, widget, "cellcheck",
ca.get_x()/* + x_offset + cell_xpad*/,
break;
default:
property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
- break;
+ break;
}
CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
}
*/
void
-CellRenderer_ValueBase::gradient_edited(sinfg::Gradient gradient, Glib::ustring path)
+CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring path)
{
ValueBase old_value(property_value_.get_value());
ValueBase value(gradient);
}
void
-CellRenderer_ValueBase::color_edited(sinfg::Color color, Glib::ustring path)
+CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
{
ValueBase old_value(property_value_.get_value());
ValueBase value(color);
Gtk::CellEditable*
CellRenderer_ValueBase::start_editing_vfunc(
- GdkEvent* event,
+ GdkEvent* event __attribute__ ((unused)),
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 __attribute__ ((unused)),
+ const Gdk::Rectangle& cell_area __attribute__ ((unused)),
+ Gtk::CellRendererState flags __attribute__ ((unused)))
{
// If we aren't editable, then there is nothing to do
if(!property_editable())
return 0;
-
+
ValueBase data=property_value_.get_value();
switch(data.get_type())
//case ValueBase::TYPE_TIME:
// property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
// return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-
+
case ValueBase::TYPE_GRADIENT:
App::dialog_gradient->reset();
App::dialog_gradient->set_gradient(data.get(Gradient()));
)
);
App::dialog_gradient->present();
-
+
return NULL;
case ValueBase::TYPE_COLOR:
)
);
App::dialog_color->present();
-
+
return NULL;
case ValueBase::TYPE_STRING:
if(get_param_desc().get_hint()=="paragraph")
{
- sinfg::String string;
+ synfig::String string;
string=data.get(string);
if(get_paragraph(string))
- {
signal_edited_(path,ValueBase(string));
- }
return NULL;
}
- if(get_param_desc().get_hint()!="filename")
- return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+ // if(get_param_desc().get_hint()!="filename")
+ // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
default:
{
assert(get_canvas());
if(old_value!=value)
signal_edited_(value_entry->get_path(),value);
-
+
//delete value_entry;
//value_entry=0;
- }
+ }
}