Browse Source

small update

Ethosa 4 years ago
parent
commit
d518afb33c

+ 2 - 1
README.md

@@ -92,7 +92,8 @@ For use debug mode you should compile with `-d:debug` or `--define:debug`, e.g.
 
 ## Export
 Use the [`Nim compiler user guide`](https://nim-lang.org/docs/nimc.html#dynliboverride) for export to the other OS.
-[Static linking SDL2](https://github.com/nim-lang/sdl2#static-linking-sdl2)
+[Static linking SDL2](https://github.com/nim-lang/sdl2#static-linking-sdl2)  
+Also use [`niminst`](https://github.com/nim-lang/niminst) tool for generate an installer
 
 -   CrossPlatform export for Windows (tested on Windows 7 x64 and Windows 10 x64)
     -   `nim c -d:mingw -d:release --opt:speed --noNimblePath file.nim`

+ 4 - 2
src/nodesnim/core/font.nim

@@ -211,7 +211,8 @@ proc getCaretPos*(text: StyleText, pos: uint32): tuple[a: Vector2Obj, b: uint16]
         return result
     result[0].y -= text.spacing
 
-proc getPosUnderPoint*(text: StyleText, global_pos, text_pos: Vector2Obj, text_align: AnchorObj): uint32 =
+proc getPosUnderPoint*(text: StyleText, global_pos, text_pos: Vector2Obj,
+                       text_align: AnchorObj = Anchor(0, 0, 0, 0)): uint32 =
   ## Returns caret position under mouse.
   if not text.font.isNil():
     let
@@ -301,7 +302,8 @@ proc render*(text: StyleText, size: Vector2Obj, align: AnchorObj) =
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
 
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA.GLint, surface.w,  surface.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, surface.pixels)
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA.GLint, surface.w, surface.h,
+                 0, GL_RGBA, GL_UNSIGNED_BYTE, surface.pixels)
 
     # free memory
     surface.freeSurface()

+ 2 - 1
src/nodesnim/core/scene_builder.nim

@@ -57,7 +57,8 @@ macro build*(code: untyped): untyped =
   ##   build:
   ##     - Scene scene:
   ##       Node test_node
-  ##       Node node
+  ##       Label text:
+  ##         call setText("Hello, world!")
   result = newStmtList()
   var
     current_level: seq[NimNode] = @[]

+ 1 - 1
src/nodesnim/core/stylesheet.nim

@@ -41,7 +41,7 @@ proc `[]=`*(a: StyleSheetRef, key, value: string) =
       return
   a.dict.add((key, value))
 
-proc count*(a: StyleSheetRef): int {.inline.} =
+proc len*(a: StyleSheetRef): int {.inline.} =
   ## Returns styles count.
   a.dict.len()
 

+ 1 - 0
src/nodesnim/core/tileset.nim

@@ -42,6 +42,7 @@ proc TileSet*(img: string, tile_size: Vector2Obj, mode: Glenum = GL_RGB): TileSe
   surface = nil
 
 proc draw*(self: TileSetObj, tilex, tiley, x, y: float) =
+  ## Draws tile at position `tilex`,`tiley` to `x`,`y` position.
   if self.texture > 0:
     let
       texx1 = self.grid.x*tilex / self.size.x

+ 1 - 3
src/nodesnim/nodes/canvas.nim

@@ -65,8 +65,6 @@ template loadColor(color_argument_name: untyped): untyped =
   canvas.renderer.setDrawColor(clr.r.uint8, clr.g.uint8, clr.b.uint8, clr.a.uint8)
 
 template loadGL(canvas: untyped): untyped =
-  `canvas`.renderer.present()
-  discard `canvas`.renderer.readPixels(nil, 0, `canvas`.surface.pixels, 0)
   if `canvas`.canvas_texture == 0:
     glGenTextures(1, `canvas`.canvas_texture.addr)
   glBindTexture(GL_TEXTURE_2D, `canvas`.canvas_texture)
@@ -155,7 +153,7 @@ method resize*(self: CanvasRef, w, h: GLfloat, save_anchor: bool = false) {.base
   if self.kind == CANVAS_NODE:
     var new_surface = createRGBSurface(
       0, w.cint, h.cint, 32,
-      0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000'u32)
+      0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000u32)
     self.surface.blitSurface(nil, new_surface, nil)
     self.renderer.destroy()
     self.surface.freeSurface()