-
Notifications
You must be signed in to change notification settings - Fork 37
Add image viewer widget #565
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
base: main
Are you sure you want to change the base?
Changes from 39 commits
e51b874
f323303
e1d2aaf
e4fe2c8
440bde3
d029bbc
ddd04b9
d641657
9fe9ddc
27ebbd7
92d78b3
de263cc
43137a1
03e4120
c9f2484
81cf00a
ec774a0
d85a312
09b9772
8269f0a
6ea6026
4e4f34d
ee6b8e7
0e10331
4febe14
4efdf4b
85cfb9b
5188571
c3cfc21
932c318
9bd6dbb
048c3d3
816fae5
f0cecc1
2ca47a3
082de67
bdf8cfc
68179c5
e55568c
30ca041
1a35f45
964b798
1136030
897952c
571c888
b43a96e
b4f81ab
dd6555b
9226992
784a08b
89d01b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -10,16 +10,15 @@ use makepad_widgets::{makepad_micro_serde::*, *}; | |||
| use matrix_sdk::ruma::{OwnedRoomId, RoomId}; | ||||
| use crate::{ | ||||
| avatar_cache::clear_avatar_cache, home::{ | ||||
| main_desktop_ui::MainDesktopUiAction, new_message_context_menu::NewMessageContextMenuWidgetRefExt, room_screen::{clear_timeline_states, MessageAction}, rooms_list::{clear_all_invited_rooms, enqueue_rooms_list_update, RoomsListAction, RoomsListRef, RoomsListUpdate} | ||||
| main_desktop_ui::MainDesktopUiAction, new_message_context_menu::NewMessageContextMenuWidgetRefExt, room_image_viewer_detail::RoomImageViewerDetailWidgetRefExt, room_image_viewer_footer::RoomImageViewerFooterWidgetRefExt, room_screen::{MessageAction, clear_timeline_states}, rooms_list::{RoomsListAction, RoomsListRef, RoomsListUpdate, clear_all_invited_rooms, enqueue_rooms_list_update} | ||||
| }, join_leave_room_modal::{ | ||||
| JoinLeaveModalKind, JoinLeaveRoomModalAction, JoinLeaveRoomModalWidgetRefExt | ||||
| }, login::login_screen::LoginAction, logout::logout_confirm_modal::{LogoutAction, LogoutConfirmModalAction, LogoutConfirmModalWidgetRefExt}, persistence, profile::user_profile_cache::clear_user_profile_cache, room::BasicRoomDetails, shared::callout_tooltip::{ | ||||
| }, login::login_screen::LoginAction, logout::logout_confirm_modal::{LogoutAction, LogoutConfirmModalAction, LogoutConfirmModalWidgetRefExt}, persistence, profile::user_profile_cache::clear_user_profile_cache, room::BasicRoomDetails, shared::{callout_tooltip::{ | ||||
| CalloutTooltipOptions, | ||||
| CalloutTooltipWidgetRefExt, | ||||
| TooltipAction, | ||||
| }, sliding_sync::current_user_id, utils::{ | ||||
| room_name_or_id, | ||||
| OwnedRoomIdRon, | ||||
| }, image_viewer::{ImageViewerAction, ImageViewerWidgetRefExt, LoadState}}, sliding_sync::current_user_id, utils::{ | ||||
| OwnedRoomIdRon, image_viewer_error_to_string, room_name_or_id | ||||
| }, verification::VerificationAction, verification_modal::{ | ||||
| VerificationModalAction, | ||||
| VerificationModalWidgetRefExt, | ||||
|
|
@@ -40,6 +39,9 @@ live_design! { | |||
| use crate::shared::popup_list::*; | ||||
| use crate::home::new_message_context_menu::*; | ||||
| use crate::shared::callout_tooltip::CalloutTooltip; | ||||
| use crate::shared::image_viewer::ImageViewer; | ||||
| use crate::home::room_image_viewer_detail::RoomImageViewerDetail; | ||||
| use crate::home::room_image_viewer_footer::RoomImageViewerFooter; | ||||
| use link::tsp_link::TspVerificationModal; | ||||
|
|
||||
|
|
||||
|
|
@@ -96,7 +98,32 @@ live_design! { | |||
| login_screen = <LoginScreen> {} | ||||
| } | ||||
|
|
||||
| <PopupList> {} | ||||
| image_viewer = <Modal> { | ||||
| content: { | ||||
| width: Fill, height: Fill, | ||||
| flow: Down | ||||
| show_bg: true | ||||
| draw_bg: { | ||||
| color: #000 | ||||
| } | ||||
|
|
||||
| <View> { | ||||
| width: Fill, height: Fill, | ||||
| flow: Overlay | ||||
| image_viewer_inner = <ImageViewer> { | ||||
| align: {x: 0.5, y: 0.5} | ||||
| padding: {bottom: 0} | ||||
| } | ||||
| image_detail = <RoomImageViewerDetail> { | ||||
| width: Fill, height: Fill, | ||||
| } | ||||
| } | ||||
|
|
||||
| footer = <RoomImageViewerFooter> {} | ||||
| } | ||||
| } | ||||
|
|
||||
| popup_list = <PopupList> {} | ||||
|
|
||||
| // Context menus should be shown in front of other UI elements, | ||||
| // but behind verification modals. | ||||
|
|
@@ -388,6 +415,10 @@ impl MatchEvent for App { | |||
| _ => {} | ||||
| } | ||||
|
|
||||
| if self.handle_image_viewer_action(cx, action) { | ||||
| continue; | ||||
| } | ||||
|
|
||||
| // `VerificationAction`s come from a background thread, so they are NOT widget actions. | ||||
| // Therefore, we cannot use `as_widget_action().cast()` to match them. | ||||
| // | ||||
|
|
@@ -481,7 +512,38 @@ impl AppMain for App { | |||
| } | ||||
| } | ||||
| } | ||||
|
|
||||
| // Ensure all draw events are handled on the main UI thread regardless of modal consuming the events. | ||||
| if let Event::Draw(_) = event { | ||||
| let scope = &mut Scope::with_data(&mut self.app_state); | ||||
| self.ui.handle_event(cx, event, scope); | ||||
| return; | ||||
| } | ||||
kevinaboos marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
|
|
||||
| // If the image viewer modal is really opened, handles non-Draw events using the modal. | ||||
| let image_viewer_modal = self.ui.modal(ids!(image_viewer)); | ||||
| if image_viewer_modal.is_open() && image_viewer_modal.area().rect(cx).size.y > 0.0 { | ||||
| let scope = &mut Scope::with_data(&mut self.app_state); | ||||
| self.ui | ||||
| .view(ids!(popup_list)) | ||||
| .handle_event(cx, event, scope); | ||||
| self.ui | ||||
| .modal(ids!(image_viewer)) | ||||
| .handle_event(cx, event, scope); | ||||
| // Pass the Signal event to the underlying room screen, so as to populate the full image in the image viewer. | ||||
| if let Event::Signal = event { | ||||
| self.ui.handle_event(cx, event, scope); | ||||
| } | ||||
| if let Event::Actions(actions) = event { | ||||
| for action in actions { | ||||
| if self.handle_image_viewer_action(cx, action) { | ||||
| continue; | ||||
| } | ||||
| } | ||||
| } | ||||
| return; | ||||
| } | ||||
|
||||
| self.ui.view(ids!(login_screen_view)).set_visible(cx, show_login); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a tracking issue here: #626. Hope to be settle this issue after this PR is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ... strange. Perhaps we need to redesign the LoginScreen to be something other than just a simple overlay view.
However, I don't understand why the existence of the LoginScreen (or whether it's currently visible) would impact how events are delivered to other widgets in that same overlay view (within the app body). I don't think that's actually the problem, because all the other modals in that same overlay view work just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see one of my latest comments — i think if you just put the ImageViewer in a Modal (like with the verification modal or other modals), it will work as expected. I've never had any problems with modals in the top-level app not working as intended.
Uh oh!
There was an error while loading. Please reload this page.