Skip to content

Commit

Permalink
Add mouse coordinates display in live viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
codejaeger committed Apr 10, 2021
1 parent 4241ea1 commit f5651ff
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/javis_viewer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ function _javis_viewer(

# Create a textbox
tbox = GtkReactive.textbox(Int; signal = signal(slide))


# Create a Gtk label to print the mouse coordinates upon hover
mouse_coordinates = GtkLabel("")

# Button for going forward through animation
forward = GtkButton("==>")

Expand All @@ -146,16 +149,22 @@ function _javis_viewer(

# Gtk Canvas object upon which to draw image; sized via frame size
canvas = Gtk.Canvas(frame_dims[1], frame_dims[2])

# Add callback to update mouse corrdinates over canvas
canvas.mouse.motion = @guarded (widget, event) -> begin
GAccessor.text(mouse_coordinates, "$(event.x), $(event.y)")
end

# Grid to allocate widgets
grid = Gtk.Grid()

# Allocate the widgets in a 3x3 grid
# Allocate the widgets in a 4x3 grid
grid[1:3, 1] = canvas
grid[1:3, 2] = slide
grid[1, 3] = backward
grid[2, 3] = tbox
grid[3, 3] = forward
grid[2, 2] = mouse_coordinates
grid[1:3, 3] = slide
grid[1, 4] = backward
grid[2, 4] = tbox
grid[3, 4] = forward

# Center all widgets vertically in grid
set_gtk_property!(grid, :valign, 3)
Expand Down

0 comments on commit f5651ff

Please sign in to comment.