Documentation
¶
Index ¶
- type Bool
- type Border
- type ChangeEvent
- type Click
- type Clickable
- func (b *Clickable) Click()
- func (b *Clickable) Clicked(gtx layout.Context) bool
- func (b *Clickable) History() []Press
- func (b *Clickable) Hovered() bool
- func (b *Clickable) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions
- func (b *Clickable) Pressed() bool
- func (b *Clickable) Update(gtx layout.Context) (Click, bool)
- type Decorations
- type Draggable
- func (d *Draggable) Dragging() bool
- func (d *Draggable) Layout(gtx layout.Context, w, drag layout.Widget) layout.Dimensions
- func (d *Draggable) Offer(gtx layout.Context, mime string, data io.ReadCloser)
- func (d *Draggable) Pos() f32.Point
- func (d *Draggable) Update(gtx layout.Context) (mime string, requested bool)
- type Editor
- func (e *Editor) CaretCoords() f32.Point
- func (e *Editor) CaretPos() (line, col int)
- func (e *Editor) ClearSelection()
- func (e *Editor) Delete(graphemeClusters int) (deletedRunes int)
- func (e *Editor) GetScrollBounds() image.Rectangle
- func (e *Editor) GetScrollX() int
- func (e *Editor) GetScrollY() int
- func (e *Editor) Insert(s string) (insertedRunes int)
- func (e *Editor) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, ...) layout.Dimensions
- func (e *Editor) Len() int
- func (e *Editor) MoveCaret(startDelta, endDelta int)
- func (e *Editor) Read(p []byte) (int, error)
- func (e *Editor) Regions(start, end int, regions []Region) []Region
- func (e *Editor) Seek(offset int64, whence int) (int64, error)
- func (e *Editor) SelectedText() string
- func (e *Editor) Selection() (start, end int)
- func (e *Editor) SelectionLen() int
- func (e *Editor) SetCaret(start, end int)
- func (e *Editor) SetScrollCaret(b bool)
- func (e *Editor) SetScrollY(y int)
- func (e *Editor) SetText(s string)
- func (e *Editor) Text() string
- func (e *Editor) Update(gtx layout.Context) (EditorEvent, bool)
- func (e *Editor) WriteTo(w io.Writer) (int64, error)
- type EditorEvent
- type Enum
- type Fit
- type Float
- type Icon
- type Image
- type Label
- type List
- type Press
- type Region
- type Scrollbar
- func (s *Scrollbar) AddDrag(ops *op.Ops)
- func (s *Scrollbar) AddIndicator(ops *op.Ops)
- func (s *Scrollbar) AddTrack(ops *op.Ops)
- func (s *Scrollbar) Dragging() bool
- func (s *Scrollbar) IndicatorHovered() bool
- func (s *Scrollbar) ScrollDistance() float32
- func (s *Scrollbar) TrackHovered() bool
- func (s *Scrollbar) Update(gtx layout.Context, axis layout.Axis, viewportStart, viewportEnd float32)
- type SelectEvent
- type Selectable
- func (l *Selectable) ClearSelection()
- func (l *Selectable) Focused() bool
- func (l *Selectable) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, ...) layout.Dimensions
- func (l *Selectable) Regions(start, end int, regions []Region) []Region
- func (l *Selectable) SelectedText() string
- func (l *Selectable) Selection() (start, end int)
- func (l *Selectable) SelectionLen() int
- func (l *Selectable) SetCaret(start, end int)
- func (l *Selectable) SetText(s string)
- func (l *Selectable) Text() string
- func (l *Selectable) Truncated() bool
- func (l *Selectable) Update(gtx layout.Context) bool
- type SubmitEvent
- type TextInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeEvent ¶
type ChangeEvent struct{}
type Clickable ¶
type Clickable struct {
// contains filtered or unexported fields
}
Example (Passthrough) ¶
package main
import (
"fmt"
"image"
"github.com/nanorele/gio/f32"
"github.com/nanorele/gio/io/input"
"github.com/nanorele/gio/io/pointer"
"github.com/nanorele/gio/layout"
"github.com/nanorele/gio/op"
"github.com/nanorele/gio/widget"
)
func main() {
var button1, button2 widget.Clickable
var r input.Router
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
Source: r.Source(),
}
widget := func() {
content := func(gtx layout.Context) layout.Dimensions { return layout.Dimensions{Size: gtx.Constraints.Min} }
button1.Layout(gtx, content)
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
button2.Layout(gtx, content)
}
widget()
r.Frame(gtx.Ops)
r.Queue(
pointer.Event{
Source: pointer.Mouse,
Buttons: pointer.ButtonPrimary,
Kind: pointer.Press,
Position: f32.Pt(50, 50),
},
pointer.Event{
Source: pointer.Mouse,
Buttons: pointer.ButtonPrimary,
Kind: pointer.Release,
Position: f32.Pt(50, 50),
},
)
if button1.Clicked(gtx) {
fmt.Println("button1 clicked!")
}
if button2.Clicked(gtx) {
fmt.Println("button2 clicked!")
}
}
Output:
type Decorations ¶
type Decorations struct {
Maximized bool
// contains filtered or unexported fields
}
func (*Decorations) LayoutMove ¶
func (d *Decorations) LayoutMove(gtx layout.Context, w layout.Widget) layout.Dimensions
type Draggable ¶
type Draggable struct {
Type string
// contains filtered or unexported fields
}
func (*Draggable) Layout ¶
Example ¶
package main
import (
"fmt"
"image"
"io"
"strings"
"github.com/nanorele/gio/f32"
"github.com/nanorele/gio/io/event"
"github.com/nanorele/gio/io/input"
"github.com/nanorele/gio/io/pointer"
"github.com/nanorele/gio/io/transfer"
"github.com/nanorele/gio/layout"
"github.com/nanorele/gio/op"
"github.com/nanorele/gio/op/clip"
"github.com/nanorele/gio/widget"
)
func main() {
var r input.Router
gtx := layout.Context{
Ops: new(op.Ops),
Constraints: layout.Exact(image.Pt(100, 100)),
Source: r.Source(),
}
const mime = "MyMime"
drag := &widget.Draggable{Type: mime}
var drop int
widget := func() {
w := func(gtx layout.Context) layout.Dimensions {
sz := image.Pt(10, 10)
return layout.Dimensions{Size: sz}
}
drag.Layout(gtx, w, w)
if m, ok := drag.Update(gtx); ok {
drag.Offer(gtx, m, io.NopCloser(strings.NewReader("hello world")))
}
ds := clip.Rect{
Min: image.Pt(20, 20),
Max: image.Pt(40, 40),
}.Push(gtx.Ops)
event.Op(gtx.Ops, &drop)
ds.Pop()
for {
ev, ok := gtx.Event(transfer.TargetFilter{Target: &drop, Type: mime})
if !ok {
break
}
switch e := ev.(type) {
case transfer.DataEvent:
data := e.Open()
defer data.Close()
content, _ := io.ReadAll(data)
fmt.Println(string(content))
}
}
}
widget()
r.Frame(gtx.Ops)
r.Queue(
pointer.Event{
Kind: pointer.Press,
Position: f32.Pt(5, 5),
},
pointer.Event{
Kind: pointer.Move,
Position: f32.Pt(5, 5),
},
pointer.Event{
Kind: pointer.Release,
Position: f32.Pt(30, 30),
},
)
widget()
r.Frame(gtx.Ops)
widget()
}
Output:
type Editor ¶
type Editor struct {
Alignment text.Alignment
LineHeight unit.Sp
LineHeightScale float32
SingleLine bool
ReadOnly bool
Submit bool
Mask rune
InputHint key.InputHint
MaxLen int
Filter string
WrapPolicy text.WrapPolicy
// contains filtered or unexported fields
}
func (*Editor) CaretCoords ¶
func (*Editor) ClearSelection ¶
func (e *Editor) ClearSelection()
func (*Editor) GetScrollBounds ¶
func (*Editor) GetScrollX ¶
func (*Editor) GetScrollY ¶
func (*Editor) SelectedText ¶
func (*Editor) SelectionLen ¶
func (*Editor) SetScrollCaret ¶ added in v1.0.11
func (*Editor) SetScrollY ¶
type EditorEvent ¶
type EditorEvent interface {
// contains filtered or unexported methods
}
type Enum ¶
type Enum struct {
Value string
// contains filtered or unexported fields
}
type Float ¶
type Float struct {
Value float32
// contains filtered or unexported fields
}
type Label ¶
type Label struct {
Alignment text.Alignment
MaxLines int
Truncator string
WrapPolicy text.WrapPolicy
LineHeight unit.Sp
LineHeightScale float32
}
type Scrollbar ¶
type Scrollbar struct {
// contains filtered or unexported fields
}
func (*Scrollbar) AddIndicator ¶
func (*Scrollbar) IndicatorHovered ¶
func (*Scrollbar) ScrollDistance ¶
func (*Scrollbar) TrackHovered ¶
type SelectEvent ¶
type SelectEvent struct{}
type Selectable ¶
type Selectable struct {
Alignment text.Alignment
MaxLines int
Truncator string
WrapPolicy text.WrapPolicy
LineHeight unit.Sp
LineHeightScale float32
// contains filtered or unexported fields
}
func (*Selectable) ClearSelection ¶
func (l *Selectable) ClearSelection()
func (*Selectable) Focused ¶
func (l *Selectable) Focused() bool
func (*Selectable) Regions ¶
func (l *Selectable) Regions(start, end int, regions []Region) []Region
func (*Selectable) SelectedText ¶
func (l *Selectable) SelectedText() string
func (*Selectable) Selection ¶
func (l *Selectable) Selection() (start, end int)
func (*Selectable) SelectionLen ¶
func (l *Selectable) SelectionLen() int
func (*Selectable) SetCaret ¶
func (l *Selectable) SetCaret(start, end int)
func (*Selectable) SetText ¶
func (l *Selectable) SetText(s string)
func (*Selectable) Text ¶
func (l *Selectable) Text() string
func (*Selectable) Truncated ¶
func (l *Selectable) Truncated() bool
type SubmitEvent ¶
type SubmitEvent struct {
Text string
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.