Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
bd1a2a9
Updated documentation for Canvas.
freakboy3742 Jul 9, 2023
dc57388
Update docstrings, core API, and canvas examples.
freakboy3742 Jul 11, 2023
ab6f9f6
Complete documentation audit and add changenotes.
freakboy3742 Jul 12, 2023
20b3556
Core Canvas widget tests ported.
freakboy3742 Jul 12, 2023
c87c837
Initial canvas probe implementations for Cocoa and iOS.
freakboy3742 Jul 14, 2023
c8aa596
Initial GTK Cairo fixes plus probe.
freakboy3742 Jul 14, 2023
83a2b72
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Jul 14, 2023
440f3be
Make the Cocoa sRGB conversion conditional on an ICC profile existing.
freakboy3742 Jul 15, 2023
2a4fb29
Add a __len__ operation to context, and expanded canvas tutorial.
freakboy3742 Jul 15, 2023
3ae60c1
Allow for a default font on write_text, and correct docs on text origin.
freakboy3742 Jul 15, 2023
1b09a23
Cocoa Canvas at 100% coverage.
freakboy3742 Jul 15, 2023
43d765a
iOS canvas at 100% coverage.
freakboy3742 Jul 15, 2023
c9453d4
Mark Dummy interface as not required, and update Winforms/Android int…
freakboy3742 Jul 15, 2023
91648c9
GTK Canvas at 100% coverage.
freakboy3742 Jul 15, 2023
4e88fb2
Correct GTK multiline text handling.
freakboy3742 Jul 15, 2023
dd03691
Correct transparency handling on iOS.
freakboy3742 Jul 15, 2023
5dc4c2c
Exclude Font from dummy interface checks.
freakboy3742 Jul 15, 2023
de81c39
Disable multiline text test on GTK.
freakboy3742 Jul 15, 2023
d15ed48
Enable capture of test failure screenshots.
freakboy3742 Jul 16, 2023
39c501a
Rework reference variant handling to allow for more complex variant d…
freakboy3742 Jul 16, 2023
4c5e816
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Jul 17, 2023
d033c1e
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Jul 26, 2023
55ba727
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Jul 26, 2023
9fc0aef
Scale up canvas reference images to 200x200.
freakboy3742 Jul 27, 2023
3df8899
Set final test error thresholds.
freakboy3742 Jul 28, 2023
9c8271f
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Aug 4, 2023
66a613b
Merge branch 'gtk-font-tests' into audit-canvas
freakboy3742 Aug 25, 2023
b8370a1
Merge remote-tracking branch 'origin/main' into audit-canvas
mhsmith Sep 14, 2023
67834ee
Make Widget.add, insert, remove and clear throw an exception if calle…
mhsmith Sep 17, 2023
5fccc5c
Documentation cleanups
mhsmith Sep 17, 2023
f793e53
Remove redundant can_have_children methods
mhsmith Sep 17, 2023
bba6824
Fix grammar
mhsmith Sep 17, 2023
142ec17
WinForms Canvas working in examples/canvas and tutorial4
mhsmith Sep 17, 2023
399b3e1
All WinForms Canvas tests passing except transparency, text and input
mhsmith Sep 20, 2023
ee334a1
WinForms Canvas input tests passing
mhsmith Sep 21, 2023
8e336af
Canvas docs clarifications
mhsmith Sep 21, 2023
233adb2
Remove redundant DrawingOperation documentation
mhsmith Sep 24, 2023
561828a
Fix WinForms Canvas test_transparency
mhsmith Sep 25, 2023
fa57ae9
Add method hyperlinks to DrawingObject subclass list
mhsmith Sep 25, 2023
146190a
All WinForms Canvas tests passing at both 100% and 125% scale, except…
mhsmith Sep 25, 2023
78eaf7f
Correct transparency handling on Cocoa canvas.
freakboy3742 Sep 25, 2023
fd7bb64
tutorial4 working on Android, except for text
mhsmith Sep 26, 2023
ae4f0ed
Canvas testbed passing on Android, except for text
mhsmith Sep 26, 2023
1a8d1cc
Add text baseline setting, update tests, and fix on WinForms
mhsmith Sep 27, 2023
1a7f57d
Update core Canvas tests
mhsmith Sep 27, 2023
c1611e6
Merge remote-tracking branch 'remotes/origin/main' into audit-canvas
mhsmith Sep 28, 2023
dbb70c6
Correct WinForms text issues
mhsmith Sep 28, 2023
16d622d
Merge branch 'canvas-tmp' into audit-canvas
mhsmith Sep 28, 2023
d9c61fd
Implement write_text baseline on Cocoa and iOS, and correct font sizes
mhsmith Sep 28, 2023
da05a42
Make MIDDLE and BOTTOM refer to the entire text block, and add roundi…
mhsmith Sep 30, 2023
9139042
Update MIDDLE and BOTTOM on WinForms, and update tests to verify it
mhsmith Sep 30, 2023
a975cab
Make Cocoa draw text lines separately
mhsmith Sep 30, 2023
9fe6c4a
Make WinForms default font follow the system theme
mhsmith Sep 30, 2023
e5c02a9
Cocoa: align ALPHABETIC baseline with a logical pixel
mhsmith Sep 30, 2023
cadc219
Cocoa: switch from drawAtPoint to drawWithRect
mhsmith Oct 1, 2023
425e6d4
Add definitions of CSS pixels and points
mhsmith Oct 1, 2023
86a2012
Copy Cocoa text implementation to iOS, and add tests for multi-size b…
mhsmith Oct 2, 2023
7cf6ce1
Android: implement Canvas text rendering
mhsmith Oct 2, 2023
1e0f349
Update WinForms text reference image
mhsmith Oct 2, 2023
8d486b4
Minor tweaks to sizing descriptions
freakboy3742 Oct 2, 2023
488403d
Rewrite GTK Canvas text rendering to use Pango
mhsmith Oct 4, 2023
d87dd61
More tweaks to sizing descriptions
mhsmith Oct 5, 2023
e97d1b4
GTK: refresh font map after loading a font
mhsmith Oct 5, 2023
6cf78a9
Android Canvas at 100% coverage
mhsmith Oct 5, 2023
d04ff97
WinForms Canvas at 100% coverage
mhsmith Oct 5, 2023
c6a18ed
Implement HTML behavior when drawing on an empty path (Android, Cocoa…
mhsmith Oct 5, 2023
d7f4e2e
Base Cocoa and iOS line height on font metrics
mhsmith Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/src/toga_android/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def onTouch(self, canvas, event):
self.interface.on_drag(None, x, y)
elif action == MotionEvent.ACTION_UP:
self.interface.on_release(None, x, y)
else:
else: # pragma: no cover
return False
return True

Expand Down
Binary file modified testbed/src/testbed/resources/canvas/arc.png
Copy link
Member Author

@freakboy3742 freakboy3742 Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Art immitates life... the test case now reflects how we feel about the Canvas widget :-)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 30 additions & 17 deletions testbed/tests/widgets/test_canvas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
from math import pi
from unittest.mock import Mock, call

