Skip to content

Commit

Permalink
update: use siwin 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
levovix0 committed Oct 22, 2024
1 parent 8c0dcfa commit fbb602d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sigui.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ srcDir = "src"

requires "nim >= 2.0.8"
requires "fusion" # to write macros using pattern matching
requires "siwin >= 0.9" # to make window
requires "siwin >= 0.9.1" # to make window
# optional: requires "imageman" # to decode png
requires "bumpy" # for rects
requires "opengl" # for graphics
Expand Down
6 changes: 3 additions & 3 deletions src/sigui/mouseArea.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type
## mouse button pressed and released inside this area (also if pressed, leaved, re-entered and released)

dragged* {.deprecated #[use grabbed instead]#.}: Event[IVec2]
grabbed*: Event[IVec2]
grabbed*: Event[Vec2]
## mouse pressed and started moving while in this area
## emits start position (relative to screen)
## see mouseX and mouseY for current position
Expand All @@ -45,7 +45,7 @@ type
## cursor for mouse when inside this area

pressedButtons: set[MouseButton]
pressedPos: IVec2
pressedPos: Vec2
grabStarted: bool

proc initRedrawWhenPropertyChanged_ignore(t: type MouseArea, name: string): bool =
Expand Down Expand Up @@ -121,7 +121,7 @@ method recieve*(this: MouseArea, signal: Signal) =
if this.hovered[]:
this.pressedButtons.incl e.button
this.pressed[] = true
this.pressedPos = e.window.mouse.pos + e.window.pos
this.pressedPos = e.window.mouse.pos + e.window.pos.vec2
else:
this.pressedButtons.excl e.button
if this.pressedButtons == {}:
Expand Down
8 changes: 4 additions & 4 deletions src/sigui/textArea.nim
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ method recieve*(this: TextArea, signal: Signal) =
if window.keyboard.pressed.containsControl(): # when crl+c pressed and copyingUsingCtrlC enabled
# copy selected text
if this.selectionStart[] != this.selectionEnd[]:
globalClipboard.text = this.selectedText
this.parentWindow.clipboard.text = this.selectedText
else:
globalClipboard.text = this.text[]
this.parentWindow.clipboard.text = this.text[]

of Key.v:
if pastingUsingCtrlV in this.allowedInteractions:
Expand All @@ -251,7 +251,7 @@ method recieve*(this: TextArea, signal: Signal) =
this.pushState()
this.eraseSelectedText()

let ct = globalClipboard.text
let ct = this.parentWindow.clipboard.text
let offset = this.text.runeOffset(this.cursorPos[])
this.text{}.insert(ct, (if offset == -1: this.text.len else: offset))
this.text.changed.emit()
Expand All @@ -266,7 +266,7 @@ method recieve*(this: TextArea, signal: Signal) =
if this.selectionStart[] != this.selectionEnd[]:
if savingUndoStates in this.allowedInteractions:
this.pushState()
globalClipboard.text = this.selectedText
this.parentWindow.clipboard.text = this.selectedText
this.eraseSelectedText()

of Key.z:
Expand Down
3 changes: 0 additions & 3 deletions src/sigui/uibase.nim
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ var registredReflection {.compileTime.}: seq[tuple[f: NimNode, filter: NimNode]]
# callable syms


var globalClipboard* = siwin.clipboard()


proc vec4*(color: chroma.Color): Vec4 =
vec4(color.r, color.g, color.b, color.a)

Expand Down

0 comments on commit fbb602d

Please sign in to comment.