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

[ui] ImageGallery: update the Viewer2D correctly when the GridView's current item changes #1823

Merged
merged 1 commit into from
Nov 17, 2022

Conversation

cbentejac
Copy link
Contributor

@cbentejac cbentejac commented Nov 15, 2022

Description

When a project file is opened, its images are first loaded in the ImageGallery, which displays them in a GridView. The first image in the gallery is automatically selected within that GridView and then displayed in the Viewer2D, with an auto-fit applied so it can fit in the viewer. The image displayed in the Viewer2D is then updated according to the one that is selected in the ImageGallery, in which every image is identified by its index within the GridView.

This PR addresses two issues related to the indices update within the GridView:

  1. If the currently selected image is the first one in the gallery and another .mg file is opened, the new first image in the gallery, which will automatically be selected, will not properly be displayed in the Viewer2D: the auto-fit will not be applied upon the opening of the .mg file, and any manual auto-fit will fail until another image in the gallery is selected. The Viewer2D is only updated when there is an index change in the GridView, and when a new project file is opened while the first image in the gallery is selected, the GridView's current index goes from 0 to 0, hence the lack of update.
  2. If an image in the gallery is removed (if it is removed, then it was necessarily selected), the next image in the GridView takes its place as the currently selected image, but is not displayed in the Viewer2D; instead of the removed image, nothing is displayed. The reason is identical: if the fifth image in the gallery (with a GridView index of 4) is removed, the sixth image (with an index of 5) takes its place, and becomes the fifth image (with an index of 4). The GridView's current index thus goes from 4 to 4, not triggering any update for the Viewer2D.

Both issues are fixed by using the change of the GridView's current item instead of its current index to trigger the Viewer2D display updates.

Features list

  • Trigger Viewer2D display updates when the current item of the ImageGallery's GridView is changed, instead of its current index

…item changes

This commit ensures that any change in the ImageGallery's GridView
selection is correctly reflected in the Viewer2D. In particular:
- When a new project file is opened, the first image in the gallery
is now displayed in the 2D viewer, after a correct auto-fit has been
applied
- When an image in the gallery is removed, the adjacent image that
becomes selected is automatically displayed in the 2D viewer
@cbentejac cbentejac force-pushed the fix/imgGalleryGridIdxReset branch from 3f8f1c4 to a531caf Compare November 17, 2022 11:24
@cbentejac cbentejac changed the title [ui] ImageGallery: update GridView's index to display images correctly in the Viewer2D [ui] ImageGallery: update the Viewer2D correctly when the GridView's current item changes Nov 17, 2022
@fabiencastan fabiencastan added this to the Meshroom 2022.1.0 milestone Nov 17, 2022
@fabiencastan fabiencastan merged commit a9447ac into develop Nov 17, 2022
@fabiencastan fabiencastan deleted the fix/imgGalleryGridIdxReset branch November 17, 2022 18:58
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

Successfully merging this pull request may close these issues.

3 participants