blob: 1c41a194a7ea18f025c62ae5d77a39bdd30b1728 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package ui
import rl "github.com/gen2brain/raylib-go/raylib"
// An element that can use another element as a background
type StackedElement interface {
// Returns an applied style
GetStyle() *Style
// Returns a background element. Should return nil if it is not uupposed to be drawn
GetBackgroundElement() UIElement
}
func drawStackedElementBackground(base StackedElement, targetPosition *rl.Rectangle) {
var bgElement = base.GetBackgroundElement()
if bgElement == nil {
_drawSimpleBackground(base.GetStyle(), targetPosition)
} else {
_drawElement(bgElement, targetPosition)
}
}
func _drawSimpleBackground(style *Style, trg *rl.Rectangle) {
rl.DrawRectangleRounded(*trg,
*style.Roundness,
0, // Assume the segments param is always 0 - it doesn't really matter without a border
*style.BacgroundColor)
}
// Should not be used outside of the scope of this file
func _drawElement(elem UIElement, trg *rl.Rectangle) {
elem.Draw(trg)
}
|