gofmt files
This commit is contained in:
parent
2dde2a79e7
commit
1ec8f6b01c
8
area.go
8
area.go
|
@ -45,12 +45,12 @@ var areas = make(map[*C.uiArea]*Area)
|
|||
// SetSize are ints. All other instances of points in parameters and
|
||||
// structures (including sizes of drawn objects) are float64s.
|
||||
type Area struct {
|
||||
c *C.uiControl
|
||||
a *C.uiArea
|
||||
c *C.uiControl
|
||||
a *C.uiArea
|
||||
|
||||
ah *C.uiAreaHandler
|
||||
ah *C.uiAreaHandler
|
||||
|
||||
scrolling bool
|
||||
scrolling bool
|
||||
}
|
||||
|
||||
// NewArea creates a new non-scrolling Area.
|
||||
|
|
|
@ -135,7 +135,7 @@ func unregisterAreaHandler(uah *C.uiAreaHandler) {
|
|||
type AreaDrawParams struct {
|
||||
// Context is the drawing context to draw on. See DrawContext
|
||||
// for how to draw.
|
||||
Context *DrawContext
|
||||
Context *DrawContext
|
||||
|
||||
// AreaWidth and AreaHeight provide the size of the Area for
|
||||
// non-scrolling Areas. For scrolling Areas both values are zero.
|
||||
|
@ -143,17 +143,17 @@ type AreaDrawParams struct {
|
|||
// To reiterate the AreaHandler documentation, do NOT save
|
||||
// these values for later; they can change without generating
|
||||
// an event.
|
||||
AreaWidth float64
|
||||
AreaHeight float64
|
||||
AreaWidth float64
|
||||
AreaHeight float64
|
||||
|
||||
// These four fields define the rectangle that needs to be
|
||||
// redrawn. The system will not draw anything outside this
|
||||
// rectangle, but you can make your drawing faster if you
|
||||
// also stay within the lines.
|
||||
ClipX float64
|
||||
ClipY float64
|
||||
ClipWidth float64
|
||||
ClipHeight float64
|
||||
ClipX float64
|
||||
ClipY float64
|
||||
ClipWidth float64
|
||||
ClipHeight float64
|
||||
}
|
||||
|
||||
//export doAreaHandlerDraw
|
||||
|
@ -161,13 +161,13 @@ func doAreaHandlerDraw(uah *C.uiAreaHandler, ua *C.uiArea, udp *C.uiAreaDrawPara
|
|||
ah := areahandlers[uah]
|
||||
a := areas[ua]
|
||||
dp := &AreaDrawParams{
|
||||
Context: &DrawContext{udp.Context},
|
||||
AreaWidth: float64(udp.AreaWidth),
|
||||
AreaHeight: float64(udp.AreaHeight),
|
||||
ClipX: float64(udp.ClipX),
|
||||
ClipY: float64(udp.ClipY),
|
||||
ClipWidth: float64(udp.ClipWidth),
|
||||
ClipHeight: float64(udp.ClipHeight),
|
||||
Context: &DrawContext{udp.Context},
|
||||
AreaWidth: float64(udp.AreaWidth),
|
||||
AreaHeight: float64(udp.AreaHeight),
|
||||
ClipX: float64(udp.ClipX),
|
||||
ClipY: float64(udp.ClipY),
|
||||
ClipWidth: float64(udp.ClipWidth),
|
||||
ClipHeight: float64(udp.ClipHeight),
|
||||
}
|
||||
ah.Draw(a, dp)
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ func doAreaHandlerDraw(uah *C.uiAreaHandler, ua *C.uiArea, udp *C.uiAreaDrawPara
|
|||
//
|
||||
// TODO note that in the case of a drag, X and Y can be out of bounds, or in the event of a scrolling area, in places that are not visible
|
||||
type AreaMouseEvent struct {
|
||||
X float64
|
||||
Y float64
|
||||
X float64
|
||||
Y float64
|
||||
|
||||
// AreaWidth and AreaHeight provide the size of the Area for
|
||||
// non-scrolling Areas. For scrolling Areas both values are zero.
|
||||
|
@ -185,20 +185,20 @@ type AreaMouseEvent struct {
|
|||
// To reiterate the AreaHandler documentation, do NOT save
|
||||
// these values for later; they can change without generating
|
||||
// an event.
|
||||
AreaWidth float64
|
||||
AreaHeight float64
|
||||
AreaWidth float64
|
||||
AreaHeight float64
|
||||
|
||||
Down uint
|
||||
Up uint
|
||||
Count uint
|
||||
Modifiers Modifiers
|
||||
Held []uint
|
||||
Down uint
|
||||
Up uint
|
||||
Count uint
|
||||
Modifiers Modifiers
|
||||
Held []uint
|
||||
}
|
||||
|
||||
func appendBits(out []uint, held C.uint64_t) []uint {
|
||||
n := uint(1)
|
||||
for i := 0; i < 64; i++ {
|
||||
if held & 1 != 0 {
|
||||
if held&1 != 0 {
|
||||
out = append(out, n)
|
||||
}
|
||||
held >>= 1
|
||||
|
@ -212,15 +212,15 @@ func doAreaHandlerMouseEvent(uah *C.uiAreaHandler, ua *C.uiArea, ume *C.uiAreaMo
|
|||
ah := areahandlers[uah]
|
||||
a := areas[ua]
|
||||
me := &AreaMouseEvent{
|
||||
X: float64(ume.X),
|
||||
Y: float64(ume.Y),
|
||||
AreaWidth: float64(ume.AreaWidth),
|
||||
AreaHeight: float64(ume.AreaHeight),
|
||||
Down: uint(ume.Down),
|
||||
Up: uint(ume.Up),
|
||||
Count: uint(ume.Count),
|
||||
Modifiers: Modifiers(ume.Modifiers),
|
||||
Held: make([]uint, 0, 64),
|
||||
X: float64(ume.X),
|
||||
Y: float64(ume.Y),
|
||||
AreaWidth: float64(ume.AreaWidth),
|
||||
AreaHeight: float64(ume.AreaHeight),
|
||||
Down: uint(ume.Down),
|
||||
Up: uint(ume.Up),
|
||||
Count: uint(ume.Count),
|
||||
Modifiers: Modifiers(ume.Modifiers),
|
||||
Held: make([]uint, 0, 64),
|
||||
}
|
||||
me.Held = appendBits(me.Held, ume.Held1To64)
|
||||
ah.MouseEvent(a, me)
|
||||
|
@ -242,11 +242,11 @@ func doAreaHandlerDragBroken(uah *C.uiAreaHandler, ua *C.uiArea) {
|
|||
|
||||
// TODO document all these
|
||||
type AreaKeyEvent struct {
|
||||
Key rune
|
||||
ExtKey ExtKey
|
||||
Modifier Modifiers
|
||||
Modifiers Modifiers
|
||||
Up bool
|
||||
Key rune
|
||||
ExtKey ExtKey
|
||||
Modifier Modifiers
|
||||
Modifiers Modifiers
|
||||
Up bool
|
||||
}
|
||||
|
||||
//export doAreaHandlerKeyEvent
|
||||
|
@ -254,11 +254,11 @@ func doAreaHandlerKeyEvent(uah *C.uiAreaHandler, ua *C.uiArea, uke *C.uiAreaKeyE
|
|||
ah := areahandlers[uah]
|
||||
a := areas[ua]
|
||||
ke := &AreaKeyEvent{
|
||||
Key: rune(uke.Key),
|
||||
ExtKey: ExtKey(uke.ExtKey),
|
||||
Modifier: Modifiers(uke.Modifier),
|
||||
Modifiers: Modifiers(uke.Modifiers),
|
||||
Up: tobool(uke.Up),
|
||||
Key: rune(uke.Key),
|
||||
ExtKey: ExtKey(uke.ExtKey),
|
||||
Modifier: Modifiers(uke.Modifier),
|
||||
Modifiers: Modifiers(uke.Modifiers),
|
||||
Up: tobool(uke.Up),
|
||||
}
|
||||
return frombool(ah.KeyEvent(a, ke))
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ func doAreaHandlerKeyEvent(uah *C.uiAreaHandler, ua *C.uiArea, uke *C.uiAreaKeyE
|
|||
//
|
||||
// Note: these must be numerically identical to their libui equivalents.
|
||||
type Modifiers uint
|
||||
|
||||
const (
|
||||
Ctrl Modifiers = 1 << iota
|
||||
Alt
|
||||
|
@ -278,9 +279,10 @@ const (
|
|||
//
|
||||
// Note: these must be numerically identical to their libui equivalents.
|
||||
type ExtKey int
|
||||
|
||||
const (
|
||||
Escape ExtKey = iota + 1
|
||||
Insert // equivalent to "Help" on Apple keyboards
|
||||
Insert // equivalent to "Help" on Apple keyboards
|
||||
Delete
|
||||
Home
|
||||
End
|
||||
|
@ -290,7 +292,7 @@ const (
|
|||
Down
|
||||
Left
|
||||
Right
|
||||
F1 // F1..F12 are guaranteed to be consecutive
|
||||
F1 // F1..F12 are guaranteed to be consecutive
|
||||
F2
|
||||
F3
|
||||
F4
|
||||
|
@ -302,8 +304,8 @@ const (
|
|||
F10
|
||||
F11
|
||||
F12
|
||||
N0 // numpad keys; independent of Num Lock state
|
||||
N1 // N0..N9 are guaranteed to be consecutive
|
||||
N0 // numpad keys; independent of Num Lock state
|
||||
N1 // N0..N9 are guaranteed to be consecutive
|
||||
N2
|
||||
N3
|
||||
N4
|
||||
|
|
8
box.go
8
box.go
|
@ -18,10 +18,10 @@ import "C"
|
|||
// stretchy, they will be given equal shares of the leftover space.
|
||||
// There can also be space between each control ("padding").
|
||||
type Box struct {
|
||||
c *C.uiControl
|
||||
b *C.uiBox
|
||||
c *C.uiControl
|
||||
b *C.uiBox
|
||||
|
||||
children []Control
|
||||
children []Control
|
||||
}
|
||||
|
||||
// NewHorizontalBox creates a new horizontal Box.
|
||||
|
@ -102,7 +102,7 @@ func (b *Box) Append(child Control, stretchy bool) {
|
|||
|
||||
// Delete deletes the nth control of the Box.
|
||||
func (b *Box) Delete(n int) {
|
||||
b.children = append(b.children[:n], b.children[n + 1:]...)
|
||||
b.children = append(b.children[:n], b.children[n+1:]...)
|
||||
// TODO why is this uintmax_t instead of intmax_t
|
||||
C.uiBoxDelete(b.b, C.uintmax_t(n))
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ var buttons = make(map[*C.uiButton]*Button)
|
|||
// click to perform an action. A Button has a text label that should
|
||||
// describe what the button does.
|
||||
type Button struct {
|
||||
c *C.uiControl
|
||||
b *C.uiButton
|
||||
c *C.uiControl
|
||||
b *C.uiButton
|
||||
|
||||
onClicked func(*Button)
|
||||
onClicked func(*Button)
|
||||
}
|
||||
|
||||
// NewButton creates a new Button with the given text as its label.
|
||||
|
|
|
@ -21,10 +21,10 @@ var checkboxes = make(map[*C.uiCheckbox]*Checkbox)
|
|||
// side. When the user clicks the checkbox, a check mark will appear
|
||||
// in the box; clicking it again removes the check.
|
||||
type Checkbox struct {
|
||||
co *C.uiControl
|
||||
c *C.uiCheckbox
|
||||
co *C.uiControl
|
||||
c *C.uiCheckbox
|
||||
|
||||
onToggled func(*Checkbox)
|
||||
onToggled func(*Checkbox)
|
||||
}
|
||||
|
||||
// NewCheckbox creates a new Checkbox with the given text as its label.
|
||||
|
|
|
@ -22,10 +22,10 @@ var comboboxes = make(map[*C.uiCombobox]*Combobox)
|
|||
// Combobox also has an entry field that the user can type an alternate
|
||||
// choice into.
|
||||
type Combobox struct {
|
||||
co *C.uiControl
|
||||
c *C.uiCombobox
|
||||
co *C.uiControl
|
||||
c *C.uiCombobox
|
||||
|
||||
onSelected func(*Combobox)
|
||||
onSelected func(*Combobox)
|
||||
}
|
||||
|
||||
// NewCombobox creates a new Combobox.
|
||||
|
@ -41,6 +41,7 @@ func NewCombobox() *Combobox {
|
|||
|
||||
return c
|
||||
}
|
||||
|
||||
/*TODO
|
||||
// NewEditableCombobox creates a new editable Combobox.
|
||||
func NewEditableCombobox() *Combobox {
|
||||
|
|
|
@ -12,8 +12,8 @@ import "C"
|
|||
// DateTimePicker is a Control that represents a field where the user
|
||||
// can enter a date and/or a time.
|
||||
type DateTimePicker struct {
|
||||
c *C.uiControl
|
||||
d *C.uiDateTimePicker
|
||||
c *C.uiControl
|
||||
d *C.uiDateTimePicker
|
||||
}
|
||||
|
||||
// NewDateTimePicker creates a new DateTimePicker that shows
|
||||
|
|
109
draw.go
109
draw.go
|
@ -159,13 +159,14 @@ import "C"
|
|||
// parameter, but some implementations prevent it.)
|
||||
// TODO talk about fill modes
|
||||
type Path struct {
|
||||
p *C.uiDrawPath
|
||||
p *C.uiDrawPath
|
||||
}
|
||||
|
||||
// TODO
|
||||
//
|
||||
// TODO disclaimer
|
||||
type FillMode uint
|
||||
|
||||
const (
|
||||
Winding FillMode = iota
|
||||
Alternate
|
||||
|
@ -184,7 +185,7 @@ func NewPath(fillMode FillMode) *Path {
|
|||
panic("invalid fill mode passed to ui.NewPath()")
|
||||
}
|
||||
return &Path{
|
||||
p: C.uiDrawNewPath(fm),
|
||||
p: C.uiDrawNewPath(fm),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,18 +271,19 @@ func (p *Path) End() {
|
|||
// At present the only DrawContexts are surfaces associated with
|
||||
// Areas and are provided by package ui; see AreaDrawParams.
|
||||
type DrawContext struct {
|
||||
c *C.uiDrawContext
|
||||
c *C.uiDrawContext
|
||||
}
|
||||
|
||||
// BrushType defines the various types of brushes.
|
||||
//
|
||||
// TODO disclaimer
|
||||
type BrushType int
|
||||
|
||||
const (
|
||||
Solid BrushType = iota
|
||||
LinearGradient
|
||||
RadialGradient
|
||||
Image // presently unimplemented
|
||||
Image // presently unimplemented
|
||||
)
|
||||
|
||||
// TODO
|
||||
|
@ -289,6 +291,7 @@ const (
|
|||
// TODO disclaimer
|
||||
// TODO rename these to put LineCap at the beginning? or just Cap?
|
||||
type LineCap int
|
||||
|
||||
const (
|
||||
FlatCap LineCap = iota
|
||||
RoundCap
|
||||
|
@ -299,6 +302,7 @@ const (
|
|||
//
|
||||
// TODO disclaimer
|
||||
type LineJoin int
|
||||
|
||||
const (
|
||||
MiterJoin LineJoin = iota
|
||||
RoundJoin
|
||||
|
@ -310,32 +314,32 @@ const DefaultMiterLimit = 10.0
|
|||
|
||||
// TODO
|
||||
type Brush struct {
|
||||
Type BrushType
|
||||
Type BrushType
|
||||
|
||||
// If Type is Solid.
|
||||
// TODO
|
||||
R float64
|
||||
G float64
|
||||
B float64
|
||||
A float64
|
||||
R float64
|
||||
G float64
|
||||
B float64
|
||||
A float64
|
||||
|
||||
// If Type is LinearGradient or RadialGradient.
|
||||
// TODO
|
||||
X0 float64 // start point for both
|
||||
Y0 float64
|
||||
X1 float64 // linear: end point; radial: circle center
|
||||
Y1 float64
|
||||
OuterRadius float64 // for radial gradients only
|
||||
Stops []GradientStop
|
||||
X0 float64 // start point for both
|
||||
Y0 float64
|
||||
X1 float64 // linear: end point; radial: circle center
|
||||
Y1 float64
|
||||
OuterRadius float64 // for radial gradients only
|
||||
Stops []GradientStop
|
||||
}
|
||||
|
||||
// TODO
|
||||
type GradientStop struct {
|
||||
Pos float64 // between 0 and 1 inclusive
|
||||
R float64
|
||||
G float64
|
||||
B float64
|
||||
A float64
|
||||
Pos float64 // between 0 and 1 inclusive
|
||||
R float64
|
||||
G float64
|
||||
B float64
|
||||
A float64
|
||||
}
|
||||
|
||||
func (b *Brush) toC() *C.uiDrawBrush {
|
||||
|
@ -373,12 +377,12 @@ func (b *Brush) toC() *C.uiDrawBrush {
|
|||
|
||||
// TODO
|
||||
type StrokeParams struct {
|
||||
Cap LineCap
|
||||
Join LineJoin
|
||||
Thickness float64
|
||||
MiterLimit float64
|
||||
Dashes []float64
|
||||
DashPhase float64
|
||||
Cap LineCap
|
||||
Join LineJoin
|
||||
Thickness float64
|
||||
MiterLimit float64
|
||||
Dashes []float64
|
||||
DashPhase float64
|
||||
}
|
||||
|
||||
func (sp *StrokeParams) toC() *C.uiDrawStrokeParams {
|
||||
|
@ -418,12 +422,12 @@ func (c *DrawContext) Fill(p *Path, b *Brush) {
|
|||
// TODO
|
||||
// TODO should the methods of these return self for chaining?
|
||||
type Matrix struct {
|
||||
M11 float64
|
||||
M12 float64
|
||||
M21 float64
|
||||
M22 float64
|
||||
M31 float64
|
||||
M32 float64
|
||||
M11 float64
|
||||
M12 float64
|
||||
M21 float64
|
||||
M22 float64
|
||||
M31 float64
|
||||
M32 float64
|
||||
}
|
||||
|
||||
// TODO identity matrix
|
||||
|
@ -576,7 +580,7 @@ type FontFamilies struct {
|
|||
// ListFontFamilies creates a new FontFamilies object ready for use.
|
||||
func ListFontFamilies() *FontFamilies {
|
||||
return &FontFamilies{
|
||||
ff: C.uiDrawListFontFamilies(),
|
||||
ff: C.uiDrawListFontFamilies(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,6 +613,7 @@ func (f *FontFamilies) Family(n int) string {
|
|||
//
|
||||
// TODO disclaimer
|
||||
type TextWeight int
|
||||
|
||||
const (
|
||||
TextWeightThin TextWeight = iota
|
||||
TextWeightUltraLight
|
||||
|
@ -627,10 +632,11 @@ const (
|
|||
//
|
||||
// TODO disclaimer
|
||||
type TextItalic int
|
||||
|
||||
const (
|
||||
TextItalicNormal TextItalic = iota
|
||||
TextItalicOblique // merely slanted text
|
||||
TextItalicItalic // true italics
|
||||
TextItalicNormal TextItalic = iota
|
||||
TextItalicOblique // merely slanted text
|
||||
TextItalicItalic // true italics
|
||||
)
|
||||
|
||||
// TextStretch defines the various text stretches, in order of
|
||||
|
@ -644,6 +650,7 @@ const (
|
|||
//
|
||||
// TODO disclaimer
|
||||
type TextStretch int
|
||||
|
||||
const (
|
||||
TextStretchUltraCondensed TextStretch = iota
|
||||
TextStretchExtraCondensed
|
||||
|
@ -658,16 +665,16 @@ const (
|
|||
|
||||
// FontDescriptor describes a Font.
|
||||
type FontDescriptor struct {
|
||||
Family string
|
||||
Size float64 // as a text size, for instance 12 for a 12-point font
|
||||
Weight TextWeight
|
||||
Italic TextItalic
|
||||
Stretch TextStretch
|
||||
Family string
|
||||
Size float64 // as a text size, for instance 12 for a 12-point font
|
||||
Weight TextWeight
|
||||
Italic TextItalic
|
||||
Stretch TextStretch
|
||||
}
|
||||
|
||||
// Font represents an actual font that can be drawn with.
|
||||
type Font struct {
|
||||
f *C.uiDrawTextFont
|
||||
f *C.uiDrawTextFont
|
||||
}
|
||||
|
||||
// LoadClosestFont loads a Font.
|
||||
|
@ -685,14 +692,14 @@ type Font struct {
|
|||
//
|
||||
// TODO guarantee that passing *that* back into LoadClosestFont() returns the same font
|
||||
func LoadClosestFont(desc *FontDescriptor) *Font {
|
||||
d := C.newFontDescriptor() // both of these are freed by C.newFont()
|
||||
d := C.newFontDescriptor() // both of these are freed by C.newFont()
|
||||
d.Family = C.CString(desc.Family)
|
||||
d.Size = C.double(desc.Size)
|
||||
d.Weight = C.uiDrawTextWeight(desc.Weight)
|
||||
d.Italic = C.uiDrawTextItalic(desc.Italic)
|
||||
d.Stretch = C.uiDrawTextStretch(desc.Stretch)
|
||||
return &Font{
|
||||
f: C.newFont(d),
|
||||
f: C.newFont(d),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -728,24 +735,24 @@ func (f *Font) Describe() *FontDescriptor {
|
|||
type FontMetrics struct {
|
||||
// Ascent is the ascent of the font; that is, the distance from
|
||||
// the top of the character cell to the baseline.
|
||||
Ascent float64
|
||||
Ascent float64
|
||||
|
||||
// Descent is the descent of the font; that is, the distance from
|
||||
// the baseline to the bottom of the character cell. The sum of
|
||||
// Ascent and Descent is the height of the character cell (and
|
||||
// thus, the maximum height of a line of text).
|
||||
Descent float64
|
||||
Descent float64
|
||||
|
||||
// Leading is the amount of space the font designer suggests
|
||||
// to have between lines (between the bottom of the first line's
|
||||
// character cell and the top of the second line's character cell).
|
||||
// This is a suggestion; it is chosen by the font designer to
|
||||
// improve legibility.
|
||||
Leading float64
|
||||
Leading float64
|
||||
|
||||
// TODO figure out what these are
|
||||
UnderlinePos float64
|
||||
UnderlineThickness float64
|
||||
UnderlinePos float64
|
||||
UnderlineThickness float64
|
||||
}
|
||||
|
||||
// Metrics returns metrics about the given Font.
|
||||
|
@ -776,14 +783,14 @@ func (f *Font) Metrics() *FontMetrics {
|
|||
// The block of text can either be a single line or multiple
|
||||
// word-wrapped lines, each with a given maximum width.
|
||||
type TextLayout struct {
|
||||
l *C.uiDrawTextLayout
|
||||
l *C.uiDrawTextLayout
|
||||
}
|
||||
|
||||
// NewTextLayout creates a new TextLayout.
|
||||
// For details on the width parameter, see SetWidth.
|
||||
func NewTextLayout(text string, defaultFont *Font, width float64) *TextLayout {
|
||||
l := new(TextLayout)
|
||||
ctext := C.CString(text) // freed by C.newTextLayout()
|
||||
ctext := C.CString(text) // freed by C.newTextLayout()
|
||||
l.l = C.newTextLayout(ctext, defaultFont.f, C.double(width))
|
||||
return l
|
||||
}
|
||||
|
|
6
entry.go
6
entry.go
|
@ -24,10 +24,10 @@ var entries = make(map[*C.uiEntry]*Entry)
|
|||
// Entry is a Control that represents a space that the user can
|
||||
// type a single line of text into.
|
||||
type Entry struct {
|
||||
c *C.uiControl
|
||||
e *C.uiEntry
|
||||
c *C.uiControl
|
||||
e *C.uiEntry
|
||||
|
||||
onChanged func(*Entry)
|
||||
onChanged func(*Entry)
|
||||
}
|
||||
|
||||
// NewEntry creates a new Entry.
|
||||
|
|
6
group.go
6
group.go
|
@ -13,10 +13,10 @@ import "C"
|
|||
// a labelled box (though some systems make this box invisible).
|
||||
// You can use this to group related controls together.
|
||||
type Group struct {
|
||||
c *C.uiControl
|
||||
g *C.uiGroup
|
||||
c *C.uiControl
|
||||
g *C.uiGroup
|
||||
|
||||
child Control
|
||||
child Control
|
||||
}
|
||||
|
||||
// NewGroup creates a new Group.
|
||||
|
|
4
label.go
4
label.go
|
@ -12,8 +12,8 @@ import "C"
|
|||
// Label is a Control that represents a line of text that cannot be
|
||||
// interacted with. TODO rest of documentation.
|
||||
type Label struct {
|
||||
c *C.uiControl
|
||||
l *C.uiLabel
|
||||
c *C.uiControl
|
||||
l *C.uiLabel
|
||||
}
|
||||
|
||||
// NewLabel creates a new Label with the given text.
|
||||
|
|
6
main.go
6
main.go
|
@ -3,8 +3,8 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"errors"
|
||||
"runtime"
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
@ -67,9 +67,9 @@ func Quit() {
|
|||
// These prevent the passing of Go functions into C land.
|
||||
// TODO make an actual sparse list instead of this monotonic map thingy
|
||||
var (
|
||||
qmmap = make(map[uintptr]func())
|
||||
qmmap = make(map[uintptr]func())
|
||||
qmcurrent = uintptr(0)
|
||||
qmlock sync.Mutex
|
||||
qmlock sync.Mutex
|
||||
)
|
||||
|
||||
// QueueMain queues f to be executed on the GUI thread when
|
||||
|
|
|
@ -12,8 +12,8 @@ import "C"
|
|||
// ProgressBar is a Control that represents a horizontal bar that
|
||||
// is filled in progressively over time as a process completes.
|
||||
type ProgressBar struct {
|
||||
c *C.uiControl
|
||||
p *C.uiProgressBar
|
||||
c *C.uiControl
|
||||
p *C.uiProgressBar
|
||||
}
|
||||
|
||||
// NewProgressBar creates a new ProgressBar.
|
||||
|
|
|
@ -12,8 +12,8 @@ import "C"
|
|||
// RadioButtons is a Control that represents a set of checkable
|
||||
// buttons from which exactly one may be chosen by the user.
|
||||
type RadioButtons struct {
|
||||
c *C.uiControl
|
||||
r *C.uiRadioButtons
|
||||
c *C.uiControl
|
||||
r *C.uiRadioButtons
|
||||
}
|
||||
|
||||
// NewRadioButtons creates a new RadioButtons.
|
||||
|
|
|
@ -21,10 +21,10 @@ var sliders = make(map[*C.uiSlider]*Slider)
|
|||
// a range of integers. The user can drag a pointer on the bar to
|
||||
// select an integer.
|
||||
type Slider struct {
|
||||
c *C.uiControl
|
||||
s *C.uiSlider
|
||||
c *C.uiControl
|
||||
s *C.uiSlider
|
||||
|
||||
onChanged func(*Slider)
|
||||
onChanged func(*Slider)
|
||||
}
|
||||
|
||||
// NewSlider creates a new Slider. If min >= max, they are swapped.
|
||||
|
|
|
@ -21,10 +21,10 @@ var spinboxes = make(map[*C.uiSpinbox]*Spinbox)
|
|||
// enter integers. The space also comes with buttons to add or
|
||||
// subtract 1 from the integer.
|
||||
type Spinbox struct {
|
||||
c *C.uiControl
|
||||
s *C.uiSpinbox
|
||||
c *C.uiControl
|
||||
s *C.uiSpinbox
|
||||
|
||||
onChanged func(*Spinbox)
|
||||
onChanged func(*Spinbox)
|
||||
}
|
||||
|
||||
// NewSpinbox creates a new Spinbox. If min >= max, they are swapped.
|
||||
|
|
12
tab.go
12
tab.go
|
@ -13,10 +13,10 @@ import "C"
|
|||
// has a label. The user can click on the tabs themselves to switch
|
||||
// pages. Individual pages can also have margins.
|
||||
type Tab struct {
|
||||
c *C.uiControl
|
||||
t *C.uiTab
|
||||
c *C.uiControl
|
||||
t *C.uiTab
|
||||
|
||||
children []Control
|
||||
children []Control
|
||||
}
|
||||
|
||||
// NewTab creates a new Tab.
|
||||
|
@ -94,17 +94,17 @@ func (t *Tab) InsertAt(name string, n int, child Control) {
|
|||
// TODO why is this uintmax_t and not intmax_t
|
||||
C.uiTabInsertAt(t.t, cname, C.uintmax_t(n), c)
|
||||
freestr(cname)
|
||||
ch := make([]Control, len(t.children) + 1)
|
||||
ch := make([]Control, len(t.children)+1)
|
||||
// and insert into t.children at the right place
|
||||
copy(ch[:n], t.children[:n])
|
||||
ch[n] = child
|
||||
copy(ch[n + 1:], t.children[n:])
|
||||
copy(ch[n+1:], t.children[n:])
|
||||
t.children = ch
|
||||
}
|
||||
|
||||
// Delete deletes the nth page of the Tab.
|
||||
func (t *Tab) Delete(n int) {
|
||||
t.children = append(t.children[:n], t.children[n + 1:]...)
|
||||
t.children = append(t.children[:n], t.children[n+1:]...)
|
||||
C.uiTabDelete(t.t, C.uintmax_t(n))
|
||||
}
|
||||
|
||||
|
|
2
util.go
2
util.go
|
@ -20,7 +20,7 @@ import "C"
|
|||
// of the desired length, we get our C.CMalloc(). Using a slice
|
||||
// that's always initialized to zero gives us the ZeroMemory()
|
||||
// for free.
|
||||
var uimallocBytes = make([]byte, 1024) // 1024 bytes first
|
||||
var uimallocBytes = make([]byte, 1024) // 1024 bytes first
|
||||
|
||||
//export uimalloc
|
||||
func uimalloc(n C.size_t) unsafe.Pointer {
|
||||
|
|
|
@ -22,12 +22,12 @@ var windows = make(map[*C.uiWindow]*Window)
|
|||
// entirety of the window. Though a Window is a Control,
|
||||
// a Window cannot be the child of another Control.
|
||||
type Window struct {
|
||||
c *C.uiControl
|
||||
w *C.uiWindow
|
||||
c *C.uiControl
|
||||
w *C.uiWindow
|
||||
|
||||
child Control
|
||||
child Control
|
||||
|
||||
onClosing func(w *Window) bool
|
||||
onClosing func(w *Window) bool
|
||||
}
|
||||
|
||||
// NewWindow creates a new Window.
|
||||
|
|
|
@ -5,8 +5,8 @@ package ui
|
|||
var page2group *Group
|
||||
|
||||
var (
|
||||
movingLabel *Label
|
||||
movingBoxes [2]*Box
|
||||
movingLabel *Label
|
||||
movingBoxes [2]*Box
|
||||
movingCurrent int
|
||||
)
|
||||
|
||||
|
@ -22,8 +22,9 @@ func moveLabel(*Button) {
|
|||
}
|
||||
|
||||
var moveBack bool
|
||||
|
||||
const (
|
||||
moveOutText = "Move Page 1 Out"
|
||||
moveOutText = "Move Page 1 Out"
|
||||
moveBackText = "Move Page 1 Back"
|
||||
)
|
||||
|
||||
|
@ -92,7 +93,7 @@ func makePage2() *Box {
|
|||
button = NewButton("Open Menuless Window")
|
||||
button.OnClicked(func(*Button) {
|
||||
w := NewWindow("Another Window", 100, 100, true)
|
||||
//TODO w.SetChild(makePage6())
|
||||
//TODO w.SetChild(makePage6())
|
||||
w.SetMargined(true)
|
||||
w.Show()
|
||||
})
|
||||
|
@ -154,8 +155,8 @@ func makePage2() *Box {
|
|||
page2.Append(hbox, false)
|
||||
|
||||
disabledTab := newTab()
|
||||
disabledTab.Append("Disabled", NewButton("Button"));
|
||||
disabledTab.Append("Tab", NewLabel("Label"));
|
||||
disabledTab.Append("Disabled", NewButton("Button"))
|
||||
disabledTab.Append("Tab", NewLabel("Label"))
|
||||
disabledTab.Disable()
|
||||
page2.Append(disabledTab, true)
|
||||
|
||||
|
|
10
zz_test.go
10
zz_test.go
|
@ -8,9 +8,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
nomenus = flag.Bool("nomenus", false, "No menus")
|
||||
nomenus = flag.Bool("nomenus", false, "No menus")
|
||||
startspaced = flag.Bool("startspaced", false, "Start with spacing")
|
||||
swaphv = flag.Bool("swaphv", false, "Swap horizontal and vertical boxes")
|
||||
swaphv = flag.Bool("swaphv", false, "Swap horizontal and vertical boxes")
|
||||
)
|
||||
|
||||
var mainbox *Box
|
||||
|
@ -64,9 +64,9 @@ func TestIt(t *testing.T) {
|
|||
|
||||
var (
|
||||
spwindows []*Window
|
||||
sptabs []*Tab
|
||||
spgroups []*Group
|
||||
spboxes []*Box
|
||||
sptabs []*Tab
|
||||
spgroups []*Group
|
||||
spboxes []*Box
|
||||
)
|
||||
|
||||
func newWindow(title string, width int, height int, hasMenubar bool) *Window {
|
||||
|
|
Loading…
Reference in New Issue