import pytest
Expand Down Expand Up @@ -352,24 +353,36 @@ async def test_quadratic_curve(canvas, probe):
async def test_arc(canvas, probe):
"An arc can be drawn"
canvas.context.begin_path()

# Face
canvas.context.arc(100, 100, 80, 0)
canvas.context.arc(100, 100, 80)

# Smile
# Smile (exactly half a turn)
canvas.context.move_to(150, 100)
canvas.context.arc(100, 100, 50, 0, math.pi, False)
canvas.context.arc(100, 100, 50, 0, pi, anticlockwise=False)

# Hair
# Hair (exactly half a turn, but in the opposite direction)
canvas.context.move_to(190, 100)
canvas.context.arc(100, 100, 90, 0, math.pi, True)
canvas.context.arc(100, 100, 90, 0, pi, anticlockwise=True)

# Left eye
canvas.context.move_to(70, 70)
canvas.context.arc(64, 70, 6, 0)
canvas.context.arc(64, 70, 6)

# Right eye
canvas.context.move_to(130, 70)
canvas.context.arc(124, 70, 6, 0)
canvas.context.arc(124, 70, 6)

canvas.context.stroke()

# Left eyebrow (less than half a turn)
canvas.context.begin_path()
canvas.context.arc(64, 70, 12, pi * 3 / 4, pi * 6 / 4)
canvas.context.stroke()

# Right eyebrow (less than half a turn, crossing the zero angle)
canvas.context.begin_path()
canvas.context.arc(124, 70, 12, pi * 6 / 4, pi * 1 / 4)
canvas.context.stroke()

await probe.redraw("Smiley face should be drawn")
Expand All @@ -385,30 +398,30 @@ async def test_ellipse(canvas, probe):
canvas.context.fill(color=RED)

# Purple orbit
canvas.context.ellipse(100, 100, 90, 20, rotation=math.pi * 3 / 4)
canvas.context.ellipse(100, 100, 90, 20, rotation=pi * 3 / 4)
canvas.context.stroke(color=REBECCAPURPLE)

# Blue orbit
# Blue orbit (more than half a turn)
canvas.context.ellipse(
100,
100,
radiusx=20,
radiusy=90,
rotation=-math.pi / 4,
startangle=math.pi * 7 / 4,
endangle=math.pi / 4,
rotation=-pi / 4,
startangle=pi * 7 / 4,
endangle=pi / 4,
anticlockwise=True,
)
canvas.context.stroke(color=CORNFLOWERBLUE)

# Yellow orbit
# Yellow orbit (more than half a turn)
canvas.context.ellipse(
100,
100,
radiusx=20,
radiusy=90,
startangle=math.pi / 4,
endangle=math.pi * 7 / 4,
startangle=pi / 4,
endangle=pi * 7 / 4,
)
canvas.context.stroke(color=GOLDENROD)

Expand Down Expand Up @@ -529,7 +542,7 @@ async def test_transforms(canvas, probe):
canvas.context.fill(color=CORNFLOWERBLUE)

canvas.context.reset_transform()
canvas.context.rotate(math.pi / 4)
canvas.context.rotate(pi / 4)
canvas.context.rect(200, 0, 20, 60)
canvas.context.fill(color=REBECCAPURPLE)

Expand All @@ -540,7 +553,7 @@ async def test_transforms(canvas, probe):

canvas.context.reset_transform()
canvas.context.translate(100, 60)
canvas.context.rotate(math.pi / 7 * 4)
canvas.context.rotate(pi / 7 * 4)
canvas.context.scale(5, 2)
canvas.context.rect(2, 2, 10, 10)
canvas.context.fill()
Expand Down