This is effectively a revert of commit gioui.org/commit/69dfd2e3a5541.
ImageOp.Rect is the wrong abstraction; it implies a clipping operation that is
better handled by package clip.
API change. Uses of ImageOp.Rect should apply a clip.Rect before the PaintOp,
or use image.RGBA.SubImage (or similar).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Package material's ad-hoc mulAlpha didn't take the sRGB color-space
into account, which meant that alpha-scaled colors were subtly wrong.
Introduce f32color.MulAlpha and convert all uses to it.
Thanks to René Post for finding and debugging the issue.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit changes the ink-drawing code so that IconButtons that
are not perfectly circular will still ink fully. Previously, an
elliptical icon would only animate a circular sub-region.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Use op.Offset instead, or create and manipulate a f32.Affine2D.
API change. Update your code with a gofmt rule:
gofmt -r 'op.TransformOp{}.Offset -> op.Offset'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A slice of FontFace pairs are simpler, and thread safe in case a client
wants to append or modify the font collection.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This change adds optional password masking to the Editor. To enable
this feature, set the new Mask field to a non-zero rune. Every rune
in the Editor's contents will be replaced by the mask rune in the
visual display, except for newlines. The actual contents of the
editor can still be accessed with Len, Text, and SetText.
Fixes gio#80
Signed-off-by: tainted-bit <sourcehut@taintedbit.com>
In preparation for adding editor masking, Editor can't rely on the
Rune and Len fields of the laid out text.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The caret x-offset tracks residual horizontal offset for arrow key
movements. Caret movement by the mouse should reset the residual.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
An interface for scaling dp and sp is overkill, at least for all
current uses. Make it a concrete struct type, and rename it to the
shorter and more precise Metric.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit configures all remaining widgets to draw themselves in a disabled state
when their layout.Context is disabled. A description of the
strategy employed by each follows:
- Checkbox and RadioButton: Draws the icon component in a lighter color. Currently the label text is left
in its default color.
- ProgressBar: The "progress" color is lightened, but not as much as the background color. This makes the current progress value still readable.
- Editor: The cursor is no longer drawn and the text is lightened.
- Switch: The track is unchanged, but the circular "thumb" component is lightened.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Fixes misaligned carets when the Editor text contains code points
represented by multiple UTF-8 bytes. Line lengths should be
measured in bytes instead of glyphs for caret positioning.
Signed-off-by: tainted-bit <sourcehut@taintedbit.com>
Then, make layout.Context.Now a field, copied from FrameEvent.Now.
API change:
gofmt -r 'gtx.Now() -> gtx.Now'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
When a clickable is pressed and dragged any enclosing List will grab and
cancels the press. To minimize visual dicontinuity, smoothly fade in the
inkwell.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This leverages the new semantics of a disabled layout.Context
to draw all of the button types in a disabled state.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Before this change, package font implemented a global font registry,
with the usual problems of package global state.
This change deletes the global registry and introduces the text.Collection
type for representing a list of fonts and their faces. Collection exports
Lookup that finds the closest match and its face.
The existing FontRegistry is renamed to Cache to reflect its new limited
functionality: a cache of shapes and measurements on top of a Collection.
Then, material.NewTheme is changed to take a Collection and initialize
a Cache.
Updates gio#19 because multiple windows require a separate (writable) Cache per
window, while (read-only) Collections may be shared.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Converting
macro := op.Record(ops)
...
macro.Stop()
macro.Add()
to
macro := op.Record(ops)
...
call := macro.Stop()
call.Add(ops)
Which is more general (call.Add can take a different ops than the op.Record
that started it), and enforced the order between Stop and the subsequent Add.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The funcs replace stack.Push and macro.Record, which become private.
This makes stack and macro faster to write, in particular for stacks
where you can just write the following line to save and restore the
state :
defer op.Push(ops).Pop()
This usage requires Push to return a pointer (since Pop has a pointer
receiver), or else the code doesn't compile.
For consistancy, I tried to do the same for op.Record, but this implied
to turn all the MacroOp fields into pointers, and this caused some
panics. As a result, op.Record doesn't return a pointer.
An other side effect pointed by Larry Clapp: StackOp and MacroOp are not
re-usable any more, you have to allocate a new one for each usage, using
the described funcs above.
Signed-off-by: Thomas Bruyelle <thomas.bruyelle@gmail.com>