// 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/input" import "git.tebibyte.media/tomo/objects/layouts" const scrollIcons = true type Application struct { window tomo.MainWindow size tomo.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, 256)) if err != nil { return err } this.window = window this.grid = objects.NewSunkenContainer(layouts.FlowVertical) this.resizeIcons(tomo.IconSizeSmall) iconButtons := objects.NewInnerContainer(layouts.NewGrid([]bool { true, true, true}, []bool { false })) button := objects.NewButton("small") button.SetIcon(tomo.IconZoomOut) button.OnClick(func () { this.resizeIcons(tomo.IconSizeSmall) }) iconButtons.Add(button) button = objects.NewButton("medium") button.SetIcon(tomo.IconZoomOriginal) button.OnClick(func () { this.resizeIcons(tomo.IconSizeMedium) }) iconButtons.Add(button) button = objects.NewButton("large") button.SetIcon(tomo.IconZoomIn) button.OnClick(func () { this.resizeIcons(tomo.IconSizeLarge) }) iconButtons.Add(button) container := objects.NewOuterContainer ( layouts.NewGrid([]bool { true }, []bool { false, true, false }), objects.NewLabel("A smorgasbord of icons:")) if scrollIcons { iconScroller := objects.NewScrollContainer(objects.ScrollVertical) this.grid.SetOverflow(false, true) iconScroller.SetRoot(this.grid) container.Add(iconScroller) } else { container.Add(this.grid) } container.Add(iconButtons) window.SetRoot(container) window.OnClose(tomo.Stop) window.SetVisible(true) return nil } func (this *Application) resizeIcons (size tomo.IconSize) { this.size = size this.grid.Clear() icons := []tomo.Icon { tomo.IconUnknown, tomo.IconAddressBookNew, tomo.IconApplicationExit, tomo.IconAppointmentNew, tomo.IconCallStart, tomo.IconCallStop, tomo.IconContactNew, tomo.IconDialogOkay, tomo.IconDialogCancel, tomo.IconEditClear, tomo.IconEditCopy, tomo.IconEditCut, tomo.IconEditDelete, tomo.IconEditFind, tomo.IconEditFindReplace, tomo.IconEditPaste, tomo.IconEditRedo, tomo.IconEditSelectAll, tomo.IconEditUndo, tomo.IconFileNew, tomo.IconDirectoryNew, tomo.IconFileOpen, tomo.IconFileOpenRecent, tomo.IconFilePageSetup, tomo.IconFilePrint, tomo.IconFilePrintPreview, tomo.IconFilePermissions, tomo.IconFileProperties, tomo.IconFileRename, tomo.IconFileRevert, tomo.IconFileSave, tomo.IconFileSaveAs, tomo.IconFileSend, tomo.IconFormatIndentLess, tomo.IconFormatIndentMore, tomo.IconFormatAlignCenter, tomo.IconFormatAlignEven, tomo.IconFormatAlignLeft, tomo.IconFormatAlignRight, tomo.IconFormatTextDirectionLtr, tomo.IconFormatTextDirectionRtl, tomo.IconFormatTextBold, tomo.IconFormatTextItalic, tomo.IconFormatTextUnderline, tomo.IconFormatTextStrikethrough, tomo.IconGoBottom, tomo.IconGoDown, tomo.IconGoFirst, tomo.IconGoHome, tomo.IconGoJump, tomo.IconGoLast, tomo.IconGoNext, tomo.IconGoPrevious, tomo.IconGoTop, tomo.IconGoUp, tomo.IconHelpAbout, tomo.IconHelpContents, tomo.IconHelpFaq, tomo.IconInsertImage, tomo.IconInsertLink, tomo.IconInsertObject, tomo.IconInsertText, tomo.IconListAdd, tomo.IconListRemove, tomo.IconMailForward, tomo.IconMailMarkImportant, tomo.IconMailMarkJunk, tomo.IconMailMarkNotJunk, tomo.IconMailMarkRead, tomo.IconMailMarkUnread, tomo.IconMailMessageNew, tomo.IconMailReplyAll, tomo.IconMailReplySender, tomo.IconMailSend, tomo.IconMailReceive, tomo.IconMediaEject, tomo.IconMediaPlaybackPause, tomo.IconMediaPlaybackStart, tomo.IconMediaPlaybackStop, tomo.IconMediaRecord, tomo.IconMediaSeekBackward, tomo.IconMediaSeekForward, tomo.IconMediaSkipBackward, tomo.IconMediaSkipForward, tomo.IconObjectFlipHorizontal, tomo.IconObjectFlipVertical, tomo.IconObjectRotateLeft, tomo.IconObjectRotateRight, tomo.IconProcessStop, tomo.IconSystemLockScreen, tomo.IconSystemLogOut, tomo.IconSystemRun, tomo.IconSystemSearch, tomo.IconSystemReboot, tomo.IconSystemShutdown, tomo.IconToolsCheckSpelling, tomo.IconValueIncrement, tomo.IconValueDecrement, tomo.IconValueReset, tomo.IconViewFullscreen, tomo.IconViewRefresh, tomo.IconViewRestore, tomo.IconViewSortAscending, tomo.IconViewSortDescending, tomo.IconWindowClose, tomo.IconWindowNew, tomo.IconZoomFitBest, tomo.IconZoomIn, tomo.IconZoomOriginal, tomo.IconZoomOut, tomo.IconApplication, tomo.IconApplicationWebBrowser, tomo.IconApplicationMesssanger, tomo.IconApplicationPhone, tomo.IconApplicationMail, tomo.IconApplicationTerminalEmulator, tomo.IconApplicationFileBrowser, tomo.IconApplicationTextEditor, tomo.IconApplicationDocumentViewer, tomo.IconApplicationWordProcessor, tomo.IconApplicationSpreadsheet, tomo.IconApplicationSlideshow, tomo.IconApplicationCalculator, tomo.IconApplicationPreferences, tomo.IconApplicationProcessManager, tomo.IconApplicationSystemInformation, tomo.IconApplicationManual, tomo.IconApplicationCamera, tomo.IconApplicationImageViewer, tomo.IconApplicationMediaPlayer, tomo.IconApplicationImageEditor, tomo.IconApplicationAudioEditor, tomo.IconApplicationVideoEditor, tomo.IconApplicationClock, tomo.IconApplicationCalendar, tomo.IconApplicationChecklist, tomo.IconApplications, tomo.IconApplicationsAccessories, tomo.IconApplicationsDevelopment, tomo.IconApplicationsEngineering, tomo.IconApplicationsGames, tomo.IconApplicationsGraphics, tomo.IconApplicationsInternet, tomo.IconApplicationsMultimedia, tomo.IconApplicationsOffice, tomo.IconApplicationsScience, tomo.IconApplicationsSystem, tomo.IconApplicationsUtilities, tomo.IconPreferences, tomo.IconPreferencesDesktop, tomo.IconPreferencesPeripherals, tomo.IconPreferencesPersonal, tomo.IconPreferencesSystem, tomo.IconPreferencesNetwork, tomo.IconDevice, tomo.IconDeviceCamera, tomo.IconDeviceWebCamera, tomo.IconDeviceComputer, tomo.IconDevicePda, tomo.IconDevicePhone, tomo.IconDevicePrinter, tomo.IconDeviceScanner, tomo.IconDeviceMultimediaPlayer, tomo.IconDeviceVideoDisplay, tomo.IconDeviceAudioInput, tomo.IconDeviceAudioOutput, tomo.IconHardware, tomo.IconHardwareCPU, tomo.IconHardwareGPU, tomo.IconHardwareRAM, tomo.IconHardwareSoundCard, tomo.IconHardwareNetworkAdapter, tomo.IconPowerBattery, tomo.IconStorageHardDisk, tomo.IconStorageFloppyDisk, tomo.IconStorageSolidState, tomo.IconStorageOptical, tomo.IconStorageFlashStick, tomo.IconStorageFlashCard, tomo.IconStorageMagneticTape, tomo.IconInputGaming, tomo.IconInputKeyboard, tomo.IconInputMouse, tomo.IconInputTablet, tomo.IconNetworkWired, tomo.IconNetworkWireless, tomo.IconNetworkCellular, tomo.IconNetworkLocal, tomo.IconNetworkInternet, tomo.IconNetworkVPN, tomo.IconNetworkServer, tomo.IconNetworkWorkgroup, tomo.IconEmblemDefault, tomo.IconEmblemEncrypted, tomo.IconEmblemFavorite, tomo.IconEmblemImportant, tomo.IconEmblemReadOnly, tomo.IconEmblemShared, tomo.IconEmblemSymbolicLink, tomo.IconEmblemSynchronized, tomo.IconEmblemSystem, tomo.IconEmblemUnreadable, tomo.IconPlaceDirectory, tomo.IconPlaceRemote, tomo.IconPlaceHome, tomo.IconPlaceDownloads, tomo.IconPlaceDesktop, tomo.IconPlacePhotos, tomo.IconPlaceBooks, tomo.IconPlaceBookmarks, tomo.IconPlaceTrash, tomo.IconPlaceDocuments, tomo.IconPlaceRepositories, tomo.IconPlaceMusic, tomo.IconPlaceArchives, tomo.IconPlaceFonts, tomo.IconPlaceBinaries, tomo.IconPlaceVideos, tomo.IconPlace3DObjects, tomo.IconPlaceHistory, tomo.IconPlacePreferences, tomo.IconCheckboxChecked, tomo.IconCheckboxUnchecked, tomo.IconAppointmentMissed, tomo.IconAppointmentSoon, tomo.IconDialogError, tomo.IconDialogInformation, tomo.IconDialogPassword, tomo.IconDialogQuestion, tomo.IconDialogWarning, tomo.IconDirectoryDragAccept, tomo.IconDirectoryFull, tomo.IconDirectoryOpen, tomo.IconDirectoryVisiting, tomo.IconTrashFull, tomo.IconResourceLoading, tomo.IconResourceMissing, tomo.IconMailAttachment, tomo.IconMailUnread, tomo.IconMailReplied, tomo.IconMailSigned, tomo.IconMailSignedVerified, tomo.IconCellularSignal0, tomo.IconCellularSignal1, tomo.IconCellularSignal2, tomo.IconCellularSignal3, tomo.IconWirelessSignal0, tomo.IconWirelessSignal1, tomo.IconWirelessSignal2, tomo.IconWirelessSignal3, tomo.IconNetworkError, tomo.IconNetworkIdle, tomo.IconNetworkOffline, tomo.IconNetworkReceive, tomo.IconNetworkTransmit, tomo.IconNetworkTransmitReceive, tomo.IconPrintError, tomo.IconPrintPrinting, tomo.IconSecurityHigh, tomo.IconSecurityMedium, tomo.IconSecurityLow, tomo.IconSoftwareUpdateAvailable, tomo.IconSoftwareUpdateUrgent, tomo.IconSoftwareInstalling, tomo.IconSyncError, tomo.IconSyncSynchronizing, tomo.IconTaskDue, tomo.IconTaskPastDue, tomo.IconUserAvailable, tomo.IconUserAway, tomo.IconUserIdle, tomo.IconUserOffline, tomo.IconBattery0, tomo.IconBattery1, tomo.IconBattery2, tomo.IconBattery3, tomo.IconBrightness0, tomo.IconBrightness1, tomo.IconBrightness2, tomo.IconBrightness3, tomo.IconVolume0, tomo.IconVolume1, tomo.IconVolume2, tomo.IconVolume3, tomo.IconPlaylistRepeat, tomo.IconPlaylistShuffle, tomo.IconWeatherClear, tomo.IconWeatherClearNight, tomo.IconWeatherFewClouds, tomo.IconWeatherFewCloudsNight, tomo.IconWeatherFog, tomo.IconWeatherOvercast, tomo.IconWeatherSevereAlert, tomo.IconWeatherShowers, tomo.IconWeatherShowersScattered, tomo.IconWeatherSnow, tomo.IconWeatherStorm, } for _, icon := range icons { iconObject := objects.NewIcon(icon, size) this.grid.Add(iconObject) icon := icon iconObject.OnMouseDown(func (button input.Button) { if button != input.ButtonLeft { return } this.iconPopup(icon) }) } } func (this *Application) iconPopup (icon tomo.Icon) error { popup, err := this.window.NewModal(image.Rectangle { }) if err != nil { return err } if icon == "" { icon = "" } sizesRow := objects.NewInnerContainer ( layouts.ContractHorizontal, objects.NewIcon(icon, tomo.IconSizeSmall), objects.NewIcon(icon, tomo.IconSizeMedium), objects.NewIcon(icon, tomo.IconSizeLarge)) okButton := objects.NewButton("OK") okButton.OnClick(popup.Close) okButton.SetIcon(tomo.IconDialogOkay) controlRow := objects.NewInnerContainer ( layouts.ContractHorizontal, okButton) controlRow.SetAlign(tomo.AlignEnd, tomo.AlignMiddle) popup.SetRoot(objects.NewOuterContainer ( layouts.NewGrid([]bool { true }, []bool { true, false }), objects.NewLabel("Icon ID: " + string(icon)), sizesRow, controlRow, )) popup.SetTitle(string(icon) + ": Properties") popup.SetVisible(true) return nil } func main () { nasin.RunApplication(&Application { }) }