|
25 | 25 |
|
26 | 26 | ' Set default colors |
27 | 27 | m.top.background = colorConstants.background_primary |
28 | | - m.top.iconBackground = colorConstants.text_secondary |
| 28 | + m.top.iconBackground = colorConstants.text_primary |
29 | 29 | m.top.focusBackground = colorConstants.background_secondary |
30 | 30 | m.top.iconFocusBackground = colorConstants.text_primary |
31 | 31 | end sub |
|
89 | 89 | end sub |
90 | 90 |
|
91 | 91 | sub setIconSize() |
92 | | - height = m.top.height |
93 | | - width = m.top.width |
94 | | - if height > 0 and width > 0 |
95 | | - ' TODO: Use smallest number between them |
96 | | - m.buttonIcon.height = m.top.height |
| 92 | + ' determine size of icon |
| 93 | + if m.buttonIcon.bitmapWidth > 0 and m.buttonIcon.bitmapHeight > 0 |
| 94 | + iconWidth = m.buttonIcon.bitmapWidth |
| 95 | + iconHeight = m.buttonIcon.bitmapHeight |
97 | 96 |
|
| 97 | + ' set buttonBackground width and height to size of poster + padding |
98 | 98 | if m.top.padding > 0 |
99 | | - m.buttonIcon.height = m.buttonIcon.height - m.top.padding |
| 99 | + m.buttonBackground.width = iconWidth + (m.top.padding * 2) |
| 100 | + m.buttonBackground.height = iconHeight + (m.top.padding * 2) |
| 101 | + else |
| 102 | + m.buttonBackground.width = iconWidth |
| 103 | + m.buttonBackground.height = iconHeight |
100 | 104 | end if |
101 | 105 |
|
102 | | - m.buttonIcon.width = m.buttonIcon.height |
103 | | - |
104 | | - m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)] |
105 | | - m.buttonText.translation = [0, height + 10] |
106 | | - m.buttonText.width = width |
107 | | - else if height = 0 and width = 0 |
108 | | - ' determine size of icon |
109 | | - if m.buttonIcon.bitmapWidth > 0 and m.buttonIcon.bitmapHeight > 0 |
110 | | - iconWidth = m.buttonIcon.bitmapWidth |
111 | | - iconHeight = m.buttonIcon.bitmapHeight |
112 | | - |
113 | | - ' set buttonBackground width and height to size of poster + padding |
114 | | - if m.top.padding > 0 |
115 | | - m.buttonBackground.width = iconWidth + (m.top.padding * 2) |
116 | | - m.buttonBackground.height = iconHeight + (m.top.padding * 2) |
117 | | - else |
118 | | - m.buttonBackground.width = iconWidth |
119 | | - m.buttonBackground.height = iconHeight |
120 | | - end if |
121 | | - |
122 | | - m.buttonIcon.translation = [((m.buttonBackground.width - iconWidth) / 2), ((m.buttonBackground.height - iconHeight) / 2)] |
123 | | - m.buttonText.translation = [0, m.buttonBackground.height + 10] |
124 | | - m.buttonText.width = width |
125 | | - end if |
| 106 | + m.buttonIcon.translation = [((m.buttonBackground.width - iconWidth) / 2), ((m.buttonBackground.height - iconHeight) / 2)] |
| 107 | + m.buttonText.translation = [0, m.buttonBackground.height + 12] |
| 108 | + m.buttonText.width = m.buttonBackground.width |
126 | 109 | end if |
127 | 110 | end sub |
128 | 111 |
|
129 | | -sub onHeightChanged() |
130 | | - m.buttonBackground.height = m.top.height |
131 | | - setIconSize() |
132 | | -end sub |
133 | | - |
134 | | -sub onWidthChanged() |
135 | | - m.buttonBackground.width = m.top.width |
136 | | - setIconSize() |
137 | | -end sub |
138 | | - |
139 | 112 | sub onPaddingChanged() |
140 | 113 | setIconSize() |
141 | 114 | end sub |
|
162 | 135 | ' translate the button so the focus border is visible |
163 | 136 | m.buttonBackground.translation = [m.top.borderSize, m.top.borderSize] |
164 | 137 | m.buttonIcon.translation = [m.top.padding + m.top.borderSize, m.top.padding + m.top.borderSize] |
| 138 | + |
| 139 | + m.buttonText.translation = [0, m.buttonBackground.height + 12 + m.top.borderSize] |
| 140 | + m.buttonText.width = m.buttonFocusBorder.width |
165 | 141 | end sub |
166 | 142 |
|
167 | 143 | function onKeyEvent(key as string, press as boolean) as boolean |
|
0 commit comments