This allows to use enum widgets for integer values on linkable value node child parameters.
It still seeing the bug of set the enum when the value is =1 that probably is due to the Gtk::OptionMenu is deprecated.
valuewidget->set_param_desc(data);
}
+ void set_child_param_desc(const synfig::ParamDesc &data)
+ {
+ if(valuewidget)
+ valuewidget->set_child_param_desc(data);
+ }
+
const synfig::ValueBase &get_value()
{
if(valuewidget)
Gtk::CellRendererText (),
property_value_ (*this,"value",synfig::ValueBase()),
property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
- property_param_desc_(*this,"param_desc",synfig::ParamDesc())
+ property_param_desc_(*this,"param_desc",synfig::ParamDesc()),
+ property_child_param_desc_(*this,"child_param_desc", synfig::ParamDesc())
{
CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
value_entry=new ValueBase_Entry();
property_text()=(Glib::ustring)strprintf("%.2fᵒ",(Real)Angle::deg(data.get(Angle())).get());
break;
case ValueBase::TYPE_INTEGER:
- 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<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()))
- {
- // don't show the key_board s_hortcut under_scores
- String local_name = iter->local_name;
- String::size_type pos = local_name.find_first_of('_');
- if (pos != String::npos)
- property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
- else
- property_text() = local_name;
- break;
- }
+ String param_hint, child_param_hint;
+ param_hint=get_param_desc().get_hint();
+ child_param_hint=get_child_param_desc().get_hint();
+ if(param_hint!="enum" && child_param_hint!="enum")
+ {
+ property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
+ }
+ else
+ {
+ property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
+ std::list<synfig::ParamDesc::EnumData> enum_list;
+ if(param_hint=="enum")
+ enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
+ else if(child_param_hint=="enum")
+ enum_list=((synfig::ParamDesc)property_child_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()))
+ {
+ // don't show the key_board s_hortcut under_scores
+ String local_name = iter->local_name;
+ String::size_type pos = local_name.find_first_of('_');
+ if (pos != String::npos)
+ property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
+ else
+ property_text() = local_name;
+ break;
+ }
+ }
}
-
break;
+
case ValueBase::TYPE_VECTOR:
{
Vector vector=data.get(Vector());
value_entry->set_path(path);
value_entry->set_canvas(get_canvas());
value_entry->set_param_desc(get_param_desc());
+ value_entry->set_child_param_desc(get_child_param_desc());
value_entry->set_value(data);
value_entry->set_parent(&widget);
value_entry->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_ValueBase::on_value_editing_done));
Glib::Property<synfig::ValueBase> property_value_;
Glib::Property<etl::handle<synfig::Canvas> > property_canvas_;
Glib::Property<synfig::ParamDesc> property_param_desc_;
+ Glib::Property<synfig::ParamDesc> property_child_param_desc_;
void string_edited_(const Glib::ustring&,const Glib::ustring&);
Glib::PropertyProxy<synfig::ValueBase> property_value() { return property_value_.get_proxy();}
Glib::PropertyProxy<etl::handle<synfig::Canvas> > property_canvas() { return property_canvas_.get_proxy();}
Glib::PropertyProxy<synfig::ParamDesc> property_param_desc() { return property_param_desc_.get_proxy(); }
+ Glib::PropertyProxy<synfig::ParamDesc> property_child_param_desc() { return property_child_param_desc_.get_proxy(); }
Glib::PropertyProxy<bool> property_inconsistent() { return property_foreground_set(); }
etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
+ synfig::ParamDesc get_child_param_desc()const { return property_child_param_desc_; }
CellRenderer_ValueBase();
~CellRenderer_ValueBase();
if(linkable && do_children)
{
row[model.link_count] = linkable->link_count();
- for(int i=0;i<linkable->link_count();i++)
+ LinkableValueNode::Vocab vocab(linkable->get_param_vocab());
+ LinkableValueNode::Vocab::iterator iter(vocab.begin());
+ for(int i=0;i<linkable->link_count();i++, iter++)
{
Gtk::TreeRow child_row=*(append(row.children()));
child_row[model.link_id] = i;
child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
child_row[model.name] = linkable->link_local_name(i);
+ child_row[model.tooltip] = iter->get_description();
+ child_row[model.child_param_desc] = *iter;
set_row(child_row,synfigapp::ValueDesc(linkable,i));
}
}
Gtk::TreeModelColumn<bool> is_exported;
Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
+ Gtk::TreeModelColumn<synfig::ParamDesc> child_param_desc;
Gtk::TreeModelColumn<Glib::ustring> tooltip;
add(is_exported);
add(is_editable);
add(value_desc);
+ add(child_param_desc);
add(link_count);
add(link_id);
cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_edited_value));
cellrenderer_value->property_value()=synfig::ValueBase();
column->add_attribute(cellrenderer_value->property_param_desc(), param_model.param_desc);
+ column->add_attribute(cellrenderer_value->property_child_param_desc(), param_model.child_param_desc);
column->add_attribute(cellrenderer_value->property_inconsistent(),param_model.is_inconsistent);
//cellrenderer_value->property_canvas()=canvas_interface->get_canvas(); // Is this line necessary?
cellrenderer_value->property_attributes()=attr_list;
vector_widget->show();
break;
case ValueBase::TYPE_REAL:
- if(param_desc.get_is_distance() && canvas)
+ if(( child_param_desc.get_is_distance() || param_desc.get_is_distance() )&& canvas)
{
Distance dist(value.get(Real()),Distance::SYSTEM_UNITS);
dist.convert(App::distance_system,canvas->rend_desc());
angle_widget->show();
break;
case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
- {
- integer_widget->set_value(value.get(int()));
- integer_widget->show();
- }
- else
{
- enum_widget->set_param_desc(param_desc);
- enum_widget->set_value(value.get(int()));
- enum_widget->show();
+ String child_param_hint(child_param_desc.get_hint());
+ String param_hint(param_desc.get_hint());
+ if(child_param_hint!="enum" && param_hint!="enum")
+ {
+ integer_widget->set_value(value.get(int()));
+ integer_widget->show();
+ }
+ else
+ {
+ if(child_param_hint=="enum")
+ enum_widget->set_param_desc(child_param_desc);
+ else
+ enum_widget->set_param_desc(param_desc);
+ enum_widget->set_value(value.get(int()));
+ enum_widget->show();
+ }
}
break;
case ValueBase::TYPE_CANVAS:
bool_widget->show();
break;
case ValueBase::TYPE_STRING:
- if(param_desc.get_hint()!="filename")
+ if(child_param_desc.get_hint()!="filename" && param_desc.get_hint()!="filename")
{
string_widget->set_text(value.get(string()));
string_widget->show();
value=canvas_widget->get_value();
break;
case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
+ if(child_param_desc.get_hint()!="enum" && param_desc.get_hint()!="enum")
{
value=integer_widget->get_value_as_int();
}
canvas_widget->grab_focus();
break;
case ValueBase::TYPE_INTEGER:
- if(param_desc.get_hint()!="enum")
+ if(child_param_desc.get_hint()!="enum" && param_desc.get_hint()!="enum")
{
integer_widget->grab_focus();
}
// std::string hint;
synfig::ParamDesc param_desc;
+ synfig::ParamDesc child_param_desc;
etl::handle<synfig::Canvas> canvas;
sigc::signal<void> signal_value_changed_;
sigc::signal<void> signal_activate_;
void set_param_desc(const synfig::ParamDesc &x) { param_desc=x; }
const synfig::ParamDesc &get_param_desc() { return param_desc; }
+ void set_child_param_desc(const synfig::ParamDesc &x) { child_param_desc=x; }
+ const synfig::ParamDesc &get_child_param_desc() { return child_param_desc; }
+
void set_sensitive(bool x);
//void set_hint(std::string x) { hint=x; }