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

new paint infrastructure with improved path, text, and image elements #1457

Draft
wants to merge 238 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
238 commits
Select commit Hold shift + click to select a range
d31276a
newpaint: start on porting path from canvas, in 32bit with api improv…
rcoreilly Jan 26, 2025
c71fdad
newpaint: canvas-based path fully building: still need to fix Eigen a…
rcoreilly Jan 26, 2025
94eb2a1
get rid of all the implicit conversions between deg and rad and just …
rcoreilly Jan 27, 2025
c9d3294
a couple of other rad / deg cleanups
rcoreilly Jan 27, 2025
e5a63a3
path is passing most tests -- need to go back and fix ones that aren't
rcoreilly Jan 27, 2025
96b2b83
add shapes test
rcoreilly Jan 27, 2025
54cbfac
newpaint: path shapes tests all passing
rcoreilly Jan 27, 2025
e9df6a7
newpaint: all but transform tests passing
rcoreilly Jan 27, 2025
8197a88
newpaint: fix crossings one -- was the end var issue
rcoreilly Jan 27, 2025
51979b8
newpaint: add stroke, stroke_test -- a few issues yet but ok for now
rcoreilly Jan 27, 2025
9a808dc
update to new rendering api -- not fully fleshed out but a start
rcoreilly Jan 27, 2025
7e1b891
newpaint: massive surgery update on paint logic with Context for Path…
rcoreilly Jan 28, 2025
1bb2080
newpaint: first pass render using rasterx working!
rcoreilly Jan 28, 2025
df8b688
newpaint: passing test
rcoreilly Jan 28, 2025
6bc93ad
newpaint: canvas rasterizer working
rcoreilly Jan 28, 2025
bb13529
newpaint: rendering tests working
rcoreilly Jan 28, 2025
ab5af50
clip bounds, context pushing working
rcoreilly Jan 28, 2025
f589cd3
svg mostly updated
rcoreilly Jan 28, 2025
ad06ecd
Merge branch 'main' into newpaint
rcoreilly Jan 28, 2025
a8e5153
newpaint: canvas-consistent transforms working and all tests are pass…
rcoreilly Jan 28, 2025
24a5b5d
svg rendering, but lines are too thick..
rcoreilly Jan 29, 2025
1003373
newpaint: srwiley renderer working very similar to before on svg; tex…
rcoreilly Jan 29, 2025
85bbd5c
almost updated to new painter api everywhere in core
rcoreilly Jan 29, 2025
1c6a533
newpaint: rest of the codebase updated to new painter api, kind of wo…
rcoreilly Jan 29, 2025
9f99419
newpaint: forgot RenderDone for the nth time. all building.
rcoreilly Jan 29, 2025
136a55e
newpaint: fixed arc, ellipse rendering
rcoreilly Jan 29, 2025
c0699ab
newpaint: reenabled all the tests, renamed path -> ppath
rcoreilly Jan 29, 2025
775b393
newpaint: image render item working
rcoreilly Jan 29, 2025
b8e366d
newpaint: full render stack of ppath, pimage, ptext all working. nota…
rcoreilly Jan 29, 2025
7537686
newpaint: move Renderer to render, pass to text rendering so paths ar…
rcoreilly Jan 29, 2025
f664bde
newpaint: rasterx renderer needed to regen scanner etc for new size -…
rcoreilly Jan 29, 2025
5428cde
newpaint: working on removing all explicit Pixel image -- use RenderI…
rcoreilly Jan 30, 2025
699b737
newpaint: icons working, mostly back to original rendering; icon line…
rcoreilly Jan 30, 2025
22073c8
newpaint: icons were re-rendering -- look normal now; finding signifi…
rcoreilly Jan 30, 2025
22250ea
newpaint: finally found issue: ClampBorderRadius was missing. sheesh.…
rcoreilly Jan 30, 2025
b5ecb01
newpaint: fixed svg text transform and added painter.Transform() meth…
rcoreilly Jan 30, 2025
7bdcd53
newpaint: fixed random fills -- now all good except meter and textedi…
rcoreilly Jan 30, 2025
68f8cca
newpaint: fixed texteditor line numbers: one per visible line
rcoreilly Jan 30, 2025
3d14954
newpaint: benchmarking
rcoreilly Jan 31, 2025
8b2b7bc
newpaint: removed temp quad stuff and perf is very close to original …
rcoreilly Jan 31, 2025
369e711
newpaint: rasterx scan is seriously fast compared to image/vector ras…
rcoreilly Jan 31, 2025
3dcb745
newpaint: full profiling hooks in basic rasterx, updated README for r…
rcoreilly Jan 31, 2025
87b8f77
newpaint: rasterx using ScanGV or ScanFT for benchmarking -- both are…
rcoreilly Jan 31, 2025
e33c345
newpaint: remove rasterx test cases, remove profiling. all good
rcoreilly Jan 31, 2025
a1b2161
newpaint: actually use ArcToCubeImmediate flag
rcoreilly Jan 31, 2025
0e410d9
newpaint: rich.Text first pass impl, sync'd with go-text types
rcoreilly Feb 2, 2025
0db822c
size encoded as additional rune
rcoreilly Feb 2, 2025
835650a
newpaint: rich text all tests passing
rcoreilly Feb 2, 2025
852e398
newpaint: add link URL; starting on HTML parsing
rcoreilly Feb 2, 2025
023e943
newpaint: reorganize everything text-related into an overall text pac…
rcoreilly Feb 2, 2025
09255ee
move text -> lines and make text the new full text rep.
rcoreilly Feb 2, 2025
738ccbf
newpaint: style functions to set from properties moved to styleprops …
rcoreilly Feb 2, 2025
f69b723
newpaint:first pass shaping working, presumably (need to render output)
rcoreilly Feb 3, 2025
f7b6ec3
newpaint: basic font rendering working finally -- renders directly in…
rcoreilly Feb 3, 2025
dacae96
newpaint: renames, some cleanup, todos
rcoreilly Feb 3, 2025
f2f0987
newpaint: sketch of new full layout and wrapping structures, prior to…
rcoreilly Feb 3, 2025
84d826f
newpaint: add textpos package and gradually transition over to these …
rcoreilly Feb 3, 2025
71a0060
newpaint: text styling properties
rcoreilly Feb 4, 2025
334320e
newpaint: text lines rendering semi-working -- infra all in place
rcoreilly Feb 4, 2025
52464b8
newpaint: fixed issues in font query and now getting the right fonts.…
rcoreilly Feb 4, 2025
96bf068
newpaint: can't seem to get vertical working -- line breaking isn't w…
rcoreilly Feb 4, 2025
8844c92
newpaint: ok figured out vertical -- actually seems good including gl…
rcoreilly Feb 4, 2025
0265fbe
newpaint: default direction for rich.Style, fixed RTL progression iss…
rcoreilly Feb 4, 2025
1142e1c
newpaint: our own Run with font colors
rcoreilly Feb 4, 2025
9c63be4
newpaint: bg and font colors working
rcoreilly Feb 4, 2025
5f2f394
newpaint: variable sized lines working -- getting line height empiric…
rcoreilly Feb 4, 2025
243edca
newpaint: NewSpans api
rcoreilly Feb 4, 2025
d46ec5e
newpaint: underlining working
rcoreilly Feb 5, 2025
e0eb146
newpaint: selection almost working
rcoreilly Feb 5, 2025
705d12b
newpaint: selection working first pass
rcoreilly Feb 5, 2025
a764b95
newpaint: selection working with arbitrary regions; renamed file to r…
rcoreilly Feb 5, 2025
fad6d4a
start on htmlcanvas renderer; initial rendering kind of working
kkoreilly Feb 5, 2025
5ebc03d
implement gradient handling in htmlcanvas
kkoreilly Feb 5, 2025
e86517d
implement most of RenderPath in htmlcanvas
kkoreilly Feb 5, 2025
6c21b63
get basic image rendering working in htmlcanvas
kkoreilly Feb 5, 2025
fd8e828
get basic font rendering working on web! uses embedded Roboto for sha…
kkoreilly Feb 5, 2025
a6757a4
newpaint: start on GlyphAtPoint
rcoreilly Feb 5, 2025
8a109ef
newpaint: inherit fields
rcoreilly Feb 5, 2025
e57e141
newpaint: font metric methods on Shaper -- needed for updating unit c…
rcoreilly Feb 5, 2025
88cb23a
newpaint: rename rich.Spans -> rich.Text
rcoreilly Feb 5, 2025
99d9c40
newpaint: htmltext working but not extensively tested
rcoreilly Feb 5, 2025
af873cd
add basic span-based rendering in htmlcanvas
kkoreilly Feb 5, 2025
34334ed
move Roboto font files from paint/ptext to text/shaped
kkoreilly Feb 5, 2025
4852b4a
newpaint: update rich.Text to support start / end of specials so they…
rcoreilly Feb 5, 2025
348ebf5
update fonts readme
kkoreilly Feb 6, 2025
41d50cf
comment out lines in ptext that don't compile
kkoreilly Feb 6, 2025
536efc0
add basic font embedding in Shaper
kkoreilly Feb 6, 2025
2b43702
newpaint: implement embedded font fs walking
kkoreilly Feb 6, 2025
7016188
newpaint: add extensible EmbeddedFonts var
kkoreilly Feb 6, 2025
d0ded6c
newpaint: naming cleanup
kkoreilly Feb 6, 2025
23b8757
newpaint: start on applyTextStyle
kkoreilly Feb 6, 2025
416e25a
newpaint: implement basic run-based text rendering; start on styling
kkoreilly Feb 6, 2025
2d4dabb
more font size work
kkoreilly Feb 6, 2025
29d8da5
newpaint: more font styling
kkoreilly Feb 6, 2025
3a0ff2e
newpaint: update todo
kkoreilly Feb 6, 2025
6b1087f
newpaint: style updated to use new text styles
rcoreilly Feb 6, 2025
483ff0f
newpaint: nuke old ptext
rcoreilly Feb 6, 2025
3e6ebe5
newpaint: in process of switching over to text
rcoreilly Feb 6, 2025
63f49e4
new text rendering framework hooked up to core, basic example running.
rcoreilly Feb 6, 2025
57abee7
add wrap.go
rcoreilly Feb 6, 2025
d925bb8
default position for wrapped text _does_ add the baseline so it rende…
rcoreilly Feb 6, 2025
40a6977
newpaint: wrap= never is not actually never according to go-text.. un…
rcoreilly Feb 6, 2025
05c73ab
newpaint: move TextShaper to Scene -- much better. fixed color setting.
rcoreilly Feb 6, 2025
c0826bf
newpaint: new logic for textfield and crash protection in shaper for …
rcoreilly Feb 6, 2025
29e8fec
newpaint: text top offset now correct
rcoreilly Feb 6, 2025
8f5a663
newpaint: UnitContext sizing fixed -- getting more functional overall…
rcoreilly Feb 6, 2025
ec92ad9
newpaint: minor
rcoreilly Feb 6, 2025
50dfdba
newpaint: optimize use of Clear function in rasterizer -- is taking t…
rcoreilly Feb 6, 2025
10ea871
newpaint: enforce text bounds to be at least 1 lineheight, and renorm…
rcoreilly Feb 6, 2025
61b6d94
newpaint: need to do clip of overall render context bounds -- fixes t…
rcoreilly Feb 7, 2025
663e864
newpaint: demo minus texteditors, all working well except for link pa…
rcoreilly Feb 7, 2025
adf1b5a
newpaint: fix add end special, better printing, tests
rcoreilly Feb 7, 2025
59244cf
newpaint: major rewrite of basic rich.Text iteration / etc utils - wa…
rcoreilly Feb 7, 2025
90c5301
newpaint: Lines RuneBounds and RuneAtPoint working
rcoreilly Feb 7, 2025
eba4940
newpaint: text links working
rcoreilly Feb 7, 2025
506b693
newpaint: texteditor selection and mouse clicking all good. still nee…
rcoreilly Feb 7, 2025
9d763bb
newpaint: texteditor up / down navigation using lines function -- muc…
rcoreilly Feb 7, 2025
950eddd
newpaint: texteditor fixed width all working, updated to use Range type
rcoreilly Feb 7, 2025
78da123
newpaint: text selection logic working!
rcoreilly Feb 8, 2025
acbccf2
newpaint: selection logic updates: still need to fix spaces
rcoreilly Feb 8, 2025
70331a9
newpaint: test for space positioning
rcoreilly Feb 8, 2025
4f33cd1
newpaint: actually spaces _are_ represented in output! use advance on…
rcoreilly Feb 8, 2025
7021628
newpaint: fix random places where comments had tabs instead of spaces
rcoreilly Feb 8, 2025
28491d5
newpaint: start on updating lines..
rcoreilly Feb 8, 2025
b4ab8f9
start on new htmlcanvas text structure
kkoreilly Feb 8, 2025
b459832
get basic textStyle placeholder working
kkoreilly Feb 8, 2025
9a4c324
newpwaint: get text styling mostly working in htmlcanvas
kkoreilly Feb 8, 2025
4ffa9b6
support text stroke in htmlcanvas
kkoreilly Feb 8, 2025
99164d6
add todo
kkoreilly Feb 8, 2025
df7d98c
newpaint: lines progress
rcoreilly Feb 8, 2025
3b80a78
newpaint: fix text non-selectable abilities and remove debug links count
rcoreilly Feb 8, 2025
33adff4
force 2d drawer for now on web for htmlcanvas testing
kkoreilly Feb 9, 2025
9665e8d
use underscore import to get renderers
kkoreilly Feb 9, 2025
bfad225
use htmlcanvas renderer on js
kkoreilly Feb 9, 2025
bdf6797
newpaint: more htmlcanvas work
kkoreilly Feb 9, 2025
c090c0d
make new canvas element in htmlcanvas.New
kkoreilly Feb 9, 2025
a87a33d
fix rendericon; work on canvas styling on web
kkoreilly Feb 9, 2025
69633d9
disable too much width and height on web
kkoreilly Feb 9, 2025
f7a7414
newpaint: shaped interface api in place
rcoreilly Feb 9, 2025
6181737
newpaint: shaped tests working
rcoreilly Feb 9, 2025
25060f3
newpaint: shaper interface now integrated into core, working on gt ve…
rcoreilly Feb 9, 2025
2820e9f
newpaint: htmlcanvas using gt shaper for now
rcoreilly Feb 9, 2025
4fdbcf6
newpaint: shapedjs measure stub; just add Time to Region
rcoreilly Feb 9, 2025
585b888
start on separate render_js impl in core
kkoreilly Feb 9, 2025
5ca91a5
start on canvas positioning in render_js.go
kkoreilly Feb 9, 2025
dcbdedf
more progress on render_js updateCanvas
kkoreilly Feb 9, 2025
aebf509
delete inactive canvases
kkoreilly Feb 9, 2025
36a3de4
newpaint: fix panic
kkoreilly Feb 9, 2025
ce0e435
newpaint: move loader removal logic to core/render_js
kkoreilly Feb 9, 2025
05a8bbf
newpaint: more sizing logic improvements in render_js
kkoreilly Feb 9, 2025
0b36076
newpaint: major fix: y coords are already normalized, so htmlcanvas d…
kkoreilly Feb 9, 2025
cfd5ba0
move parse and spell to text
rcoreilly Feb 9, 2025
33a3db1
parse updated to textpos
rcoreilly Feb 9, 2025
47357e3
parse tests all passing
rcoreilly Feb 9, 2025
e34b36d
move parse/tokens to text/tokens
rcoreilly Feb 9, 2025
a69c3d0
runes: add trim functions; one test needs fixed
rcoreilly Feb 9, 2025
d40987e
lines is updated: need to fix markup and then do tests
rcoreilly Feb 9, 2025
4eeee6d
htmlcanvas: avoid overt cache invalidation with applyTextStyle
kkoreilly Feb 9, 2025
b063701
htmlcanvas: use wgpu.BytesToJS to improve performance some
kkoreilly Feb 9, 2025
f17c955
htmlcanvas: implement fast path for image.Uniform
kkoreilly Feb 9, 2025
31eb203
newpaint: add todo
kkoreilly Feb 10, 2025
0e8be4e
newpaint: text styling cleanup
kkoreilly Feb 10, 2025
6277bc6
newpaint: need to format weight as number in css
kkoreilly Feb 10, 2025
477e4ba
newpaint: no stroke if zero stroke width; fixes stroke rendering in h…
kkoreilly Feb 10, 2025
475f665
progress on markup
rcoreilly Feb 10, 2025
21ebf82
markup rich styling and remove core dependencies, except system.TheAp…
rcoreilly Feb 10, 2025
04f40ce
markup test running but result not good for rich -- need better stack…
rcoreilly Feb 10, 2025
19cec5a
markup test passing for rich and html
rcoreilly Feb 11, 2025
9740ee9
fix highlighting values in core
rcoreilly Feb 11, 2025
45d75c1
lines all building
rcoreilly Feb 12, 2025
8c90a32
lines: start on layout
rcoreilly Feb 12, 2025
8e7fe26
lines: layout first pass; moved settings to textsettings
rcoreilly Feb 12, 2025
a15ce38
lines: edit tests
rcoreilly Feb 12, 2025
0a52af7
lines: edit tests all working -- needed undo groups!
rcoreilly Feb 12, 2025
f4b74e6
lines: rect at end paste
rcoreilly Feb 12, 2025
7892d5d
lines: no tabs in test so resutls are clearer
rcoreilly Feb 12, 2025
ef36afc
lines: layout and markup mostly working
rcoreilly Feb 13, 2025
6f8f5af
lines: word level move and select in textpos
rcoreilly Feb 13, 2025
1800605
lines: use textpos in textfield
rcoreilly Feb 13, 2025
4c65849
lines: layout fixes and stronger test case
rcoreilly Feb 13, 2025
afff3c4
lines: move tests passing -- just need up and down now
rcoreilly Feb 13, 2025
108f281
lines: added view for different width support -- essential
rcoreilly Feb 14, 2025
62bb099
lines: clone, api updates
rcoreilly Feb 14, 2025
eafe520
lines: set style, tests passing
rcoreilly Feb 14, 2025
543aa64
lines: default highlighting style -- much more robust
rcoreilly Feb 14, 2025
5f3847a
lines: all move working and tested
rcoreilly Feb 14, 2025
7edff7a
lines: move exported api
rcoreilly Feb 14, 2025
acbd3df
lines: migrating code from buffer to lines: no more buffer ultimately.
rcoreilly Feb 14, 2025
12e95ef
lines: more buffer code including filemod check, autosave, event sign…
rcoreilly Feb 14, 2025
7b0f6e2
lines: major pass on files api cleanup and readme updating -- need fi…
rcoreilly Feb 15, 2025
c723281
lines: move runes into text
rcoreilly Feb 15, 2025
545f242
lines: start on textcore.Editor layout logic
rcoreilly Feb 15, 2025
f88a766
lines: moved listeners to views so they go away when view is disconne…
rcoreilly Feb 15, 2025
8e25ee9
lines: major update to lines layout, which is much more efficient and…
rcoreilly Feb 16, 2025
3a678c6
lines: fix for markup parsing -- was adding an extra space; new view …
rcoreilly Feb 16, 2025
a736eeb
textcore: Base rendering first pass building
rcoreilly Feb 16, 2025
c3936f4
textcore: Base rendering test working-ish
rcoreilly Feb 16, 2025
2db92f4
textcore: base layout and basic rendering working correctly.
rcoreilly Feb 16, 2025
527ad80
textcore: do need manageoverflow to get scrollbars -- seems to be wor…
rcoreilly Feb 16, 2025
a3662f1
textcore: more api for scrolling and nav in base
rcoreilly Feb 17, 2025
3717bc4
textcore: nav functions
rcoreilly Feb 17, 2025
53735db
textcore: Editor compiling with various things stubbed out
rcoreilly Feb 17, 2025
ee4beff
textcore: add complete
rcoreilly Feb 17, 2025
e39a834
textcore: smooth scrolling and line number fixes
rcoreilly Feb 18, 2025
2f57212
textcore: depth background and indenting
rcoreilly Feb 18, 2025
4450b36
textcore: leading indent logic working
rcoreilly Feb 18, 2025
6237529
textcore: LineStart, LineEnd
rcoreilly Feb 18, 2025
1a75a39
textcore: moving things around, adding pos history update for buffer …
rcoreilly Feb 18, 2025
e5dcada
textcore: online reformatting; still need to revisit linesedited logic
rcoreilly Feb 18, 2025
cb72e4a
textcore: correct insert and delete lines view updating, except for r…
rcoreilly Feb 18, 2025
c65aaf9
textcore: select region rendering
rcoreilly Feb 18, 2025
5443231
textcore: key move fixes in lines and textcore -- mostly there
rcoreilly Feb 18, 2025
c6ee788
textcore: no way to optimize the view lines layout -- just need to re…
rcoreilly Feb 18, 2025
1b325c9
textcore: updated scroll impl -- still needs work
rcoreilly Feb 18, 2025
79a0a67
textcore: scrolling, page up / down etc working
rcoreilly Feb 19, 2025
d51dc1c
textcore: robustness at end of file editing
rcoreilly Feb 19, 2025
dfafae2
textcore: end of line, kill all good
rcoreilly Feb 19, 2025
ebf378c
spell and complete code updated
rcoreilly Feb 19, 2025
9e6dc3f
add other editor types from orig
rcoreilly Feb 19, 2025
c38612b
textcore: highlights, scopelights
rcoreilly Feb 19, 2025
e3cda57
textcore: scopelights uses highlights; bracematch in place
rcoreilly Feb 19, 2025
3deabfa
textcore: nuke the old _texteditor, start getting everything building
rcoreilly Feb 19, 2025
9336fb6
textcore: everything building in core; docs has race condition
rcoreilly Feb 19, 2025
0a31480
textcore: docs web build fixed, but race condition causes crash still
rcoreilly Feb 19, 2025
3cb19ff
textcore: fix cursorcolumn setting, add editors back into demo
rcoreilly Feb 19, 2025
b9e1427
textcore: pixel from cursor fix, robustness; autoscroll is off..
rcoreilly Feb 19, 2025
dd4a668
textcore: break self update loop from calling changed in String() and…
rcoreilly Feb 20, 2025
58c20e5
major fix for core.Text which fixes most of docs etc: need to re-upda…
rcoreilly Feb 20, 2025
f09a888
textcore: docs, fix markup bug with extra spaces
rcoreilly Feb 20, 2025
3a7f836
textcore: fixed autoscroll, moved to base
rcoreilly Feb 20, 2025
d70a2fd
textcore: updated outputbuffer to use runes and rich.Text; autoscroll…
rcoreilly Feb 21, 2025
c0f56e4
textcore: may updates to support cogent code; still some more fixes n…
rcoreilly Feb 21, 2025
3f92e22
textcore: add independent file functions so they can be used on any l…
rcoreilly Feb 21, 2025
50e3b3f
removed Lines from filetree -- lots of todo esp with search
rcoreilly Feb 22, 2025
7c96144
textcore: add metadata to Lines -- key for storing vcs repo in Code
rcoreilly Feb 22, 2025
fe8169e
textcore: completer and update file info from lines logic
rcoreilly Feb 22, 2025
7ae818f
key fix for appendtextmarkup: need to add a blank line at end so next…
rcoreilly Feb 23, 2025
d933360
start on search
rcoreilly Feb 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
153 changes: 0 additions & 153 deletions base/runes/runes.go

