It wasn't used, and it's not clear that it is useful at all in its current
form. For example, a single control with multiple handler keys (say, one for
scrolling and one for clicking) will only receive priority Foremost for one of
them.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
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>
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>
While "DrawEvent" was too specific (op.Ops contains non-draw events),
"Update" is too vague: it's a common word, and could be misunderstood
to mean update parts of a window, not replace it.
"FrameEvent" is more specific, and is the usual way to refer to immediate
mode drawing.
While we're here, unexport Window.Update and add a Frame function to
FrameEvent, to emphasize that updating the window frame is only
appropriate during the handling of a FrameEvent.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
First, let the handlers know they're dropping with a cancel event.
Second, reset the grab flag of dropped handlers.
Fixes issues when drag-scrolling and then clicking and another with two nested
drag gestures where the grab flag is kept for the second handler even after it
is pushed out by the first handler grabbing.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Go 1.14 disables the use of `go run` in module mode outside a module,
see https://golang.org/issue/32027.
Suggest initializing a module in the current directory instead; that
enables module mode (in Go 1.13) and enables `go run`.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
While we're here, replace Height and Width options with just a Size; the value
of separate width and height options is not clear to me.
Finally, leave out the wrapping struct from the Option type, the
function is enough.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
With Context containing all the necessary information, separate
Init methods no longer makes much sense. Delete them and thereby
remove a source of runtime panics.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>