Commit Graph

25 Commits

Author SHA1 Message Date
Elias Naur ff3fc7a24a widget,text: move Label and Editor from text to widget package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur a5b22860ac text: replace Editor.Event with Editor.Event and add Text to SubmitEvent
THe single-stepping Event was done so that SubmitEvents didn't have to
copy the text out if it wasn't needed.

This is a dubious optimization, because SubmitEvents are only generated
when Editor.Submit is true, in which case it is highly likely the user
wants the text.

Furthermore, I expect Editors with Submit enabled to be relatively short,
in the order of a message field in a chat program.

Finally, Editor will need support for undo at some point. Supporting undo
means we can support a lightweight SubmitEvent that points to an older Editor
state.

All in all (1) we gain a simpler Events method, and (2) we can allow the user
to call it before or after Editor.Layout. Before this change any the events were
gone after Layout was called.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur d8e3d1077c text: maintain valid Editor scroll offset
No functional changes.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur bc8ad61b54 text: remove themable properties from Editor and Label
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur dbb62ae0f6 text: remove padding from Editor
Before this change, the Editor computed a suitable padding for itself
from its font and text. Varying the padding according to the particular
font and text doesn't seem worth it and interferes with higher level widgets'
ability to overlay hints and the like on top of the editor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur f35fe407b3 text: tighten clip bounds for Editor and Label
We're about to remove the extra padding from Editor. To do that, the
clipping must account for text drawing that lie outside the viewport.

With accurate clip bounds, use it for Label as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur bef7c39e4c text: replace Family with Shaper, add Font, Face
There is now a single shaping implementation, Shaper, for all fonts, replacing
Family that only covered a single typeface.

A typeface is identified by a name, where the empty string denotes the
default typeface.

Font is introduced to specify a particular font from the typeface, style,
weight and size.

Face is changed to an interface for a particular layout and shaping method.
The text/shape package is renamed to text/opentype and contains a Face
implementation based on golang.org/x/image/font/sfnt.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur ea404bc8fc text: refactor Editor
To prepare for separating drawing from state tracking, refactor
Editor so that only its top level Layout method touches font
parameters and materials.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00
Elias Naur ef5cf5b724 op/paint: return ClipOp from Path.End
Instead of adding an implicit ClipOp, return a ClipOp ready to use, freeing the
caller from recording a macro.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur 163d9037e6 text: fix editBuffer.runeBefore
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-10 15:27:02 +02:00
Elias Naur afeaa247c8 text: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-06 13:03:19 +02:00
Elias Naur 225c73f012 text: move Label.it to a local variable
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-06 12:29:35 +02:00
Elias Naur 1b44594411 text/shape: reduce garbage a bit
The sfnt.Buffer embedded in the opentype type caused instances of
it to escape. Move the buffer to Family to avoid that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-05 22:53:37 +02:00
Elias Naur 2097c6475d text/shape: remove Family.Reset by introducing LRU caches
It was easy to forget Family.Reset, and the per-frame caching strategy is
probably too aggressive. Use a static size for the caches and evict
according to a least recently used policy.

Reset is then no longer required, and we can delete it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-05 22:27:32 +02:00
Elias Naur 0b637f549d text: rename Face to Family and let Face denote a family configuration
While here, rename Family.Path to Shape which a more precise term.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-05 22:27:32 +02:00
Elias Naur b4a52d3010 text: make text size implicit
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-05 11:22:26 +02:00
Elias Naur f230036cad text: re-phrase and clarify Label.MaxLines comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-04 19:18:05 +02:00
Elias Naur 6dad034b22 op/paint: rename PathBuilder to Path
There was no "Path" to "Build", so let's just use the simpler name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-03 13:35:38 +02:00
Elias Naur 3784ece6dd all: rename package ui to unit
Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 1d3360699e text/shape: move package measure
Text shaping is a common name for what package measure does. Rename
it to "shape" and move it below the text package.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur beaec661d2 op/paint: move paint package below the op package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 8cf35a1f97 op: add package op for operations
Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur e7a97bf176 io/event: move event types from package ui to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 15:18:08 +02:00
Elias Naur 7a259e68f7 io: give event packages a common prefix
Packages that provide support for external events such as pointer, key and
system are only the beginning. Future packages are expected for clipboard
access, drag and drop, gps positions and so on.

To keep the number of top-level packages under control, move such I/O packages
to the new `io` directory.

The `system` package name was the previous solution to keeping the number of
top-level packages under control: I named it `system` instead of the narrower
`profile` because I expected to put all the less common events into it, turning
`system` into a "package util" smell.

With `io`, package system can be renamed to `profile`.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 14:50:55 +02:00
Elias Naur 22cd88df9f all: rename the gioui.org/ui module to gioui.org
The "ui" is redundant and stutters.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:37:06 +02:00