diff --git a/button.go b/button.go index 8d02985..a82e86d 100644 --- a/button.go +++ b/button.go @@ -28,7 +28,7 @@ func NewButton (text string) *Button { ContainerBox: tomo.NewContainerBox(), label: NewLabel(text), } - theme.Apply(box, theme.R("objects", "Button", "")) + tomo.Apply(box, tomo.R("objects", "Button", "")) box.label.SetAlign(tomo.AlignMiddle, tomo.AlignMiddle) box.SetLayout(buttonLayout) box.SetText(text) @@ -48,7 +48,7 @@ func NewButton (text string) *Button { func (this *Button) SetText (text string) { this.label.SetText(text) if this.labelActive && text == "" { - this.Delete(this.label) + this.Remove(this.label) this.labelActive = false } if !this.labelActive && text != "" { @@ -60,11 +60,11 @@ func (this *Button) SetText (text string) { // SetIcon sets an icon for this button. Setting the icon to IconUnknown will // remove it. -func (this *Button) SetIcon (id theme.Icon) { - if this.icon != nil { this.Delete(this.icon) } +func (this *Button) SetIcon (id tomo.Icon) { + if this.icon != nil { this.Remove(this.icon) } - var icon *Icon; if id != theme.IconUnknown { - icon = NewIcon(id, theme.IconSizeSmall) + var icon *Icon; if id != tomo.IconUnknown { + icon = NewIcon(id, tomo.IconSizeSmall) } this.icon = icon diff --git a/checkbox.go b/checkbox.go index f24de62..c7a8181 100644 --- a/checkbox.go +++ b/checkbox.go @@ -18,7 +18,7 @@ func NewCheckbox (value bool) *Checkbox { box := &Checkbox { Box: tomo.NewBox(), } - theme.Apply(box, theme.R("objects", "Checkbox", "")) + tomo.Apply(box, tomo.R("objects", "Checkbox", "")) box.SetValue(false) box.OnMouseUp(box.handleMouseUp) @@ -31,11 +31,10 @@ func NewCheckbox (value bool) *Checkbox { func (this *Checkbox) SetValue (value bool) { this.value = value if this.value { - // TODO perhaps have IconStatusOkay/Cancel in actions, and have - // a status icon for checked checkboxes. - this.SetTexture(theme.IconStatusOkay.Texture(theme.IconSizeSmall)) + // FIXME: we need checkbox icons + this.SetTextureCenter(tomo.Icon("").Texture(tomo.IconSizeSmall)) } else { - this.SetTexture(nil) + this.SetTextureCenter(nil) } } diff --git a/container.go b/container.go index 4629b6c..0b22c04 100644 --- a/container.go +++ b/container.go @@ -27,7 +27,7 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container { // window, tab pane, etc. func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) - theme.Apply(this, theme.R("objects", "Container", "outer")) + tomo.Apply(this, tomo.R("objects", "Container", "outer")) return this } @@ -35,14 +35,14 @@ func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container // around it. It is meant to be used as a root container for a ScrollContainer. func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) - theme.Apply(this, theme.R("objects", "Container", "sunken")) + tomo.Apply(this, tomo.R("objects", "Container", "sunken")) return this } // NewInnerContainer creates a new container that has no padding around it. func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container { this := newContainer(layout, children...) - theme.Apply(this, theme.R("objects", "Container", "inner")) + tomo.Apply(this, tomo.R("objects", "Container", "inner")) return this } diff --git a/dialog.go b/dialog.go index e26eda8..f5dbd1b 100644 --- a/dialog.go +++ b/dialog.go @@ -45,15 +45,15 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti dialog.Window = window } - var iconId theme.Icon + var iconId tomo.Icon switch kind { - case DialogInformation: iconId = theme.IconStatusInformation - case DialogQuestion: iconId = theme.IconStatusQuestion - case DialogWarning: iconId = theme.IconStatusWarning - case DialogError: iconId = theme.IconStatusError + case DialogInformation: iconId = tomo.IconDialogInformation + case DialogQuestion: iconId = tomo.IconDialogQuestion + case DialogWarning: iconId = tomo.IconDialogWarning + case DialogError: iconId = tomo.IconDialogError } dialog.SetTitle(title) - icon := NewIcon(iconId, theme.IconSizeLarge) + icon := NewIcon(iconId, tomo.IconSizeLarge) messageText := NewLabel(message) messageText.SetAlign(tomo.AlignStart, tomo.AlignMiddle) @@ -75,7 +75,8 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti // NewDialogOk creates a new dialog window with an OK option. func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { okButton := NewButton("OK") - okButton.SetIcon(theme.IconStatusOkay) + // FIXME: need dialog accept/reject action icons + // okButton.SetIcon(tomo.IconStatusOkay) okButton.OnClick(func () { if onOk != nil { onOk() } }) @@ -87,10 +88,12 @@ func NewDialogOk (kind DialogKind, parent tomo.Window, title, message string, on // NewDialogOkCancel creates a new dialog window with OK and Cancel options. func NewDialogOkCancel (kind DialogKind, parent tomo.Window, title, message string, onOk func ()) (*Dialog, error) { cancelButton := NewButton("Cancel") - cancelButton.SetIcon(theme.IconStatusCancel) + // FIXME: need dialog accept/reject action icons + // cancelButton.SetIcon(tomo.IconStatusCancel) okButton := NewButton("OK") - okButton.SetIcon(theme.IconStatusOkay) + // FIXME: need dialog accept/reject action icons + // okButton.SetIcon(tomo.IconStatusOkay) okButton.OnClick(func () { if onOk != nil { onOk() } }) diff --git a/heading.go b/heading.go index 7b88ae9..421296d 100644 --- a/heading.go +++ b/heading.go @@ -15,7 +15,7 @@ func NewHeading (level int, text string) *Heading { if level < 0 { level = 0 } if level > 2 { level = 2 } this := &Heading { TextBox: tomo.NewTextBox() } - theme.Apply(this, theme.R("objects", "Heading", fmt.Sprint(level))) + tomo.Apply(this, tomo.R("objects", "Heading", fmt.Sprint(level))) this.SetText(text) return this } diff --git a/icon.go b/icon.go index d22cd05..bbc057b 100644 --- a/icon.go +++ b/icon.go @@ -11,27 +11,27 @@ type Icon struct { } // NewIcon creates a new icon from an icon ID. -func NewIcon (id theme.Icon, size theme.IconSize) *Icon { +func NewIcon (id tomo.Icon, size tomo.IconSize) *Icon { this := &Icon { Box: tomo.NewBox(), } - theme.Apply(this, theme.R("objects", "Icon", size.String())) + tomo.Apply(this, tomo.R("objects", "Icon", size.String())) this.SetTexture(id.Texture(size)) return this } // NewMimeIcon creates a new icon from a MIME type. -func NewMimeIcon (mime data.Mime, size theme.IconSize) *Icon { +func NewMimeIcon (mime data.Mime, size tomo.IconSize) *Icon { this := &Icon { Box: tomo.NewBox(), } - theme.Apply(this, theme.R("objects", "Icon", size.String())) - this.SetTexture(theme.MimeIcon(mime, size)) + tomo.Apply(this, tomo.R("objects", "Icon", size.String())) + this.SetTexture(tomo.MimeIcon(mime, size)) return this } func (this *Icon) SetTexture (texture canvas.Texture) { - this.Box.SetTexture(texture) + this.Box.SetTextureCenter(texture) if texture == nil { this.SetMinimumSize(image.Pt(0, 0)) } else { diff --git a/label.go b/label.go index 619989d..5428dc6 100644 --- a/label.go +++ b/label.go @@ -10,7 +10,7 @@ type Label struct { // NewLabel creates a new text label. func NewLabel (text string) *Label { this := &Label { TextBox: tomo.NewTextBox() } - theme.Apply(this, theme.R("objects", "Label", "")) + tomo.Apply(this, tomo.R("objects", "Label", "")) this.SetText(text) return this } diff --git a/labelcheckbox.go b/labelcheckbox.go index e2c8981..dc21536 100644 --- a/labelcheckbox.go +++ b/labelcheckbox.go @@ -20,7 +20,7 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox { checkbox: NewCheckbox(value), label: NewLabel(text), } - theme.Apply(box, theme.R("objects", "LabelCheckbox", "")) + tomo.Apply(box, tomo.R("objects", "LabelCheckbox", "")) box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle) box.Add(box.checkbox) box.Add(box.label) diff --git a/numberinput.go b/numberinput.go index c9661c5..c209266 100644 --- a/numberinput.go +++ b/numberinput.go @@ -28,13 +28,13 @@ func NewNumberInput (value float64) *NumberInput { increment: NewButton(""), decrement: NewButton(""), } - theme.Apply(box, theme.R("objects", "NumberInput", "")) + tomo.Apply(box, tomo.R("objects", "NumberInput", "")) box.Add(box.input) box.Add(box.decrement) box.Add(box.increment) box.SetLayout(layouts.NewGrid([]bool { true, false, false }, []bool { true })) - box.increment.SetIcon(theme.IconActionIncrement) - box.decrement.SetIcon(theme.IconActionDecrement) + box.increment.SetIcon(tomo.IconListAdd) // FIXME: need incr/decrment icons + box.decrement.SetIcon(tomo.IconListRemove) box.SetValue(value) diff --git a/scrollbar.go b/scrollbar.go index c0d1379..8d8d6b0 100644 --- a/scrollbar.go +++ b/scrollbar.go @@ -45,8 +45,8 @@ func newScrollbar (orient string) *Scrollbar { this.OnMouseUp(this.handleMouseUp) this.OnMouseMove(this.handleMouseMove) this.OnScroll(this.handleScroll) - theme.Apply(this.handle, theme.R("objects", "SliderHandle", orient)) - theme.Apply(this, theme.R("objects", "Slider", orient)) + tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient)) + tomo.Apply(this, tomo.R("objects", "Slider", orient)) return this } @@ -240,7 +240,7 @@ func (this *Scrollbar) pageSize () int { func (this *Scrollbar) stepSize () int { // FIXME: this should not be hardcoded, need to get base font metrics - // from theme somehow. should be (emspace, lineheight) + // from tomo.somehow. should be (emspace, lineheight) return 16 } diff --git a/scrollcontainer.go b/scrollcontainer.go index d32c093..927446f 100644 --- a/scrollcontainer.go +++ b/scrollcontainer.go @@ -60,7 +60,7 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer { } this.CaptureScroll(true) this.OnScroll(this.handleScroll) - theme.Apply(this, theme.R("objects", "ScrollContainer", sides.String())) + tomo.Apply(this, tomo.R("objects", "ScrollContainer", sides.String())) this.SetLayout(this.layout) return this } @@ -70,8 +70,8 @@ func NewScrollContainer (sides ScrollSide) *ScrollContainer { // one. func (this *ScrollContainer) SetRoot (root tomo.ContentBox) { if this.layout.root != nil { - // delete root and close cookies - this.Delete(this.layout.root) + // remove root and close cookies + this.Remove(this.layout.root) if this.horizontalCookie != nil { this.horizontalCookie.Close() this.horizontalCookie = nil diff --git a/separator.go b/separator.go index 33c613a..b9a3292 100644 --- a/separator.go +++ b/separator.go @@ -12,6 +12,6 @@ func NewSeparator () *Separator { this := &Separator { Box: tomo.NewBox(), } - theme.Apply(this, theme.R("objects", "Separator", "")) + tomo.Apply(this, tomo.R("objects", "Separator", "")) return this } diff --git a/slider.go b/slider.go index ff276c4..4d6fa5d 100644 --- a/slider.go +++ b/slider.go @@ -51,8 +51,8 @@ func newSlider (orient string, value float64) *Slider { this.OnMouseUp(this.handleMouseUp) this.OnMouseMove(this.handleMouseMove) this.OnScroll(this.handleScroll) - theme.Apply(this.handle, theme.R("objects", "SliderHandle", orient)) - theme.Apply(this, theme.R("objects", "Slider", orient)) + tomo.Apply(this.handle, tomo.R("objects", "SliderHandle", orient)) + tomo.Apply(this, tomo.R("objects", "Slider", orient)) return this } diff --git a/textinput.go b/textinput.go index fd76fee..e014bb3 100644 --- a/textinput.go +++ b/textinput.go @@ -19,7 +19,7 @@ type TextInput struct { // NewTextInput creates a new text input containing the specified text. func NewTextInput (text string) *TextInput { this := &TextInput { TextBox: tomo.NewTextBox() } - theme.Apply(this, theme.R("objects", "TextInput", "")) + tomo.Apply(this, tomo.R("objects", "TextInput", "")) this.SetAlign(tomo.AlignStart, tomo.AlignMiddle) this.SetText(text) this.SetFocusable(true) diff --git a/textview.go b/textview.go index 42f4e67..73fe9e8 100644 --- a/textview.go +++ b/textview.go @@ -11,7 +11,7 @@ type TextView struct { // NewTextView creates a new text view. func NewTextView (text string) *TextView { this := &TextView { TextBox: tomo.NewTextBox() } - theme.Apply(this, theme.R("objects", "TextView", "")) + tomo.Apply(this, tomo.R("objects", "TextView", "")) this.SetFocusable(true) this.SetSelectable(true) this.SetText(text)