Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9f2eb0f
fix(components): draw a focus ring on unfilled buttons as a halo
t8y2 Nov 27, 2026
7022edd
fix(input): scroll a page notch by the region's own screen
t8y2 Nov 27, 2026
4178eee
fix(cli): regenerate button focus ring recipes
caichangqing1120 Nov 27, 2026
c1785af
fix(render): keep thin stroke coverage uniform across clips
mirakyux Nov 27, 2026
f54ffb3
fix(filewatch): report replacement of a watched directory on Windows
1lck Nov 27, 2026
a2d34fd
feat(app): own notification activation on the application event loop
darrenjindai Nov 27, 2026
3d0ea01
feat(audio): add cross-platform microphone input capture
DeanCen Nov 27, 2026
f9c0fce
feat(app): add native window watermarks
darrenjindai Nov 27, 2026
5a57e24
fix(tooltip): fall back to hover when the focused hit has no Hint
DeanCen Nov 27, 2026
3c5ea40
fix(app): refresh hover after layout under a stationary pointer
mirakyux Nov 27, 2026
13980d0
docs(audio): document microphone permission and macOS bundle keys
t8y2 Nov 27, 2026
1f47eb2
fix(darwin): cast the watermark bitmap info for -Werror builds
t8y2 Nov 27, 2026
467d79a
docs(release): v0.6.10 notes
t8y2 Nov 27, 2026
bb23a23
fix(components): scroll a self-painted input to keep its caret in view
woliubang256 Nov 28, 2026
d5f9ead
feat(tree): add a full-width row background to TreeItem
xiaoyumuxi Nov 27, 2026
ab697bf
fix(linux): isolate monospace font scanning from Cairo rendering
lizhuangs Nov 28, 2026
43d4519
fix(windows): report a credential write that finds no store as unavai…
t8y2 Nov 28, 2026
27054e7
fix(components): enable dragging popup menu scrollbars
Pyolar Nov 28, 2026
5847af7
fix(components): sync dropdown menu installer recipe
t8y2 Nov 28, 2026
97cdc2b
fix(windows): raise the watermark above the owner's popups
yiqiui Nov 28, 2026
fa31927
fix(components): keep anchored turn in place on prepend
yiqiui Nov 28, 2026
7ca5803
fix(linux): respect Num Lock and Shift for keypad input
lizhuangs Nov 28, 2026
b53f7fe
fix(patchgen): read a Linux payload's executable from its tar header
yiqiui Nov 28, 2026
17b35ae
docs(website): explain notifications and watermarks in guides
t8y2 Nov 28, 2026
b92eb19
feat(ui): add live editing to the color picker
lizhuangs Nov 28, 2026
c21745f
feat(windows): report the graphics path through diagnostics
t8y2 Nov 28, 2026
ca01419
fix(input): keep an overlap when a region scrolls by a page
t8y2 Nov 28, 2026
7ac5ef1
fix(ui): let ScrollTo leave the end of a following List
xiaoyumuxi Nov 28, 2026
a1af758
fix(components): let CarouselStepForKey follow the reading direction
yiqiui Nov 28, 2026
c5246ab
merge: sync upstream main (a1af7583) into fork
xiaoyumuxi Nov 28, 2026
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
1 change: 1 addition & 0 deletions app/painter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ func (painter *painter) focusedTextField() (TextInputContext, gfx.TextPlacement,
Multiline: hit.Multiline, ReadOnly: hit.ReadOnly, Secure: hit.Secure,
NavigationKeys: hit.NavigationKeys,
TextBounds: text.Bounds, FontSize: text.Size, FontWeight: text.Weight, TextColor: text.Color, Alignment: text.Alignment,
TextScroll: text.Scroll,
HideNativeOverlays: hit.HideNativeOverlays,
}
return context, text.Placement, index
Expand Down
7 changes: 5 additions & 2 deletions app/text_geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type textGeometry struct {
alignment gfx.Alignment
value string // the field's value
shown string // what is drawn: the value, or one bullet per rune
// scroll is how far a field that paints its own line moved it left, so a point in
// the window is measured against the glyphs where they were drawn.
scroll float32
}

