Calendar no longer embeds tomo.ContainerBox
This commit is contained in:
parent
8de08a9bdc
commit
4e8823ef9f
23
calendar.go
23
calendar.go
@ -6,10 +6,12 @@ import "git.tebibyte.media/tomo/tomo"
|
|||||||
import "git.tebibyte.media/tomo/tomo/event"
|
import "git.tebibyte.media/tomo/tomo/event"
|
||||||
import "git.tebibyte.media/tomo/objects/layouts"
|
import "git.tebibyte.media/tomo/objects/layouts"
|
||||||
|
|
||||||
|
var _ tomo.Object = new(Calendar)
|
||||||
|
|
||||||
// Calendar is an object that can display a date and allow the user to change
|
// Calendar is an object that can display a date and allow the user to change
|
||||||
// it. It can display one month at a time.
|
// it. It can display one month at a time.
|
||||||
type Calendar struct {
|
type Calendar struct {
|
||||||
tomo.ContainerBox
|
box tomo.ContainerBox
|
||||||
|
|
||||||
grid tomo.ContainerBox
|
grid tomo.ContainerBox
|
||||||
time time.Time
|
time time.Time
|
||||||
@ -23,11 +25,11 @@ type Calendar struct {
|
|||||||
// NewCalendar creates a new calendar with the specified date.
|
// NewCalendar creates a new calendar with the specified date.
|
||||||
func NewCalendar (tm time.Time) *Calendar {
|
func NewCalendar (tm time.Time) *Calendar {
|
||||||
calendar := &Calendar {
|
calendar := &Calendar {
|
||||||
ContainerBox: tomo.NewContainerBox(),
|
box: tomo.NewContainerBox(),
|
||||||
time: tm,
|
time: tm,
|
||||||
}
|
}
|
||||||
calendar.SetRole(tomo.R("objects", "Calendar"))
|
calendar.box.SetRole(tomo.R("objects", "Calendar"))
|
||||||
calendar.SetAttr(tomo.ALayout(layouts.ContractVertical))
|
calendar.box.SetAttr(tomo.ALayout(layouts.ContractVertical))
|
||||||
|
|
||||||
prevButton := NewButton("")
|
prevButton := NewButton("")
|
||||||
prevButton.SetIcon(tomo.IconGoPrevious)
|
prevButton.SetIcon(tomo.IconGoPrevious)
|
||||||
@ -48,17 +50,22 @@ func NewCalendar (tm time.Time) *Calendar {
|
|||||||
calendar.grid.SetRole(tomo.R("objects", "CalendarGrid"))
|
calendar.grid.SetRole(tomo.R("objects", "CalendarGrid"))
|
||||||
calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid (
|
calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid (
|
||||||
true, true, true, true, true, true, true)()))
|
true, true, true, true, true, true, true)()))
|
||||||
calendar.Add(NewInnerContainer (
|
calendar.box.Add(NewInnerContainer (
|
||||||
layouts.Row { false, true, false },
|
layouts.Row { false, true, false },
|
||||||
prevButton, calendar.monthLabel, nextButton))
|
prevButton, calendar.monthLabel, nextButton))
|
||||||
calendar.Add(calendar.grid)
|
calendar.box.Add(calendar.grid)
|
||||||
|
|
||||||
calendar.OnScroll(calendar.handleScroll)
|
calendar.box.OnScroll(calendar.handleScroll)
|
||||||
|
|
||||||
calendar.refresh()
|
calendar.refresh()
|
||||||
return calendar
|
return calendar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBox returns the underlying box.
|
||||||
|
func (this *Calendar) GetBox () tomo.Box {
|
||||||
|
return this.box
|
||||||
|
}
|
||||||
|
|
||||||
// Value returns the time this calendar is displaying.
|
// Value returns the time this calendar is displaying.
|
||||||
func (this *Calendar) Value () time.Time {
|
func (this *Calendar) Value () time.Time {
|
||||||
return this.time
|
return this.time
|
||||||
|
Loading…
Reference in New Issue
Block a user