~xigoi/vier

3720451d853f4ed80d1df4344b20a1a8ae076ca5 — Adam Blažek 7 months ago 5d48fc4
Evil hack to work around a bug
1 files changed, 16 insertions(+), 16 deletions(-)

M src/vier.nim
M src/vier.nim => src/vier.nim +16 -16
@@ 313,7 313,7 @@ proc ellipse(a, b: Vec, filled: bool): seq[Vec] =
    a.y.inc()
    b.y.dec()
  if filled:
    result = toSeq(toHashSet(result))
    result = result.toHashSet.toSeq # deduplicate

proc select(picture: Picture, target: Vec, tool: Tool) =
  case tool.kind


@@ 670,14 670,15 @@ proc draw(app: App) =
        app.pictures, origin, maxSize, app.selectedPictureIndex.int32
      ):
        picture.draw(app, origin, selected = index == app.selectedPictureIndex)
  drawText(
    app.font,
    app.command.cstring,
    (margin, screenSize.y - margin - textSize).toVector2,
    textSize,
    textSpacing,
    White,
  )
  if app.command != "\xC0":
    drawText(
      app.font,
      app.command.cstring,
      (margin, screenSize.y - margin - textSize).toVector2,
      textSize,
      textSpacing,
      White,
    )

proc processKeyboard(app: App) =
  let shift = isKeyDown(LeftShift) or isKeyDown(RightShift)


@@ 703,7 704,10 @@ proc processKeyboard(app: App) =
        app.command.setLen(app.command.len - 1)
    else:
      while (var ch = getCharPressed(); ch != 0):
        app.command.add(Rune(ch))
        if app.command == "\xC0": # evil hack to work around a bug
          app.command = ""
        else:
          app.command.add(Rune(ch))
  else:
    if isKeyPressed(Escape):
      if app.activeSelection:


@@ 783,9 787,7 @@ proc processKeyboard(app: App) =
        app.color = app.selectedPicture.colorAtCursor
    if isKeyPressed(Semicolon):
      app.mode = Command
      app.command = ""
      while (var ch = getCharPressed(); ch != 0):
        discard
      app.command = "\xC0" # evil hack to work around a bug
    if isKeyPressed(Equal):
      if shift:
        app.pictures.apply(zoomIn)


@@ 869,9 871,7 @@ proc processMouse(app: App) =
          app.secondaryColorPos.palette = index
          app.secondaryColorPos.cursor = (pos - canvasOrigin) div palette.scale
          app.secondaryColor =
            palette.image.getImageColor(
              app.secondaryColorPos.cursor.x, app.secondaryColorPos.cursor.y
            )
            palette[(app.secondaryColorPos.cursor.x, app.secondaryColorPos.cursor.y)]
        break
  block pictures:
    let origin: Vec = (margin, margin + maxPaletteHeight + margin)