Enable tooltips and allow use the 'hint' descriptor for some types for the linkable...
authorCarlos Lopez <genetita@gmail.com>
Sun, 12 Dec 2010 12:52:57 +0000 (13:52 +0100)
committerCarlos Lopez <genetita@gmail.com>
Sun, 2 Jan 2011 07:19:34 +0000 (08:19 +0100)
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.

synfig-studio/src/gui/cellrenderer/cellrenderer_value.cpp
synfig-studio/src/gui/cellrenderer/cellrenderer_value.h
synfig-studio/src/gui/trees/canvastreestore.cpp
synfig-studio/src/gui/trees/canvastreestore.h
synfig-studio/src/gui/trees/layertree.cpp
synfig-studio/src/gui/widgets/widget_value.cpp
synfig-studio/src/gui/widgets/widget_value.h

index 553a517..3c9c699 100644 (file)
@@ -197,6 +197,12 @@ public:
                        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)
@@ -265,7 +271,8 @@ CellRenderer_ValueBase::CellRenderer_ValueBase():
        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();
@@ -359,31 +366,39 @@ CellRenderer_ValueBase::render_vfunc(
                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());
@@ -570,6 +585,7 @@ CellRenderer_ValueBase::start_editing_vfunc(
                        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));
index 14a425d..2d1e21f 100644 (file)
@@ -81,6 +81,7 @@ class CellRenderer_ValueBase : public Gtk::CellRendererText
        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&);
 
@@ -98,10 +99,12 @@ public:
        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();
index 6b928f1..77ffe4b 100644 (file)
@@ -427,12 +427,16 @@ CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool
                        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));
                                }
                        }
index d7e119a..b302db1 100644 (file)
@@ -87,6 +87,7 @@ public:
                Gtk::TreeModelColumn<bool> is_exported;
 
                Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
+               Gtk::TreeModelColumn<synfig::ParamDesc> child_param_desc;
 
                Gtk::TreeModelColumn<Glib::ustring> tooltip;
 
@@ -107,6 +108,7 @@ public:
                        add(is_exported);
                        add(is_editable);
                        add(value_desc);
+                       add(child_param_desc);
                        add(link_count);
                        add(link_id);
 
index a17529e..66884c4 100644 (file)
@@ -315,6 +315,7 @@ LayerTree::create_param_tree()
                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;
index ee0366f..be291fa 100644 (file)
@@ -221,7 +221,7 @@ Widget_ValueBase::set_value(const synfig::ValueBase &data)
                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());
@@ -244,16 +244,23 @@ Widget_ValueBase::set_value(const synfig::ValueBase &data)
                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:
@@ -267,7 +274,7 @@ Widget_ValueBase::set_value(const synfig::ValueBase &data)
                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();
@@ -324,7 +331,7 @@ Widget_ValueBase::get_value()
                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();
                }
@@ -395,7 +402,7 @@ Widget_ValueBase::on_grab_focus()
                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();
                }
index 18f272f..6b15397 100644 (file)
@@ -99,6 +99,7 @@ class Widget_ValueBase : public Gtk::HBox
 //     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_;
@@ -118,6 +119,9 @@ public:
        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; }