2023-03-30 21:19:04 -06:00
|
|
|
package tomo
|
2023-02-01 23:47:01 -07:00
|
|
|
|
|
|
|
import "image"
|
2023-03-25 11:32:48 -06:00
|
|
|
import "git.tebibyte.media/sashakoshka/tomo/data"
|
2023-02-01 23:47:01 -07:00
|
|
|
|
2023-04-10 00:36:28 -06:00
|
|
|
// TODO: add support for the icon window because imagine if we allowed
|
|
|
|
// applications to display live updating information readouts on their icons.
|
|
|
|
// that would be baller
|
|
|
|
|
2023-02-01 23:47:01 -07:00
|
|
|
// Window represents a top-level container generated by the currently running
|
|
|
|
// backend. It can contain a single element. It is hidden by default, and must
|
2023-03-14 15:08:39 -06:00
|
|
|
// be explicitly shown with the Show() method.
|
2023-02-01 23:47:01 -07:00
|
|
|
type Window interface {
|
|
|
|
// Adopt sets the root element of the window. There can only be one of
|
|
|
|
// these at one time.
|
2023-03-14 15:08:39 -06:00
|
|
|
Adopt (Element)
|
2023-02-01 23:47:01 -07:00
|
|
|
|
|
|
|
// SetTitle sets the title that appears on the window's title bar. This
|
|
|
|
// method might have no effect with some backends.
|
2023-03-14 15:08:39 -06:00
|
|
|
SetTitle (string)
|
2023-02-01 23:47:01 -07:00
|
|
|
|
2023-04-09 23:56:43 -06:00
|
|
|
// SetApplicationName sets the name of the application that this window
|
|
|
|
// belongs to. This method might have no effect with some backends.
|
|
|
|
SetApplicationName (string)
|
|
|
|
|
2023-02-01 23:47:01 -07:00
|
|
|
// SetIcon taks in a list different sizes of the same icon and selects
|
|
|
|
// the best one to display on the window title bar, dock, or whatever is
|
|
|
|
// applicable for the given backend. This method might have no effect
|
|
|
|
// for some backends.
|
|
|
|
SetIcon (sizes []image.Image)
|
|
|
|
|
2023-04-09 23:56:43 -06:00
|
|
|
// NewModal creates a new modal dialog window. The resulting window will
|
|
|
|
// inherit this window's application name and icon, but these can be
|
2023-04-10 00:36:28 -06:00
|
|
|
// manually overridden. The modal will be placed relative to the parent
|
|
|
|
// window, but this position may be overridden by the backend or
|
|
|
|
// operating system.
|
|
|
|
NewModal (bounds image.Rectangle) (Window, error)
|
2023-04-10 14:22:47 -06:00
|
|
|
|
|
|
|
// NewMenu creates a new temporary window for things like dropdown or
|
|
|
|
// context menus. It automatically closes when the user presses escape
|
|
|
|
// or clicks outside of it. Like NewModal, the pulldown window will
|
|
|
|
// inherit this window's application name and icon, and will be
|
|
|
|
// positioned relative to it.
|
|
|
|
NewMenu (bounds image.Rectangle) (MenuWindow, error)
|
2023-03-25 11:32:48 -06:00
|
|
|
|
|
|
|
// Copy puts data into the clipboard.
|
|
|
|
Copy (data.Data)
|
|
|
|
|
|
|
|
// Paste requests the data currently in the clipboard. When the data is
|
2023-03-27 18:44:39 -06:00
|
|
|
// available, the callback is called with the clipboard data. If there
|
|
|
|
// was no data matching the requested mime type found, nil is passed to
|
|
|
|
// the callback instead.
|
2023-03-28 22:50:23 -06:00
|
|
|
Paste (callback func (data.Data, error), accept ...data.Mime)
|
2023-03-23 22:34:25 -06:00
|
|
|
|
2023-02-01 23:47:01 -07:00
|
|
|
// Show shows the window. The window starts off hidden, so this must be
|
|
|
|
// called after initial setup to make sure it is visible.
|
|
|
|
Show ()
|
|
|
|
|
|
|
|
// Hide hides the window.
|
|
|
|
Hide ()
|
|
|
|
|
|
|
|
// Close closes the window.
|
|
|
|
Close ()
|
|
|
|
|
|
|
|
// OnClose specifies a function to be called when the window is closed.
|
|
|
|
OnClose (func ())
|
|
|
|
}
|
2023-03-23 22:34:25 -06:00
|
|
|
|
|
|
|
// MainWindow is a window capable of owning multiple sub-windows.
|
|
|
|
type MainWindow interface {
|
|
|
|
Window
|
|
|
|
|
|
|
|
// NewPanel creates a panel window that is semantically tied to this
|
2023-04-10 00:36:28 -06:00
|
|
|
// window, positioned relative to it. This is intended to be used for
|
|
|
|
// utility windows, tool bars, torn-off menus, etc. The resulting window
|
|
|
|
// will inherit this window's application name and icon, but these can
|
|
|
|
// be manually overridden.
|
|
|
|
NewPanel (bounds image.Rectangle) (Window, error)
|
2023-03-23 22:34:25 -06:00
|
|
|
}
|
2023-04-10 14:22:47 -06:00
|
|
|
|
|
|
|
// MenuWindow is a temporary window that automatically closes when the user
|
|
|
|
// presses escape or clicks outside of it.
|
|
|
|
type MenuWindow interface {
|
|
|
|
Window
|
|
|
|
|
|
|
|
// Pin converts this window into a panel, pinning it to the screen.
|
|
|
|
Pin ()
|
|
|
|
}
|