Skip to content

Instantly share code, notes, and snippets.

@arriqaaq
Created January 27, 2023 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arriqaaq/ea5cb92a25ff47cb0056857fc60c6386 to your computer and use it in GitHub Desktop.
Save arriqaaq/ea5cb92a25ff47cb0056857fc60c6386 to your computer and use it in GitHub Desktop.
type GUI interface {
Draw()
HandleEvent(event interface{})
}
type Button struct {
x, y, width, height int
label string
}
func (b *Button) Draw() {
// draw button on screen
}
func (b *Button) HandleEvent(event interface{}) {
// handle button event
}
type Window struct {
x, y, width, height int
title string
elements []GUI
}
func (w *Window) Draw() {
// draw window on screen
for _, element := range w.elements {
element.Draw()
}
}
func (w *Window) HandleEvent(event interface{}) {
// handle window event
for _, element := range w.elements {
element.HandleEvent(event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment