Re: [Vala] Any tips for newbies




 Hi, 

On Wednesday, 19 September 2018, 09:57:22 BST, Robin Wils via vala-list <vala-list gnome org> wrote: > I am 
working on a [small simple project](https://gitlab.com/RobinWils/BAG-art-creator/tree/master) and have a 
feeling that
the GNOME Vala website only contains some basics.
I use a grid which I want to be able to resize when a menu_button gets clicked so I probably need a way to 
recreate/refresh the grid.

Your project seems to need two widgets: a color palette for selecting colors and an interactive grid that 
allows the color of each square in the grid to be changed. You may want to consider custom GTK widgets for 
this. I've collected a few links, but have not put this in to practise myself. From what I understand a 
custom widget inherits from Gtk.DrawingArea and uses Cairo to render the contents.

Some guides I've found:
 - https://codeburst.io/how-to-build-a-custom-gtk-widget-with-haskell-eaff04a6262 - 'How To Build A Custom 
GTK Widget With Haskell', I found this explained the principles very well, although the code isn't too 
relevant because it is in Haskell
 - https://wiki.gnome.org/Projects/Vala/CustomWidgetSamples - this is the Vala code sample, but you probably 
want to understand a bit more about how things work in GTK before coding anything up - 
https://developer.gnome.org/gtkmm-tutorial/stable/chapter-drawingarea.html.en - this provides a good overview 
of the principles, although the code examples are C++
 - https://valadoc.org/gtk+-3.0/Gtk.DrawingArea.html - also includes a small Vala code sample
 - https://stackoverflow.com/questions/9395111/gtkdrawingarea-how-to-make-it-drawable - may be useful to help 
understand the 'draw' signal a bit better
There is also the concept of off screen windows in GTK, but I don't know enough to explain it.

Hope that helps,

Al















[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]