-
Notifications
You must be signed in to change notification settings - Fork 7
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
Gtk4 port #53
Merged
Merged
Gtk4 port #53
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e74678a
use Gtk4
jwahlstrand fcc8b74
support "focus-leave" event for textbox, restore some tests
jwahlstrand 8058b4a
fix some tests
jwahlstrand 8bc3870
add XML file (formerly player.glade)
jwahlstrand aa1109b
restore commented out code, fix a crash in slider
jwahlstrand 2925bda
fix slider
jwahlstrand 21ab3f3
fix zoom-scroll at mouse position
jwahlstrand 6697a77
work on precompile code
jwahlstrand 73bf4b5
fix a few doctest problems, remove 1.3 from CI
jwahlstrand 371a715
fix the canvas precompiles that I know how to fix
jwahlstrand 340dad9
don't open windows during precompilation
jwahlstrand 7475499
bump Gtk4 compat
jwahlstrand 6bba9e6
implement rest of tests
jwahlstrand 9db5582
add precompile code for events with modifiers
jwahlstrand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,9 @@ Let's begin by creating a window with a canvas in it: | |
|
||
```julia | ||
using GtkObservables, Colors | ||
using GtkObservables.Gtk | ||
using GtkObservables.Gtk.ShortNames | ||
using GtkObservables.Gtk4 | ||
|
||
win = Window("Drawing") | ||
win = GtkWindow("Drawing") | ||
c = canvas(UserUnit) # create a canvas with user-specified coordinates | ||
push!(win, c) | ||
``` | ||
|
@@ -34,7 +33,7 @@ We're going to set this up so that a new line is started when the user | |
clicks with the left mouse button; when the user releases the mouse | ||
button, the line is finished and added to a list of previously-drawn | ||
lines. Consequently, we need a place to store user data. We'll use | ||
Signals, so that our Canvas will be notified when there is new | ||
Observables, so that our Canvas will be notified when there is new | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
material to draw: | ||
|
||
```julia | ||
|
@@ -116,9 +115,9 @@ by monitoring `lines` from the command line by clicking, dragging, and | |
releasing. | ||
|
||
However, it's much more fun to see it in action. Let's set up a | ||
[`draw`](http://juliagraphics.github.io/Gtk.jl/latest/manual/canvas.html) | ||
[`draw`](http://juliagtk.github.io/Gtk4.jl/dev/manual/canvas.html) | ||
method for the canvas, which will be called (1) whenever the window | ||
resizes (this is arranged by Gtk.jl), or (2) whenever `lines` or | ||
resizes (this is arranged by Gtk4.jl), or (2) whenever `lines` or | ||
`newline` update (because we supply them as arguments to the `draw` | ||
function): | ||
|
||
|
@@ -127,7 +126,7 @@ function): | |
redraw = draw(c, lines, newline) do cnvs, lns, newl # the function body takes 3 arguments | ||
fill!(cnvs, colorant"white") # set the background to white | ||
set_coordinates(cnvs, BoundingBox(0, 1, 0, 1)) # set coordinates to 0..1 along each axis | ||
ctx = Gtk.getgc(cnvs) # gets the "graphics context" object (see Cairo/Gtk) | ||
ctx = Gtk4.getgc(cnvs) # gets the "graphics context" object (see Cairo/Gtk) | ||
for l in lns | ||
drawline(ctx, l, colorant"blue") # draw old lines in blue | ||
end | ||
|
@@ -148,13 +147,13 @@ end | |
``` | ||
|
||
**Important note:** Only modify the canvas inside the `draw` function, and pass | ||
all observables that you want to consume as additional arguments (the example shows | ||
all observables that you want to consume as additional arguments (the example shows | ||
three, but you may pass as few or as many as you wish). Otherwise, you | ||
may find the rendering behaves unexpectedly. | ||
|
||
A lot of these commands come from Cairo.jl and/or Graphics.jl. | ||
|
||
Our application is done! (But don't forget to `showall(win)`.) Here's a | ||
Our application is done! Here's a | ||
picture of me in the middle of a very fancy drawing: | ||
|
||
![drawing](assets/drawing.png) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't have to be fixed in this PR, but we'd want a path towards resolving doc errors too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed -- it looks like we need to do some pattern matching to get them to pass. I will submit a new PR once I figure out how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely don't worry about that for this PR, unless you know of something that will make that really hard. One of us can tackle that later.