Comments (1)
Problem is that the DrawingArea class is not yet inheritable. Therefore the new()
method did not make a native object. The below code works although it's a bit contrived now after some changes.
use Gnome::Gtk3::Window;
use Gnome::Gtk3::Main;
use Gnome::Gtk3::Grid;
use Gnome::Gtk3::EventBox;
use Gnome::Gtk3::DrawingArea;
use Gnome::Gdk3::Events;
use Gnome::Cairo;
use Gnome::Cairo::Types;
use Gnome::Cairo::Enums;
use Gnome::N::GlibToRakuTypes;
use Gnome::N::X;
Gnome::N::debug(:on);
class Events {
method exit {
Gnome::Gtk3::Main.new.quit;
}
}
class DA {
has Gnome::Gtk3::DrawingArea $.da;
submethod BUILD ( ) {
$!da .= new;
$!da.register-signal( self, 'on-draw', 'draw');
$!da.set-hexpand(True);
$!da.set-vexpand(True);
}
my gdouble $zero = 0e0;
method on-draw(cairo_t $cr) {
my Gnome::Cairo $surface .= new(:native-object($cr));
given $surface {
.set-source-rgb($zero, $zero, $zero);
.set-line-width(2);
.move-to(10,10);
.line-to(30, 23);
.stroke;
}
}
}
my Gnome::Gtk3::Window $w .= new;
my Gnome::Gtk3::Grid $g .= new;
my DA $da .= new;
my Events $e .= new;
$g.attach( $da.da, 0, 0 , 1, 1);
$w.add($g);
$w.register-signal($e, 'exit', 'destroy');
$w.show-all;
Gnome::Gtk3::Main.new.main;
I will make the class inheritable but it will take some time before I publish it because I was working on some other classes as well. I also think that TWEAK()
is not necessary, BUILD()
will do.
from gnome-gtk3.
Related Issues (20)
- crash when using threads on X11 HOT 1
- gtk_tree_selection_get_selected() in Gnome::Gtk3::TreeSelection returns error HOT 1
- native types are not always used properly HOT 1
- Installing Gnome::Gtk3 on Windows 10, MSYS2 : Cannot locate native library '(null)': error 0x7e HOT 28
- packages getting larger and slower HOT 1
- Ubuntu 20.04, failed test 'class is a 'text-button' at t/WidgetPath.t line 77 HOT 5
- Module does not install on windows HOT 5
- Could not find Gnome::Gtk3::Main HOT 1
- Can't create signal for DrawingArea HOT 9
- Container.get-children causes application to freeze HOT 3
- Returning True from delete-event signal doesn't leave window open HOT 11
- How to go through each page in a GtkNotebook HOT 5
- Can't connect to "scroll-event" signal HOT 2
- Are templates not implemented yet? HOT 1
- Problem installing on older MacOS (10.11 El Capitan) HOT 7
- Test case failures on debian 11 (bullseye) HOT 1
- Zef can't find Gnome::Glib HOT 19
- Cannot use classes as a parent class HOT 3
- Programs crash with core dumps HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnome-gtk3.