Created
May 26, 2017 00:22
-
-
Save haiitch/7eddea79a8dbe673e5b4d0bb048726b0 to your computer and use it in GitHub Desktop.
Basic Gossamy abstraction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gossamy | |
type Controller interface { | |
// here go user events | |
} | |
type Arranger interface { | |
func Arrange() | |
// here go | |
} | |
type Dragger interface { | |
func CanDrag() bool | |
func BeginDrag() | |
func EndDrag() | |
func DropInto(target Control) bool | |
} | |
type Dropper { | |
CanDrop *func() | |
OnDrop *func() | |
} | |
type DragAndDropper interface { | |
Dragger | |
Dropper | |
} | |
type Themable interface { | |
func LoadTheme(name string, t {}interface) Theme | |
func UnloadTheme(name string) | |
func ApplyTheme(name string) | |
} | |
// A Theme is a pre-designed collection of styles. | |
// A Theme can be loaded from an external theme definition | |
// much in the same way a browser loads a CSS file. | |
// A style can be altered for any given control. | |
// There is no concept of classes. | |
// A Style is a list of key/value pairs. | |
// Style values can be strings, ints, floats, or Style | |
// For example: | |
// buttonstyle := &Style{ {"pen-width", 2},{"opacity", 0.5}, | |
// {"fill", &Gradient{ 0x000000, 0xffffff } } } | |
// | |
type Style map[string]interface{} | |
type Theme struct { | |
name string // short name | |
description string // longer display name | |
definition map[string]Style | |
} | |
type Control struct { | |
id int | |
parent Container | |
x int // top | |
y int // left | |
width int | |
height int | |
visible bool // true = control is displayed on screen | |
focused bool // true = control has focus | |
readonly bool // true = user can't change state | |
enabled bool // true = esponds to events | |
// to be added later via dependency injection | |
// I don't like to have all the drag and drop stuff | |
// stuck here | |
// dragsource bool // true = can be dragged | |
// droptarget bool // true = can accept drops | |
maxwidth int | |
maxheight int | |
minwidth int | |
minheight int | |
padding int | |
margin int | |
border int | |
hint *Tooltip | |
contextmenu *Menu | |
} | |
type Option struct { | |
text string | |
value {}interface // useful to hold associated values | |
checkbox bool | |
checked bool | |
visible bool | |
enabled bool | |
iconutf8 int // icon codepage in system icon set | |
iconbits Image.image // icon as PNG image data | |
submenu Menu | |
} | |
type Menu { | |
[]Option | |
} | |
type MainMenu { | |
Control | |
[]Menu | |
} | |
type Label { | |
Control | |
text string | |
maxwidth int | |
// background and font style | |
} | |
type Scrollbar { | |
Control | |
orientation int // 0 horiztontal, 1 vertical | |
} | |
type Edit { | |
Control | |
text string | |
maxlength int | |
length int | |
displayformat string | |
editmask string | |
} | |
type TextBox { | |
Control | |
cursorline int | |
cursorcolumn int | |
text string | |
maxlines int | |
maxcolumns int | |
vscrollbar Scrollbar | |
hscrollbar Scrollbar | |
} | |
type Container struct { | |
Control | |
children []Control | |
} | |
type Form struct { | |
Container | |
title string | |
is_minimised bool | |
is_maximised bool | |
has_decoration bool | |
has_minimisebutton bool | |
has_maximisebutton bool | |
has_restorebutton bool | |
has_closebutton bool | |
is_resizable bool | |
is_snappy bool | |
is_modal bool | |
modalvalue int | |
} | |
type Window struct { | |
Form | |
mintraybar bool // true = minimised to traybar | |
minmenu *Menu // context menu on traybar or minimised icon | |
sysmenu *Menu // window title menu in platforms that support it | |
// should contain a proxy to the lower level glfw | |
// window handling system, or a proxy to a remote | |
// server providing similar functionality | |
// syswindow glfw.Window | |
// syswindow gossamy.Server | |
screen *Screen // screen this | |
} | |
type Screen struct { | |
title string | |
width int | |
height int | |
layers []Layer | |
windows []Window | |
// tiling data go here | |
} | |
type Display struct { | |
// system device caps and low level | |
// glfw/opengl system data goes here. | |
monitors []Screen | |
} | |
var ( | |
gxdark Theme // gossamy default dark theme | |
gxlight Theme // gossamy default light theme | |
winold Theme // Windows 95/2000/2003 theme | |
winten Theme // Windows 10 | |
feline Theme // Mac OS X Leopard theme | |
capitano Theme // Mac OS X El Capitan theme | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment