Add icons example
This commit is contained in:
parent
2b9f17b612
commit
d90fb327db
190
examples/icons/main.go
Normal file
190
examples/icons/main.go
Normal file
@ -0,0 +1,190 @@
|
||||
// Example icons demonstrates the use of icons, and buttons with icons.
|
||||
package main
|
||||
|
||||
import "image"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/nasin"
|
||||
import "git.tebibyte.media/tomo/objects"
|
||||
import "git.tebibyte.media/tomo/tomo/theme"
|
||||
import "git.tebibyte.media/tomo/objects/layouts"
|
||||
|
||||
type Application struct {
|
||||
size theme.IconSize
|
||||
grid tomo.ContainerBox
|
||||
}
|
||||
|
||||
func (this *Application) Describe () nasin.ApplicationDescription {
|
||||
return nasin.ApplicationDescription {
|
||||
Name: "Tomo Icon Example",
|
||||
ID: "xyz.holanet.TomoIconExample",
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Application) Init () error {
|
||||
window, err := nasin.NewApplicationWindow(this, image.Rect(0, 0, 128, 128))
|
||||
if err != nil { return err }
|
||||
|
||||
this.grid = objects.NewInnerContainer (
|
||||
layouts.NewGrid([]bool {
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
}, []bool { }),
|
||||
)
|
||||
this.resizeIcons(theme.IconSizeSmall)
|
||||
|
||||
iconButtons := objects.NewInnerContainer(layouts.NewGrid([]bool { true, true, true}, []bool { false }))
|
||||
|
||||
button := objects.NewButton("small")
|
||||
button.SetIcon(theme.IconActionZoomOut)
|
||||
button.OnClick(func () { this.resizeIcons(theme.IconSizeSmall) })
|
||||
iconButtons.Add(button)
|
||||
|
||||
button = objects.NewButton("medium")
|
||||
button.SetIcon(theme.IconActionZoomReset)
|
||||
button.OnClick(func () { this.resizeIcons(theme.IconSizeMedium) })
|
||||
iconButtons.Add(button)
|
||||
|
||||
button = objects.NewButton("large")
|
||||
button.SetIcon(theme.IconActionZoomIn)
|
||||
button.OnClick(func () { this.resizeIcons(theme.IconSizeLarge) })
|
||||
iconButtons.Add(button)
|
||||
|
||||
container := objects.NewOuterContainer (
|
||||
layouts.NewGrid([]bool { true }, []bool { false, true, false }),
|
||||
objects.NewLabel("A smorgasbord of icons:"),
|
||||
this.grid,
|
||||
iconButtons)
|
||||
window.SetRoot(container)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Application) resizeIcons (size theme.IconSize) {
|
||||
this.size = size
|
||||
this.grid.Clear()
|
||||
icons := []theme.Icon {
|
||||
theme.IconUnknown,
|
||||
theme.IconFile,
|
||||
theme.IconDirectory,
|
||||
theme.IconStorage,
|
||||
theme.IconApplication,
|
||||
theme.IconNetwork,
|
||||
theme.IconDevice,
|
||||
theme.IconPeripheral,
|
||||
theme.IconPort,
|
||||
theme.IconActionOpen,
|
||||
theme.IconActionOpenIn,
|
||||
theme.IconActionSave,
|
||||
theme.IconActionSaveAs,
|
||||
theme.IconActionPrint,
|
||||
theme.IconActionNew,
|
||||
theme.IconActionNewDirectory,
|
||||
theme.IconActionDelete,
|
||||
theme.IconActionRename,
|
||||
theme.IconActionGetInformation,
|
||||
theme.IconActionChangePermissions,
|
||||
theme.IconActionRevert,
|
||||
theme.IconActionAdd,
|
||||
theme.IconActionRemove,
|
||||
theme.IconActionAddBookmark,
|
||||
theme.IconActionRemoveBookmark,
|
||||
theme.IconActionAddFavorite,
|
||||
theme.IconActionRemoveFavorite,
|
||||
theme.IconActionPlay,
|
||||
theme.IconActionPause,
|
||||
theme.IconActionStop,
|
||||
theme.IconActionFastForward,
|
||||
theme.IconActionRewind,
|
||||
theme.IconActionToBeginning,
|
||||
theme.IconActionToEnd,
|
||||
theme.IconActionRecord,
|
||||
theme.IconActionVolumeUp,
|
||||
theme.IconActionVolumeDown,
|
||||
theme.IconActionMute,
|
||||
theme.IconActionUndo,
|
||||
theme.IconActionRedo,
|
||||
theme.IconActionCut,
|
||||
theme.IconActionCopy,
|
||||
theme.IconActionPaste,
|
||||
theme.IconActionFind,
|
||||
theme.IconActionReplace,
|
||||
theme.IconActionSelectAll,
|
||||
theme.IconActionSelectNone,
|
||||
theme.IconActionIncrement,
|
||||
theme.IconActionDecrement,
|
||||
theme.IconActionClose,
|
||||
theme.IconActionQuit,
|
||||
theme.IconActionIconify,
|
||||
theme.IconActionShade,
|
||||
theme.IconActionMaximize,
|
||||
theme.IconActionFullScreen,
|
||||
theme.IconActionRestore,
|
||||
theme.IconActionExpand,
|
||||
theme.IconActionContract,
|
||||
theme.IconActionBack,
|
||||
theme.IconActionForward,
|
||||
theme.IconActionUp,
|
||||
theme.IconActionDown,
|
||||
theme.IconActionReload,
|
||||
theme.IconActionZoomIn,
|
||||
theme.IconActionZoomOut,
|
||||
theme.IconActionZoomReset,
|
||||
theme.IconActionMove,
|
||||
theme.IconActionResize,
|
||||
theme.IconActionGoTo,
|
||||
theme.IconActionTransform,
|
||||
theme.IconActionTranslate,
|
||||
theme.IconActionRotate,
|
||||
theme.IconActionScale,
|
||||
theme.IconActionWarp,
|
||||
theme.IconActionCornerPin,
|
||||
theme.IconActionSelectRectangle,
|
||||
theme.IconActionSelectEllipse,
|
||||
theme.IconActionSelectLasso,
|
||||
theme.IconActionSelectGeometric,
|
||||
theme.IconActionSelectAuto,
|
||||
theme.IconActionCrop,
|
||||
theme.IconActionFill,
|
||||
theme.IconActionGradient,
|
||||
theme.IconActionPencil,
|
||||
theme.IconActionBrush,
|
||||
theme.IconActionEraser,
|
||||
theme.IconActionText,
|
||||
theme.IconActionEyedropper,
|
||||
theme.IconStatusInformation,
|
||||
theme.IconStatusQuestion,
|
||||
theme.IconStatusWarning,
|
||||
theme.IconStatusError,
|
||||
theme.IconStatusCancel,
|
||||
theme.IconStatusOkay,
|
||||
theme.IconStatusCellSignal0,
|
||||
theme.IconStatusCellSignal1,
|
||||
theme.IconStatusCellSignal2,
|
||||
theme.IconStatusCellSignal3,
|
||||
theme.IconStatusWirelessSignal0,
|
||||
theme.IconStatusWirelessSignal1,
|
||||
theme.IconStatusWirelessSignal2,
|
||||
theme.IconStatusWirelessSignal3,
|
||||
theme.IconStatusBattery0,
|
||||
theme.IconStatusBattery1,
|
||||
theme.IconStatusBattery2,
|
||||
theme.IconStatusBattery3,
|
||||
theme.IconStatusBrightness0,
|
||||
theme.IconStatusBrightness1,
|
||||
theme.IconStatusBrightness2,
|
||||
theme.IconStatusBrightness3,
|
||||
theme.IconStatusVolume0,
|
||||
theme.IconStatusVolume1,
|
||||
theme.IconStatusVolume2,
|
||||
theme.IconStatusVolume3,
|
||||
}
|
||||
|
||||
for _, icon := range icons {
|
||||
this.grid.Add(objects.NewIcon(icon, size))
|
||||
}
|
||||
}
|
||||
|
||||
func main () {
|
||||
nasin.RunApplication(&Application { })
|
||||
}
|
Loading…
Reference in New Issue
Block a user