closes #6 - use DoNotChange constant

This commit is contained in:
Vladimir Markelov 2015-10-19 16:54:26 -07:00
parent 6233b42e76
commit 92a3c3b9f1
2 changed files with 14 additions and 6 deletions

View File

@ -59,7 +59,7 @@ func NewThemeManager() *ThemeManager {
defTheme.colors[ColorDisabledText] = ColorBlackBold defTheme.colors[ColorDisabledText] = ColorBlackBold
defTheme.colors[ColorDisabledBack] = ColorWhite defTheme.colors[ColorDisabledBack] = ColorWhite
defTheme.colors[ColorText] = ColorWhite defTheme.colors[ColorText] = ColorWhite
defTheme.colors[ColorBack] = ColorBlack defTheme.colors[ColorBack] = ColorBlackBold
defTheme.colors[ColorViewBack] = ColorBlackBold defTheme.colors[ColorViewBack] = ColorBlackBold
defTheme.colors[ColorViewText] = ColorWhite defTheme.colors[ColorViewText] = ColorWhite

View File

@ -35,17 +35,25 @@ func NewWindow(parent Screen, x, y, w, h int, title string) *Window {
} }
func (w *Window) SetSize(width, height int) { func (w *Window) SetSize(width, height int) {
if width > 1000 || width < w.minW { if width == w.width && height == w.height {
return
}
if width != DoNotChange && (width > 1000 || width < w.minW) {
panic(fmt.Sprintf("Invalid width: %v", width)) panic(fmt.Sprintf("Invalid width: %v", width))
} }
if height > 200 || height < w.minH { if height != DoNotChange && (height > 200 || height < w.minH) {
panic(fmt.Sprintf("Invalid height: %v", height)) panic(fmt.Sprintf("Invalid height: %v", height))
} }
if width != DoNotChange {
w.width = width w.width = width
}
if height != DoNotChange {
w.height = height w.height = height
}
w.canvas.SetSize(width, height) w.canvas.SetSize(w.width, w.height)
RepositionControls(0, 0, w) RepositionControls(0, 0, w)
} }