Skip to content

Implement canvasproperties glade file #1552

Closed

Description

@Keyikedalube

Synfig version & platform:
Building from master branch
Debian sid

Issue description:
To ease UI designers, it's wise to separate the handwritten UI code from canvasproperties.cpp to its own glade (UI) file
And implement only the logic inside the .cpp file

That way it'll be much easier to focus only on the design aspects without having to refer to GTKMM API docs all the time

Activity

  1. Keyikedalube commented on Jul 13, 2020

    @Keyikedalube
    ContributorAuthor

    I'm experimenting/working on this issue ;)

  2. rodolforg commented on Jul 13, 2020

    @rodolforg
    Contributor

    @Keyikedalube Great :D

    Synfig Custom widgets should support GtkBuilder (it should be Gtk::Buildable). I made something here 025eec2 for Widget_Time - this allow us to refer to them on Glade too (but with a placeholder - not the real appearance)

    I converted a dialog to UI here 9207c07 .

    Ideally, we would have a library (.so/dll/dynlib) for collecting custom widgets to be able to preview better the dialogs on Glade.
    I don't know if it would be possible as they're in C++ though.

  3. Keyikedalube commented on Jul 15, 2020

    @Keyikedalube
    ContributorAuthor

    I'm trying to separate GammaPattern from renddesc.cpp to its own source file but I'm stuck with this error

    gammapattern.h:13:2: error: ‘Gamma’ does not name a type; did you mean ‘gamma’?

    I believe this include is the correct one to successfully build GammaPattern class

    #include <synfig/renddesc.h>

    Here's how I implemented the gammapattern.h file

    #ifndef __SYNFIG_GTKMM_GAMMAPATTERN_H
    #define __SYNFIG_GTKMM_GAMMAPATTERN_H
    
    #include <gtkmm/drawingarea.h>
    
    #include <synfig/renddesc.h>
    
    namespace studio {
    
    class GammaPattern : public Gtk::DrawingArea
    {
    	Gamma gamma;
    	int tile_w, tile_h, gradient_h;
    	Cairo::RefPtr<Cairo::SurfacePattern> pattern;
    	
    public:
    	GammaPattern();
    
    	void set_gamma(const Gamma &);
    	const Gamma &get_gamma();
    
    	virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &);
    };
    
    };
    
    #endif

    I'm using CMake to build synfig for now. I've included the definition file in target_sources(synfigstudio ...)
    What am I missing?

  4. ice0 commented on Jul 15, 2020

    @ice0
    Collaborator

    You need to use synfig::Gamma, it added indirectly via using namespace synfig;

  5. Keyikedalube commented on Jul 16, 2020

    @Keyikedalube
    ContributorAuthor

    @ice0 Thanks! How stupid of me. I did not notice that I inserted using namespace synfig in the .cpp implementation file and I missed the error message indicating .h
    I was too tired and a bit desperate ;P

    Anyway, so much thanks for the pointer!

  6. rodolforg commented on Jul 16, 2020

    @rodolforg
    Contributor

    Why are you including synfig/renddesc.h instead of synfig/gamma.h (in the header file) ?

  7. Keyikedalube commented on Jul 16, 2020

    @Keyikedalube
    ContributorAuthor

    Thanks @rodolforg :)

    Had to use synfig/color/gamma.h though
    make couldn't find synfig/gamma.h

  8. Keyikedalube commented on Jul 16, 2020

    @Keyikedalube
    ContributorAuthor

    // The root canvas doesn't have an ID, so don't
    // display it if this is a root canvas.
    if(!canvas_interface_->get_canvas()->is_root())
    {
    Gtk::Label *idLabel = manage(new Gtk::Label(_("_ID"), true));
    idLabel->set_alignment(0, 0.5);
    idLabel->set_mnemonic_widget(entry_id);
    info_table->attach(*idLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
    info_table->attach(entry_id, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
    }

    Is the idLabel & entry_id output for the above code like this? (But hidden)
    Screenshot from 2020-07-16 17-29-46

    Because I haven't seen an actual dialog with that idLabel and entry_id on it...

  9. rodolforg commented on Jul 17, 2020

    @rodolforg
    Contributor

    As far as I understood reading the code, this field is for rendering exported canvas.

    However, I don't know a GUI way to call this dialog for those canvases

  10. rodolforg commented on Jul 17, 2020

    @rodolforg
    Contributor

    Ok, I got it.

    You must open the exported canvas via Canvas Navigator panel. :)

    You can export canvas by exporting value of the "canvas" (¬¬) parameter of a Group Layer, for example.

  11. Keyikedalube commented on Jul 17, 2020

    @Keyikedalube
    ContributorAuthor

    Thanks! Tested it and got ID output in the top :)
    Screenshot from 2020-07-17 07-20-51

  12. Keyikedalube commented on Jul 18, 2020

    @Keyikedalube
    ContributorAuthor

    Implementing Widget_Link as custom widget

    The constructor for Widget_Link takes two std::string arguments
    I don't really know how to pass those args to Glib::wrap part

    Glib::wrap_register(gtype, Widget_Link::wrap);

    Web is not helping much either. Can't even find the doc about it

  13. Keyikedalube commented on Jul 18, 2020

    @Keyikedalube
    ContributorAuthor

    I think there's no way to send tooltip message string when we try to widget_link->get_widget("widget_name", widget) from glade file

    Instead, we would have to set the tooltip message directly on the glade file using

    <object ...>
      <property name="tooltip_text">Click to link/unlink</property>
    </object>

    I guess the only downside to this would be static message instead of the dynamic one synfig has right now

  14. rodolforg commented on Jul 18, 2020

    @rodolforg
    Contributor

    AFAIK, WrapNewFunction passed in void Glib::wrap_register(GType type, WrapNewFunction func) takes the allocated C object into a new C++ object, calling the YourClass(BaseObjectType* cobject) constructor (I'm calling it C-wrap constructor).

    In this case, BaseObjectType is GtkToggleButton, that doesn't take those parameters in current single C++ constructor of Widget_Link.

    Workaround here is easy: create a default constructor (without any parameters): it's "just" tooltips anyway.
    So the C-wrap constructor can work normally.
    Then, via glade/gtkbuilder properties, you load the custom tooltips. I don't remember know how to do it, if I did it before XD


    Yes, it's very poorly documented.

    Here's some related info around the web:

  15. 1 remaining item

  16. rodolforg commented on Jul 18, 2020

    @rodolforg
    Contributor

    @Keyikedalube that's the way: you'll implement Glib::Property ;)

    // .h
    #include <glibmm/property.h>
    
    private:
    	Glib::Property<std::string> property_mine_;
    public:
    	Glib::PropertyProxy<std::string> property_mine() { return property_mine_.get_proxy();}
    // .cpp
    Widget_X::Widget_X() :
    	Glib::ObjectBase("widget_x"), // name in glade: gtkmm__CustomObject_widget_x
    	property_mine_(*this, "property_name_for_glade", "My default") // third argument is optional
    {
    	init();
    }
    
    Widget_X::Widget_X(BaseObjectType* cobject) :
    	Glib::ObjectBase("widget_x"), // name in glade: gtkmm__CustomObject_widget_x
    	Gtk::Entry(cobject),
    	property_mine_(*this, "property_name_for_glade", "My default") // third argument is optional
    {
    	init();
    }
    
    void
    Widget_X::init()
    {
    	set_tooltip_text(property_mine_.get_value());
    }
  17. Keyikedalube commented on Jul 19, 2020

    @Keyikedalube
    ContributorAuthor

    About 80% done...

    Glade file is too ugly now with lots of custom widgets
    Peek 2020-07-19 20-28

    Derived GtkToggleButton implemented in synfig ie., Widget_Link is too simple
    No special added feature at all
    I feel it's better adding the standard GtkToggleButton from Glade options and programmatically manipulating the icons
    Haven't tried it yet

    And here's how the loaded glade dialog looks after building and running
    Screenshot from 2020-07-19 20-25-07

  18. rodolforg commented on Jul 19, 2020

    @rodolforg
    Contributor

    Did you try to add the custom widgets in synfig glade catalog xml?

  19. Keyikedalube commented on Jul 19, 2020

    @Keyikedalube
    ContributorAuthor

    Yes

    So far gammapattern and widget_link have been implemented as custom widgets

  20. rodolforg commented on Jul 20, 2020

    @rodolforg
    Contributor

    Did you see that notebook container is a separated widget? It's also used in other dialogs, like Render.

  21. Keyikedalube commented on Jul 20, 2020

    @Keyikedalube
    ContributorAuthor

    Yes, I noticed that

    For CanvasProperties I'm duplicating the notebook container all over again
    That way I don't have to modify three separate classes which would be tedious

    The only modification made to Widget_Render is separating out GammaPattern to its own file so both Widget_Render and CanvasProperties class can instantiate GammaPattern object by including it as a header file
    One invokes it with pure C++ code and the other invokes it as a custom widget inside the glade file

    Once this issue is done, Widget_Render (notebook container) can be safely deprecated and new Render dialog #721 can be implemented in the future

  22. Keyikedalube commented on Jul 21, 2020

    @Keyikedalube
    ContributorAuthor

    Implementation is done but I haven't modified the build script for Autotools yet

    On CMake, a new build target is implemented called build_resource, this time our resource (glade file) is generated to a C file using glib-compile-resources tool and later compiled with synfigstudio. That way we don't have to ship the .glade file because the UI is loaded as library.

    There is a bug (and maybe more) with the newly implemented CanvasPorperties class. I'm working on fixing it before submitting the PR

    PS: For compiling gresource on Autotools, I might ditch it if the above pending issue persists. It's new to me :(

  23. Keyikedalube commented on Jul 22, 2020

    @Keyikedalube
    ContributorAuthor

    Made the PR

    Couldn't solve the above post-issue... More info on the PR

  24. Keyikedalube commented on Jul 23, 2020

    @Keyikedalube
    ContributorAuthor

    Behavior issue solved in commit d1ebfd8
    Whew..!

    Need help with updating the Autotools build script

  25. rodolforg commented on Jul 23, 2020

    @rodolforg
    Contributor

    Need help with updating the Autotools build script

    I can help with that, but not right now…

  26. added a commit that references this issue on Jul 26, 2020
    6d9ebf4
  27. added a commit that references this issue on Oct 15, 2020
    bdb71e6
  28. Keyikedalube commented on Nov 2, 2020

    @Keyikedalube
    ContributorAuthor

    Closed in favor of #777

    Reason discussed here and here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions