Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to use Cairo in DrawingArea #69

Closed
finanalyst opened this issue Nov 14, 2016 · 5 comments
Closed

Trying to use Cairo in DrawingArea #69

finanalyst opened this issue Nov 14, 2016 · 5 comments

Comments

@finanalyst
Copy link
Owner

The Cairo documentation is sparse and there is no example for the use of DrawingArea.

Also the following error is puzzling:
$perl6 test_lib.p6
Could not find symbol '&ConnectionHandler'
in method add-draw-handler at /home/richard/perl6/rakudo-star-2016.07/install/share/perl6/site/sources/A6D434FC7BEE2A422FB2B8F6CF413E78905D1848 (GTK::Simple::DrawingArea) line 33
in block at test_lib.p6 line 20
Actually thrown at:
in method add-draw-handler at /home/richard/perl6/rakudo-star-2016.07/install/share/perl6/site/sources/A6D434FC7BEE2A422FB2B8F6CF413E78905D1848 (GTK::Simple::DrawingArea) line 33
in block at test_lib.p6 line 20

$ cat test_lib.p6
#!/usr/bin/env perl6
use v6.c;
use GTK::Simple;
use Cairo;
use GTK::Simple::DrawingArea;

my $app = GTK::Simple::App.new(:title);
my $da = GTK::Simple::DrawingArea.new;
gtk_simple_use_cairo;

$app.set-content( $da );
$app.border-width = 20;
$da.size-request(300,300);
my $ctx = $da.add-draw-handler( &rect-do );
$app.run;

sub rect-do( $d, $ctx ) {
given $ctx {
.rgb(0, 0.7, 0.9);
.rectangle(10, 10, 50, 50);
.fill :preserve; .rgb(1, 1, 1);
.stroke
};
}

@jonathanstowe
Copy link
Contributor

The GTK::Simple::DrawingArea.add-draw-handler references some type that isn't defined. I'll take a look later.

jonathanstowe added a commit that referenced this issue Nov 14, 2016
@jonathanstowe
Copy link
Contributor

That may fix that problem but there may be another issue

dwarring added a commit to dwarring/gtk-simple that referenced this issue Jun 19, 2017
To get the following to work (display aqua square)

use v6.c;
use GTK::Simple;
use GTK::Simple::DrawingArea;

my $app = GTK::Simple::App.new(:title<Test>);
my $da = GTK::Simple::DrawingArea.new;
gtk_simple_use_cairo;

$app.set-content( $da );
$app.border-width = 20;
$da.size-request(300,300);

sub rect-do( $d, $ctx ) {
    given $ctx {
	.rgb(0, 0.7, 0.9);
	.rectangle(10, 10, 50, 50);
	.fill :preserve; .rgb(1, 1, 1);
	.stroke
    };
}

my $ctx = $da.add-draw-handler( &rect-do );
$app.run;
dwarring added a commit that referenced this issue Jun 19, 2017
fix gtk_simple_use_cairo() as per issue #69
@dwarring
Copy link
Contributor

@finanalyst
Please try again with latest Gtk::Simple, and Cairo, and with slightly amended code sample as below

use v6.c;
use GTK::Simple;
use GTK::Simple::DrawingArea;

my $app = GTK::Simple::App.new(:title<Test>);
my $da = GTK::Simple::DrawingArea.new;
gtk_simple_use_cairo;

$app.set-content( $da );
$app.border-width = 20;
$da.size-request(300,300);

sub rect-do( $d, $ctx ) {
    given $ctx {
	.rgb(0, 0.7, 0.9);
	.rectangle(10, 10, 50, 50);
	.fill :preserve; .rgb(1, 1, 1);
	.stroke
    };
}

my $ctx = $da.add-draw-handler( &rect-do );
$app.run;

@dwarring
Copy link
Contributor

I've also added this as examples/18-cairo-draw-handler.pl6 e42501e

@dwarring
Copy link
Contributor

dwarring commented Jul 5, 2017

Please reopen, if there's any further problems.

@dwarring dwarring closed this as completed Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants