Created
January 27, 2023 09:40
-
-
Save arriqaaq/ea5cb92a25ff47cb0056857fc60c6386 to your computer and use it in GitHub Desktop.
This file contains 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
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