From acaab891333001c470f09887701b870f7dbbe12e Mon Sep 17 00:00:00 2001 From: Jared Wahlstrand Date: Sun, 29 Dec 2024 19:06:31 -0500 Subject: [PATCH] Label in the bottom right corner showing the current view (#314) Label shows the current view (only when zoomed in). This is selectable, allowing users to cut and paste into an editor (or the REPL). Also includes a microoptimization in the hover label setter and a minor fix to the README. Finally, require Julia 1.10 and bump version. --- .github/workflows/CI.yml | 4 ++-- Project.toml | 5 +++-- README.md | 2 +- src/ImageView.jl | 29 ++++++++++++++++++++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2f9326a..df133e1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - version: ['1.6', '1'] + version: ['1'] arch: [x64, x86] include: - os: ubuntu-latest @@ -27,7 +27,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: julia-actions/cache@v1 + - uses: julia-actions/cache@v2 env: cache-name: cache-artifacts with: diff --git a/Project.toml b/Project.toml index 2f0d34c..1f5c03a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ImageView" uuid = "86fae568-95e7-573e-a6b2-d8a6b900c9ef" author = ["Tim Holy win, "vbox"=>vbox, "frame"=>frames, "status"=>status, - "canvas"=>canvases) + "canvas"=>canvases, "viewlabel"=>viewlabel) # Add the player controls if !isempty(slicedata) @@ -526,10 +533,22 @@ function hoverinfo(lbl, btn, img, sd::SliceData{transpose}) where transpose if checkbounds(Bool, img, axes...) print(io, '[', y, ',', x, "] ") show(IOContext(io, :compact=>true), img[axes...]) - set_gtk_property!(lbl, :label, String(take!(io))) + Gtk4.label(lbl, String(take!(io))) + else + Gtk4.label(lbl, "") + end +end + +function viewinfo(lbl, zr, sd::SliceData{transpose}) where transpose + io = IOBuffer() + if zr.currentview == zr.fullview + print(io, "") else - set_gtk_property!(lbl, :label, "") + print(io, "view: ") + x, y = transpose ? (zr.currentview.x, zr.currentview.y) : (zr.currentview.y, zr.currentview.x) + print(io, '[', x.left, ':', x.right, ',', y.left, ':', y.right, ']') end + Gtk4.label(lbl, String(take!(io))) end function valuespan(img::AbstractMatrix)