This file was deleted.

101 changes: 0 additions & 101 deletions base/runes/runes_test.go

This file was deleted.

5 changes: 1 addition & 4 deletions cmd/core/rendericon/rendericon.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ import (
"strings"

"cogentcore.org/core/icons"
"cogentcore.org/core/paint"
"cogentcore.org/core/svg"
)

// Render renders the icon located at icon.svg at the given size.
// If no such icon exists, it sets it to a placeholder icon, [icons.DefaultAppIcon].
func Render(size int) (*image.RGBA, error) {
paint.FontLibrary.InitFontPaths(paint.FontPaths...)

sv := svg.NewSVG(size, size)

spath := "icon.svg"
Expand All @@ -41,5 +38,5 @@ func Render(size int) (*image.RGBA, error) {
}

sv.Render()
return sv.Pixels, nil
return sv.RenderImage(), nil
}
8 changes: 5 additions & 3 deletions cmd/core/web/embed/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ body {
}
}

body > #app {
width: 100vw;
height: 100vh;
body > canvas {
position: fixed;
top: 0;
/* width: 100vw;
height: 100vh; */

/* no selection of canvas */
-webkit-touch-callout: none;
Expand Down
6 changes: 3 additions & 3 deletions core/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func appIconImages() []image.Image {
}

sv.Render()
res[0] = sv.Pixels
res[0] = sv.RenderImage()

sv.Resize(image.Pt(32, 32))
sv.Render()
res[1] = sv.Pixels
res[1] = sv.RenderImage()

sv.Resize(image.Pt(48, 48))
sv.Render()
res[2] = sv.Pixels
res[2] = sv.RenderImage()
appIconImagesCache = res
return res
}
6 changes: 3 additions & 3 deletions core/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (bt *Button) Init() {
s.Padding.Right.Dp(16)
}
}
s.Font.Size.Dp(14) // Button font size is used for text font size
s.Text.FontSize.Dp(14) // Button font size is used for text font size
s.Gap.Zero()
s.CenterAll()