// focusedTextGeometry is the geometry of the focused field, false when no field with text
Expand All @@ -44,7 +47,7 @@ func (painter *painter) focusedTextGeometry() (textGeometry, bool) {
geometry := textGeometry{
canvas: painter.canvas, placement: placement, bounds: context.TextBounds,
style: gfx.TextStyle{Size: context.FontSize, Weight: context.FontWeight},
alignment: context.Alignment, value: value, shown: value,
alignment: context.Alignment, value: value, shown: value, scroll: context.TextScroll,
}
if placement == nil && (context.TextBounds.Width <= 0 || context.TextBounds.Height <= 0 || context.FontSize <= 0) {
return textGeometry{}, false
Expand Down Expand Up @@ -98,7 +101,7 @@ func (geometry textGeometry) RangeRects(dst []gfx.Rect, start, end int) []gfx.Re
}

func (geometry textGeometry) origin() float32 {
return geometry.canvas.LabelOrigin(geometry.shown, geometry.bounds, geometry.style, geometry.alignment)
return geometry.canvas.LabelOrigin(geometry.shown, geometry.bounds, geometry.style, geometry.alignment) - geometry.scroll
}

// byteOffsetOfRune is the byte offset of rune index in value, clamped to its ends.
Expand Down
25 changes: 25 additions & 0 deletions base/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func (b Box) TabStop(on bool) Box {
type ColorPickerState struct {
open, restoreFocus, applied bool
showAlpha bool
live bool
draft ColorPickerValue
hexEditor text.Editor
hex Field
Expand Down Expand Up @@ -100,6 +101,28 @@ func (s *ColorPickerState) Applied() bool {
return applied
}

// Live reports whether edits update the bound color immediately.
func (s *ColorPickerState) Live() bool { return s.live }

// Live makes a ColorPicker update its bound color as it is edited, without
// Clear, Cancel or Apply buttons. Escape and outside clicks close the panel
// without reverting edits. Bind a draft when the application owns Save/Cancel.
func (b Box) Live(on bool) Box {
if extra := b.pickerExtra(); extra != nil {
extra.picker.live = on
}
return b
}

func (s *ColorPickerState) commitLive() {
if s.live && s.open && !s.invalid && s.target != nil {
color := s.draft.Color()
if *s.target != color {
*s.target, s.applied = color, true
}
}
}

// colorPickerLook is how a ColorPicker looks, set by its Box methods.
type ColorPickerLook struct {
Label string
Expand Down Expand Up @@ -247,6 +270,7 @@ func (s *ColorPickerState) SetDraftValue(v ColorPickerValue) {
}
s.seen, s.invalid = value, false
s.Summary = Summary(v)
s.commitLive()
}

func Summary(v ColorPickerValue) string {
Expand Down Expand Up @@ -304,5 +328,6 @@ func (s *ColorPickerState) syncHex() {
if valid {
s.draft = s.draft.WithColor(color)
s.Summary = Summary(s.draft)
s.commitLive()
}
}
5 changes: 5 additions & 0 deletions base/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ type Field struct {
// blink is the phase of the caret when the field paints it itself, which a fixed-pitch
// field does (see Box.Mono): the platform draws the caret of the others.
blink CaretBlink
// scroll keeps a value longer than the field in view of its caret, which the field
// must do itself: it paints its own line (HideEditorText), so the platform editor
// that would have scrolled it draws nothing.
scroll InputScroll
// seen is the text as the field was last declared, and changed whether that
// declaration found it edited since the one before (Box.Changed).
seen string
Expand Down Expand Up @@ -346,6 +350,7 @@ func (field *Field) Snapshot(f *Frame, ID gfx.ID, Label, placeholder string) Inp
// canvas line, which moves the value when the field gains the keyboard.
HideEditorText: true,
Blink: &field.blink,
Scroll: &field.scroll,
}
// Where the caret, the selection and the composition are: what a field that paints them
// itself needs, and what the platform's own presentation of them does without.
Expand Down
6 changes: 6 additions & 0 deletions base/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ type InputSnapshot struct {
// Blink is the phase of the caret a field paints itself (see InputTextStyle.Mono and
// HideEditorText): the caret is drawn only while it is lit. Nil keeps it lit.
Blink *CaretBlink
// Scroll keeps a value too long for the field's line in view of its caret, when the
// component paints the line itself (see HideEditorText and InputTextStyle.Mono). A
// field that lets the platform editor paint its text does not need it: the platform
// scrolls the line for its own caret. Nil leaves the line where it is, which is where
// a value that fits stays.
Scroll *InputScroll
}
51 changes: 51 additions & 0 deletions base/input_scroll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package base

// InputScroll is the horizontal offset of one single-line field's painted line: how
// far the text of a value too long for the field is moved left so that the caret
// stays in view, as a native single-line editor does. The zero value starts at the
// left edge, which is the whole story for a value that fits.
//
// It is held by the field, next to the text it belongs to, and read during the paint
// that draws the field's own glyphs (see InputSnapshot.Scroll): a component that
// paints the text itself must move it with the caret, because the platform editor
// that would have scrolled it draws nothing. It is not safe for concurrent use, and
// one InputScroll serves one field.
type InputScroll struct {
offset float32
}

// Follow returns the offset to paint the line with, for a line textWidth wide whose
// caret stands caretX from the line's start, inside a field width across. The offset
// moves only as far as it must: a caret that is still in view leaves the text where
// it is, so typing at the end does not slide the line under a caret that has not
// reached the edge, and End shows the tail of a long value while Home comes back to
// its start. width of zero or less paints nothing, and an offset that no longer
// fits (a shorter value, a wider field) is brought back into range.
func (s *InputScroll) Follow(caretX, textWidth, width float32) float32 {
if width <= 0 {
s.offset = 0
return 0
}
// The caret is a stroke one pixel wide, so the room the line has to show its
// glyphs is the field less that stroke: a caret at the right edge is visible.
visible := max(width-1, 1)
most := max(textWidth-visible, 0)
offset := min(max(s.offset, 0), most)
if caretX-offset > visible {
offset = caretX - visible
} else if caretX < offset {
offset = caretX
}
offset = min(max(offset, 0), most)
s.offset = offset
return offset
}

// Rest puts the line back at the field's start, as a field that loses its value does
// not want the next one scrolled by the last one's caret.
func (s *InputScroll) Rest() { s.offset = 0 }

// Offset reports how far the line is painted left of the field's start, as the last
// Follow left it. A field reads it for what it must do itself, such as reporting
// where its text sits to the platform.
func (s *InputScroll) Offset() float32 { return s.offset }
14 changes: 12 additions & 2 deletions base/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ func (s *ListState) HasFocus() bool {
// list has not laid out is placed at the average height of the rows it has, so the
// request stays for the paints that show the rows around the target and measure
// them, and goes once the offset no longer moves; the list asks for those paints
// itself, and lets the request go if anything else moves the list first.
// itself, and lets the request go if anything else moves the list first. On a list
// that follows its end, a row away from the end leaves the end, as a scroll by the
// user does; ScrollToEnd follows it again.
func (s *ListState) ScrollTo(row int, align ListAlign) {
kind := listScrollStart
switch align {
Expand Down Expand Up @@ -910,19 +912,27 @@ func (p *Page) ListArea(c C, state *ListState, n int, horizontal bool, row func(
id := p.ID(at)
// Follow is declared on the area the List returns, after its rows: whether the area
// keeps to its end is what the paint before left it, as ScrollState.Pinned says.
pinned := c.f.Scrolls.get(id).pinned()
// ScrollArea forgets whether it follows until that declaration, so it is kept here.
prev := c.f.Scrolls.get(id)
pinned, followed := prev.pinned(), prev.follow
area := c.f.ScrollArea(id)
p.SetNode(area.i, at)
in := &state.list
in.n, in.area, in.pinned = n, area.i, -1
state.resize(n)
scroll := c.f.Exts[c.f.Nodes[area.i].Ext].scrollState
in.Scroll = scroll
// The request settles against the follow the paint before declared: a ScrollTo
// away from the end of a following list leaves the end, as a scroll by the user
// does, instead of the Follow(true) after the rows pulling the list back to it.
scroll.follow = followed
if state.applyScrollRequest(c.f) {
// The area was declared at the offset it had; the layout reads the node, so it
// takes the requested one too, which the rows are placed for below (as ScrollAt).
c.f.Nodes[area.i].Scroll = scroll.Offset
pinned = scroll.pinned()
}
scroll.follow = false
viewport := scroll.Viewport
if viewport <= 0 {
viewport = c.f.bounds.Height
Expand Down
2 changes: 1 addition & 1 deletion base/menu_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (scroll *MenuScroll) Dragging() bool { return scroll.Held }
func (scroll *MenuScroll) Drag(event gfx.PointerEvent) bool {
switch event.Kind {
case gfx.PointerDown:
if scroll.BarID.IsZero() || event.Target != scroll.BarID || scroll.MaxValue <= 0 {
if scroll.BarID.IsZero() || event.Target != scroll.BarID || scroll.MaxValue <= 0 || event.Button > gfx.PointerButtonPrimary {
return false
}
at := scroll.BarTop + (scroll.View-scroll.Thumb)*scroll.Offset/scroll.MaxValue
Expand Down
12 changes: 6 additions & 6 deletions base/scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ func (s *ScrollState) relax(canvas *gfx.Canvas) {

// Key applies the keyboard's scrolling to the area, from the content and viewport
// of its last layout: Left and Right move a Sideways area by step, Up and Down
// vertically by step, PageUp and PageDown by a viewport, and Home and End to the
// start and the end. A step of zero or less is 32 pixels, one line. It reports a
// recognized key as handled even when the area was already at that end, so the
// caller stops there rather than looking for another area, and Repaint only when
// the offsets moved.
// vertically by step, PageUp and PageDown by gfx.ScrollPage of the viewport, and
// Home and End to the start and the end. A step of zero or less is 32 pixels,
// one line. It reports a recognized key as handled even when the area was
// already at that end, so the caller stops there rather than looking for another
// area, and Repaint only when the offsets moved.
//
// It is for a page that gives the keyboard to the area itself, as one does to a
// terminal or a log beside a control: a List and a Table scroll with the arrow
Expand All @@ -379,7 +379,7 @@ func (s *ScrollState) Key(event gfx.KeyEvent, step float32) gfx.EventResult {
if step <= 0 {
step = 32
}
page := max(s.Viewport*0.9, step)
page := max(gfx.ScrollPage(s.Viewport), step)
before, beforeX := s.Offset, s.OffsetX
switch event.Key {
case gfx.KeyLeft:
Expand Down
24 changes: 13 additions & 11 deletions base/scroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func TestScrollPaintsOnWholeLogicalPixels(t *testing.T) {
}

// ScrollState.Key is the keyboard's counterpart of Wheel: a page that owns an
// area's focus moves it with the arrow keys, a viewport at a time with PageUp and
// area's focus moves it with the arrow keys, a page at a time with PageUp and
// PageDown, and to either end with Home and End, never past them.
func TestScrollStateKeyScrollsWithinItsContent(t *testing.T) {
var view View
Expand All @@ -304,7 +304,7 @@ func TestScrollStateKeyScrollsWithinItsContent(t *testing.T) {
}{
{gfx.KeyDown, 32},
{gfx.KeyUp, 0},
{gfx.KeyPageDown, 90},
{gfx.KeyPageDown, gfx.ScrollPage(state.Viewport)},
{gfx.KeyPageUp, 0},
{gfx.KeyEnd, 200},
{gfx.KeyHome, 0},
Expand All @@ -324,8 +324,8 @@ func TestScrollStateKeyScrollsWithinItsContent(t *testing.T) {
if result := state.Key(gfx.KeyEvent{Key: gfx.KeyDown, Release: true}, 32); result.Handled || state.Offset != 0 {
t.Errorf("a key release moved the area to %v, handled %v", state.Offset, result.Handled)
}
if result := state.Key(gfx.KeyEvent{Key: gfx.KeyPageDown}, 32); result.Handled && state.Offset != 90 {
t.Errorf("a zero step paged to %v, want 90", state.Offset)
if result := state.Key(gfx.KeyEvent{Key: gfx.KeyPageDown}, 32); result.Handled && state.Offset != gfx.ScrollPage(state.Viewport) {
t.Errorf("a zero step paged to %v, want %v", state.Offset, gfx.ScrollPage(state.Viewport))
}
state.ScrollTo(state.Max())
if result := state.Key(gfx.KeyEvent{Key: gfx.KeyDown}, 32); !result.Handled || result.Repaint {
Expand Down Expand Up @@ -369,19 +369,21 @@ func TestAWheelPageMovesTheAreasOwnPage(t *testing.T) {
state := view.ScrollState(listID)
window := gfx.Size{Width: 800, Height: 1000}
// The system asks for a screen per notch: the event's delta is a screen of
// the window, and the area moves a screen of its own instead.
// the window, and the area moves a page of its own instead, short of its
// whole viewport so the edge it leaves stays in view.
if result := state.Wheel(gfx.ScrollEvent{DeltaY: 1000, Pages: 1, Viewport: window}); !result.Handled {
t.Fatal("a page notch was not handled")
}
if state.Offset != 100 {
t.Fatalf("one page notch moved the area to %v, want its own page 100, not the window's", state.Offset)
page := state.Offset
if page <= state.Viewport/2 || page >= state.Viewport {
t.Fatalf("one page notch moved the area %v of its %v viewport, want most of it with an overlap, not the window's", page, state.Viewport)
}
state.Wheel(gfx.ScrollEvent{DeltaY: 1000, Pages: 1, Viewport: window})
if state.Offset != 200 {
t.Fatalf("the second page notch left the area at %v, want 200", state.Offset)
if state.Offset != 2*page {
t.Fatalf("the second page notch left the area at %v, want %v", state.Offset, 2*page)
}
state.Wheel(gfx.ScrollEvent{DeltaY: -1000, Pages: -1, Viewport: window})
if state.Offset != 100 {
t.Fatalf("a page notch up left the area at %v, want 100", state.Offset)
if state.Offset != page {
t.Fatalf("a page notch up left the area at %v, want %v", state.Offset, page)
}
}
Loading
Loading