Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

canvas proportions disrupted when image on canvas in box with button widget #88

Open
mantzaris opened this issue May 8, 2019 · 0 comments

Comments

@mantzaris
Copy link

There is an unexpected effect seen when trying to dock a canvas onto a Box, and then include a Button widget as well, or even when trying to duplicate the image into 2 segments:

img = load("hg1.png")
img2 = load("hg1.png")
c = canvas(UserUnit)
c2 = canvas(UserUnit)
bx = Box(:v)

win = Window("ok")
push!(win,bx)
push!(bx,c)
push!(bx,c2)

with the remaining code from the zoom/pan example remaining the same

zr = Signal(ZoomRegion(img))
# Interactivity: hold down Ctrl and then click-drag to select a
# region via rubberband. It updates `zr`.
zoomsigs = init_zoom_rubberband(c, zr)
# See also: init_pan_drag, init_zoom_scroll, init_pan_scroll
# You can turn on all of these for the same canvas
# Create a Signal containing a `view` of the image over the
# region of interest. This view will update anytime `zr` updates.
imgsig = map(zr) do r
    cv = r.currentview
    view(img, UnitRange{Int}(cv.y), UnitRange{Int}(cv.x))
end
## Turn on drawing for the canvas
# `draw`, when passed Signal(s), will cause the canvas to be updated
# whenever any of the input Signals updates. It will also redraw
# whenever the Canvas is resized.
redraw = draw(c, imgsig) do cnvs, image
    copy!(cnvs, image)
    # canvas adopts the indices of the zoom region. That way if we
    # zoom in further, we select the correct region.
    set_coordinates(cnvs, value(zr))
end

## Don't forget this!
Gtk.showall(win)

This effect where the displays for both Box components are disrupted is also visible when

bt = Button("ok")
push!(bx,bt)

how can the images on the canvas become stacked onto the layout object without a disruption?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant