Skip Menu |

This queue is for tickets about the GooCanvas2 CPAN distribution.

Report information
The Basics
Id: 133659
Status: new
Priority: 0/
Queue: GooCanvas2

People
Owner: Nobody in particular
Requestors: SLAFFAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: document and/or fully implement set_transform
It is unclear how to call the set_transform() method, and my various attempts to set one using array refs and flat arrays of parameters has failed. Looking at the internals, it would appear that the underlying library needs a CairoMatrix object, but I am also unable to generate one of these. This is perhaps related to this Stack Overflow question, in which the solution was to call a get method to obtain an object that can then be used. https://stackoverflow.com/questions/64625955/cairosolidpattern-is-not-of-type-goocanvas2cairopattern However, get_transform() returns an undef second argument, even when set_transform() has been called to reset the transform, so that approach will not work. I note that the GooCanvas2 GIO setup has the comment below. Maybe the Gtk perl list can be consulted? # HANDLE SENTINAL BOOLEAN FOR # Unsicher bin ich mir bei GooCanvas2::CanvasItem::get_transform # GooCanvas2::CanvasItem::get_simple_transform ist an sich eine Funktion, die ein # bool'sches und weitere out-Argumente zurückgibt. Allerdings sind diese nicht NULL # wenn die Funktion unwahr zurückgibt (sd. bspw. undef, 0, 0, 1, 0). Daher lass ich es raus. # Das selbe gilt für die entsprechenden Funktionen in CanvasItem (get_transform # und get_simple_transform) Thanks, Shawn.
I've now worked out how to generate the Cairo::Matrix object, but get a seg fault when applying it. The code below is an adaptation of the module synopsis. The set_transform call results in "ERROR:gperl-i11n-marshal-struct.c:119:sv_to_struct: assertion failed: (package)" #### use strict; use warnings; use 5.022; local $| = 1; use Gtk3 -init; use GooCanvas2; my $window = Gtk3::Window->new(); $window->set_default_size(640, 600); $window->signal_connect('destroy' => sub {Gtk3->main_quit()}); my $scrolled_win = Gtk3::ScrolledWindow->new(); $scrolled_win->set_shadow_type('in'); my $canvas = GooCanvas2::Canvas->new(); $canvas->set_size_request(600,450); $canvas->set_bounds(0,0,1000,1000); $scrolled_win->add($canvas); my $root = $canvas->get_root_item(); my $rect_item = GooCanvas2::CanvasRect->new( 'parent' => $root, 'x' => 100, 'y' => 100, 'width' => 300, 'height' => 400, 'line_width' => 10.0, 'radius-x' => 20.0, 'radius-y' => 10.0, 'stroke-color' => 'yellow', 'fill-color' => 'red', ); my $mx = Cairo::Matrix->init (1, 0, 0, 1, 1, 1); # this fails my $tfm = eval { $rect_item->set_transform ($mx); }; say $@ if $@; say 'Getting transform'; my (@tt) = eval { $rect_item->get_transform; }; say $@ if $@; say join ' ', map {$_ // 'undef'} @tt; # Connect a signal handler for the rectangle item. $rect_item->signal_connect('button_press_event' => \&on_rect_button_press); $window->add($scrolled_win); $window->show_all; # Pass control to the Gtk3 main event loop Gtk3->main(); # This handles button presses in item views. #We simply output a message to the console sub on_rect_button_press { my ($item, $target, $event) = @_; print "rect item received button press event \n"; return 1; } ####