Re: builder.ui and GtkDrawingArea size
GtkDrawingArea is a widget, so you just write the property width and height in the builder.ui, done! đ On Tue, Feb 27, 2018 at 10:58 AM, Roger Matthews wrote: > How do I set the size, or what are the x and y size of a > GtkDrawingArea in builder.ui, I can't find these in the documentation > anywhere, thanks, > > Roger Matthews > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
builder.ui and GtkDrawingArea size
How do I set the size, or what are the x and y size of a GtkDrawingArea in builder.ui, I can't find these in the documentation anywhere, thanks, Roger Matthews ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re.: GtkDrawingArea size request
Solved. Someone have a example of how to create a custom widget with cairo in C? Thanks Mensagem original Assunto: Fwd: GtkDrawingArea size request De: RĂșben Rodrigues Para: gtk-app-devel-list@gnome.org CC: Someone received my question? Thanks Mensagem reencaminhada Assunto:GtkDrawingArea size request Data: Wed, 21 Jun 2017 10:08:15 +0100 De: RĂșben Rodrigues <mailto:ruben...@live.com.pt> Para: gtk-app-devel-list@gnome.org<mailto:gtk-app-devel-list@gnome.org> <mailto:gtk-app-devel-list@gnome.org> Hi, I create a drawing area to draw a circular gauge with cairo. GtkWidget *drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, 100, 100); gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, "box30")),drawing_area,FALSE,TRUE,0); The problem is that the drawing area is not 100x100 but the entire of screen. This is the callback function: gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { int width, height; gint percentage, linewidth; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0; cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, angle1, angle2); cairo_stroke (cr); cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, 180.0 * (M_PI/180.0),315.0 * (M_PI/180.0) ); cairo_stroke (cr); return FALSE; } [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Sem vĂrus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size request
Hi Ruben, You might consider allowing the gauge to expand with the window size. This makes the gauge a lot more flexible. When drawing a gauge it is useful to get a general coordinate drawing on screen that you can check your gauge drawing with. Both cartesian coordinates and radial coordinates are useful to check your drawing. There is a general layout drawing in the following. https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/gears2.c You can use set sizes if you want to also. To keep your drawing area window size a set size check your vexpand and hexpand properties. Make sure they are false. Try using a GtkGrid instead of a GtkBox. Put the drawing area in a scrolled window and put that in the grid. I have done some work drawing gauges and have a couple packaged as widgets. There are also some drawings of clocks, gauges, gems and gears in the above github cairo_drawings folder. Some resize as circles and some as ellipses. They might be helpful getting something that you can test a gauge drawing with. Eric ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkDrawingArea size request
Hi, I create a drawing area to draw a circular gauge with cairo. GtkWidget *drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, 100, 100); gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, "box30")),drawing_area,FALSE,TRUE,0); The problem is that the drawing area is not 100x100 but the entire of screen. This is the callback function: gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { int width, height; gint percentage, linewidth; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0; cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, angle1, angle2); cairo_stroke (cr); cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, 180.0 * (M_PI/180.0),315.0 * (M_PI/180.0) ); cairo_stroke (cr); return FALSE; } --- Este e-mail foi verificado em termos de vĂrus pelo software antivĂrus Avast. https://www.avast.com/antivirus ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Fwd: GtkDrawingArea size request
There's no reason the drawing area code you're showing shouldn't work. The most obvious possibility is that the size of your enclosing widget (GTK_BOX(gtk_builder_get_object(builder, "box30"))) isn't set right--the default is that your drawing area will expand to fill its parent. On 06/21/17 10:11, RĂșben Rodrigues wrote: Someone received my question? Thanks Mensagem reencaminhada Assunto:GtkDrawingArea size request Data: Wed, 21 Jun 2017 10:08:15 +0100 De: RĂșben Rodrigues <mailto:ruben...@live.com.pt> Para: gtk-app-devel-list@gnome.org<mailto:gtk-app-devel-list@gnome.org> <mailto:gtk-app-devel-list@gnome.org> Hi, I create a drawing area to draw a circular gauge with cairo. GtkWidget *drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, 100, 100); gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, "box30")),drawing_area,FALSE,TRUE,0); The problem is that the drawing area is not 100x100 but the entire of screen. This is the callback function: gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { int width, height; gint percentage, linewidth; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0; cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, angle1, angle2); cairo_stroke (cr); cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, 180.0 * (M_PI/180.0),315.0 * (M_PI/180.0) ); cairo_stroke (cr); return FALSE; } [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Sem vĂrus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Fwd: GtkDrawingArea size request
Someone received my question? Thanks Mensagem reencaminhada Assunto:GtkDrawingArea size request Data: Wed, 21 Jun 2017 10:08:15 +0100 De: RĂșben Rodrigues <mailto:ruben...@live.com.pt> Para: gtk-app-devel-list@gnome.org<mailto:gtk-app-devel-list@gnome.org> <mailto:gtk-app-devel-list@gnome.org> Hi, I create a drawing area to draw a circular gauge with cairo. GtkWidget *drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, 100, 100); gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, "box30")),drawing_area,FALSE,TRUE,0); The problem is that the drawing area is not 100x100 but the entire of screen. This is the callback function: gboolean on_circular_gauge_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { int width, height; gint percentage, linewidth; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); linewidth = (MIN (width, height) / 2.0 * 30.0) / 100.0; cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, angle1, angle2); cairo_stroke (cr); cairo_set_source_rgba (cr, 0.0, 0.9, 0.0, 1.0); cairo_set_line_width (cr, linewidth); cairo_arc(cr, width/2.0, height/2.0, MIN (width, height) / 2.0 - linewidth, 180.0 * (M_PI/180.0),315.0 * (M_PI/180.0) ); cairo_stroke (cr); return FALSE; } [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Sem vĂrus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
Hey if you use Gtk+-3.0 you can use GtkWindow* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable(window, FALSE); This should prevent the resizing and disables the grip. -- GĂŒnther Wutz Student der University of Applied Science Allgemeine Informatik Am Donnerstag, den 08.03.2012, 17:25 -0900 schrieb Christopher Howard: > On 03/08/2012 01:54 AM, Tadej BorovĆĄak wrote: > > Hello. > > > > 2012/3/7 Christopher Howard : > >> Hello again. So, I recently started a project to create a certain board > >> game (in C) using gtk+, and I just started learning gtk+. I was planning > >> to draw the board graphics, pieces, etc. all into one GtkDrawingArea. > >> So, how do I fix the size of the drawing area so it doesn't get larger > >> or smaller than my graphics? > > > > I would add a wrapper GtkAlignment around my drawing area, set it's > > xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack > > GtkDrawingArea inside it and fix it's size using > > gtk_window_set_size_request(). > > > > Have a look at this simple app: > > > > #include > > > > #define WIDTH 300 > > #define HEIGHT 400 > > > > static gboolean > > cb_draw (GtkWidget *w, > > GdkEventExpose *e) > > { > > cairo_t *cr = gdk_cairo_create (e->window); > > cairo_set_source_rgb (cr, 1.0, 1.0, 0.0); > > cairo_paint (cr); > > cairo_destroy (cr); > > > > return TRUE; > > } > > > > int > > main (intargc, > > char **argv) > > { > > GtkWidget *window, > > *align, > > *area; > > > > gtk_init (&argc, &argv); > > > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > > g_signal_connect (window, "destroy", gtk_main_quit, NULL); > > > > align = gtk_alignment_new (0.5, 0.5, 0, 0); > > gtk_container_add (GTK_CONTAINER (window), align); > > > > area = gtk_drawing_area_new (); > > gtk_widget_set_size_request (area, WIDTH, HEIGHT); > > g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL); > > gtk_container_add (GTK_CONTAINER (align), area); > > > > gtk_widget_show_all (window); > > > > gtk_main (); > > > > return 0; > > } > > > > Cheers, > > Tadej > > > > Thanks for the help. Is there a way to turn off the small resizing > graphic that appears at the bottom right of the window? (It looks like > three small diagonal lines.) Even if this did not actually prevent > resizing it would make sense in my case not to have it showing. > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
On 03/08/2012 01:54 AM, Tadej BorovĆĄak wrote: > Hello. > > 2012/3/7 Christopher Howard : >> Hello again. So, I recently started a project to create a certain board >> game (in C) using gtk+, and I just started learning gtk+. I was planning >> to draw the board graphics, pieces, etc. all into one GtkDrawingArea. >> So, how do I fix the size of the drawing area so it doesn't get larger >> or smaller than my graphics? > > I would add a wrapper GtkAlignment around my drawing area, set it's > xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack > GtkDrawingArea inside it and fix it's size using > gtk_window_set_size_request(). > > Have a look at this simple app: > > #include > > #define WIDTH 300 > #define HEIGHT 400 > > static gboolean > cb_draw (GtkWidget *w, > GdkEventExpose *e) > { > cairo_t *cr = gdk_cairo_create (e->window); > cairo_set_source_rgb (cr, 1.0, 1.0, 0.0); > cairo_paint (cr); > cairo_destroy (cr); > > return TRUE; > } > > int > main (intargc, > char **argv) > { > GtkWidget *window, > *align, > *area; > > gtk_init (&argc, &argv); > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > g_signal_connect (window, "destroy", gtk_main_quit, NULL); > > align = gtk_alignment_new (0.5, 0.5, 0, 0); > gtk_container_add (GTK_CONTAINER (window), align); > > area = gtk_drawing_area_new (); > gtk_widget_set_size_request (area, WIDTH, HEIGHT); > g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL); > gtk_container_add (GTK_CONTAINER (align), area); > > gtk_widget_show_all (window); > > gtk_main (); > > return 0; > } > > Cheers, > Tadej > Thanks for the help. Is there a way to turn off the small resizing graphic that appears at the bottom right of the window? (It looks like three small diagonal lines.) Even if this did not actually prevent resizing it would make sense in my case not to have it showing. -- frigidcode.com indicium.us ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
Hello. 2012/3/7 Christopher Howard : > Hello again. So, I recently started a project to create a certain board > game (in C) using gtk+, and I just started learning gtk+. I was planning > to draw the board graphics, pieces, etc. all into one GtkDrawingArea. > So, how do I fix the size of the drawing area so it doesn't get larger > or smaller than my graphics? I would add a wrapper GtkAlignment around my drawing area, set it's xalign and yalign propertes to 0.5, it's xscale and yscale to 0, pack GtkDrawingArea inside it and fix it's size using gtk_window_set_size_request(). Have a look at this simple app: #include #define WIDTH 300 #define HEIGHT 400 static gboolean cb_draw (GtkWidget *w, GdkEventExpose *e) { cairo_t *cr = gdk_cairo_create (e->window); cairo_set_source_rgb (cr, 1.0, 1.0, 0.0); cairo_paint (cr); cairo_destroy (cr); return TRUE; } int main (intargc, char **argv) { GtkWidget *window, *align, *area; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", gtk_main_quit, NULL); align = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (window), align); area = gtk_drawing_area_new (); gtk_widget_set_size_request (area, WIDTH, HEIGHT); g_signal_connect (area, "expose-event", G_CALLBACK (cb_draw), NULL); gtk_container_add (GTK_CONTAINER (align), area); gtk_widget_show_all (window); gtk_main (); return 0; } Cheers, Tadej -- Tadej BorovĆĄak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
On Wed, 2012-03-07 at 09:44 -0900, Christopher Howard wrote: X > > Bump. > > I'm trying to look through some other projects to see how this is done, > but I would appreciate it if anyone happens to know of the top of their > head. I guess you can have a drawingarea of fixed size if you put it in a container of fixed size, ie. make the window fixed size, see http://developer.gnome.org/gtk3/stable/GtkWindow.html#GtkWindow--resizable With cairo it is easy to scale your graphics, and you get all these nice stuff like anti-aliasing, transparency and much more. But cairo is not very fast -- for my current toy project (http://www.ssalewski.de/PetEd.html.de) I had to carefully figure out which redraw operation is really necessary for updating the display. A complete redraw can take more than 100ms -- but now I have fixed that by using bounding boxes for each elements, and redrawing only what has changed. But for fast action games OpenGL may be a better choice. When your application does not need fast graphics, then you may also consider other languages than C -- I am using Ruby currently, next time I may give Vala a try... ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
On 03/07/2012 11:37 AM, Bernhard Schuster wrote: > If you did not yet start implementing it, goocanvas might be another > option to the bare stuff. goocanvas allows you to set a fixed "paper" > size. > > I think the halign and valign properties are what I was looking for. It seems that, if I do an align center, that the widget never grows larger than its requested size, though it still can shrink. code: -- gtk_widget_set_size_request (my_widget, 256, 256); gtk_widget_set_halign(my_widget, GTK_ALIGN_CENTER); gtk_widget_set_valign(my_widget, GTK_ALIGN_CENTER); -- -- frigidcode.com indicium.us ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
If you did not yet start implementing it, goocanvas might be another option to the bare stuff. goocanvas allows you to set a fixed "paper" size. Am 7. MĂ€rz 2012 19:44 schrieb Christopher Howard : > On 03/06/2012 02:08 PM, Christopher Howard wrote: >> Hello again. So, I recently started a project to create a certain board >> game (in C) using gtk+, and I just started learning gtk+. I was planning >> to draw the board graphics, pieces, etc. all into one GtkDrawingArea. >> So, how do I fix the size of the drawing area so it doesn't get larger >> or smaller than my graphics? >> >> The alternative, I suppose, would be to scale everything against the >> actual size of the drawing area (cairo can resize bitmap images, no?) >> but presumably that would be a lot more complicated to code, and I would >> still need to constrain the proportions of width to height. >> >> >> >> >> ___ >> gtk-app-devel-list mailing list >> gtk-app-devel-list@gnome.org >> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > Bump. > > I'm trying to look through some other projects to see how this is done, > but I would appreciate it if anyone happens to know of the top of their > head. > > -- > frigidcode.com > indicium.us > > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkDrawingArea size
On 03/06/2012 02:08 PM, Christopher Howard wrote: > Hello again. So, I recently started a project to create a certain board > game (in C) using gtk+, and I just started learning gtk+. I was planning > to draw the board graphics, pieces, etc. all into one GtkDrawingArea. > So, how do I fix the size of the drawing area so it doesn't get larger > or smaller than my graphics? > > The alternative, I suppose, would be to scale everything against the > actual size of the drawing area (cairo can resize bitmap images, no?) > but presumably that would be a lot more complicated to code, and I would > still need to constrain the proportions of width to height. > > > > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Bump. I'm trying to look through some other projects to see how this is done, but I would appreciate it if anyone happens to know of the top of their head. -- frigidcode.com indicium.us ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkDrawingArea size
Hello again. So, I recently started a project to create a certain board game (in C) using gtk+, and I just started learning gtk+. I was planning to draw the board graphics, pieces, etc. all into one GtkDrawingArea. So, how do I fix the size of the drawing area so it doesn't get larger or smaller than my graphics? The alternative, I suppose, would be to scale everything against the actual size of the drawing area (cairo can resize bitmap images, no?) but presumably that would be a lot more complicated to code, and I would still need to constrain the proportions of width to height. -- frigidcode.com indicium.us ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list