Expand Down Expand Up @@ -210,7 +210,7 @@ func (bt *Button) Init() {
if bt.Icon.IsSet() {
tree.AddAt(p, "icon", func(w *Icon) {
w.Styler(func(s *styles.Style) {
s.Font.Size.Dp(18)
s.Text.FontSize.Dp(18)
})
w.Updater(func() {
w.SetIcon(bt.Icon)
Expand All @@ -226,7 +226,7 @@ func (bt *Button) Init() {
s.SetNonSelectable()
s.SetTextWrap(false)
s.FillMargin = false
s.Font.Size = bt.Styles.Font.Size // Directly inherit to override the [Text.Type]-based default
s.Text.FontSize = bt.Styles.Text.FontSize // Directly inherit to override the [Text.Type]-based default
})
w.Updater(func() {
if bt.Type == ButtonMenu {
Expand Down
2 changes: 1 addition & 1 deletion core/button_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestButtonFontSize(t *testing.T) {
b := NewBody()
bt := NewButton(b).SetText("Hello")
bt.Styler(func(s *styles.Style) {
s.Font.Size.Dp(48)
s.Text.FontSize.Dp(48)
})
b.AssertRender(t, "button/font-size")
}
25 changes: 14 additions & 11 deletions core/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package core
import (
"cogentcore.org/core/math32"
"cogentcore.org/core/paint"
"cogentcore.org/core/paint/ppath"
"cogentcore.org/core/styles"
"cogentcore.org/core/styles/units"
"golang.org/x/image/draw"
Expand All @@ -21,10 +22,10 @@ type Canvas struct {
// canvas every time that it is rendered. The paint context
// is automatically normalized to the size of the canvas,
// so you should specify points on a 0-1 scale.
Draw func(pc *paint.Context)
Draw func(pc *paint.Painter)

// context is the paint context used for drawing.
context *paint.Context
// painter is the paint painter used for drawing.
painter *paint.Painter
}

func (c *Canvas) Init() {
Expand All @@ -39,12 +40,14 @@ func (c *Canvas) Render() {

sz := c.Geom.Size.Actual.Content
szp := c.Geom.Size.Actual.Content.ToPoint()
c.context = paint.NewContext(szp.X, szp.Y)
c.context.UnitContext = c.Styles.UnitContext
c.context.ToDots()
c.context.PushTransform(math32.Scale2D(sz.X, sz.Y))
c.context.VectorEffect = styles.VectorEffectNonScalingStroke
c.Draw(c.context)

draw.Draw(c.Scene.Pixels, c.Geom.ContentBBox, c.context.Image, c.Geom.ScrollOffset(), draw.Over)
c.painter = paint.NewPainter(szp.X, szp.Y)
c.painter.Paint.Transform = math32.Scale2D(sz.X, sz.Y)
c.painter.Context().Transform = math32.Scale2D(sz.X, sz.Y)
c.painter.UnitContext = c.Styles.UnitContext
c.painter.ToDots()
c.painter.VectorEffect = ppath.VectorEffectNonScalingStroke
c.Draw(c.painter)

// todo: direct render for painter to painter
c.Scene.Painter.DrawImage(c.painter.RenderImage(), c.Geom.ContentBBox, c.Geom.ScrollOffset(), draw.Over)
}
Loading
Loading