Browse Source

update color and subwindow.

SakiKawasaki 4 years ago
parent
commit
8159b7dbb8
2 changed files with 24 additions and 4 deletions
  1. 4 0
      src/nodesnim/core/color.nim
  2. 20 4
      src/nodesnim/nodescontrol/subwindow.nim

+ 4 - 0
src/nodesnim/core/color.nim

@@ -77,6 +77,10 @@ proc Color*(): ColorRef {.inline.} =
   ColorRef(r: 0, g: 0, b: 0, a: 0)
 
 
+proc getBrightness*(self: ColorRef): float =
+  (self.r + self.g + self.b) / 3f
+
+
 proc normalize*(n: float): uint32 {.inline.} =
   if n > 1.0:
     255'u32

+ 20 - 4
src/nodesnim/nodescontrol/subwindow.nim

@@ -244,12 +244,12 @@ method resize*(self: SubWindowRef, w, h: float) {.base.} =
     self.rect_size.y = h
 
 
-method setTitle*(self: SubWindowRef, title: string) {.base.} =
-  ## Changes subwindow title.
+method setBorderColor*(self: SubWindowRef, color: ColorRef) {.base.} =
+  ## Changes border color.
   ##
   ## Arguments:
-  ## - `title` is a new title.
-  self.title.setText(title)
+  ## - `color` is a new border color.
+  self.border_color = color
 
 
 method setIcon*(self: SubWindowRef, gltexture: GlTextureObj) {.base.} =
@@ -266,3 +266,19 @@ method setIcon*(self: SubWindowRef, file: cstring) {.base.} =
   ## Arguments:
   ## - `file` is an image file path.
   self.icon = load(file)
+
+
+method setTitleBarColor*(self: SubWindowRef, color: ColorRef) {.base.} =
+  ## Changes title bar color.
+  ##
+  ## Arguments:
+  ## - `color` is a new title bar color.
+  self.title_bar_color = color
+
+
+method setTitle*(self: SubWindowRef, title: string) {.base.} =
+  ## Changes subwindow title.
+  ##
+  ## Arguments:
+  ## - `title` is a new title.
+  self.title.setText(title)