+
+ {set_remove_overlay_button}
{pin_unpin_button}
if *value_variable_kind == ValueVariableKind::Expression {{edit_button}} else {<>>}
@@ -168,7 +291,7 @@ pub(crate) fn ImageListItem(props: &ImageListItemProps) -> Html {
if let Image::Full(entry) = entry {
- if *selected {
} else {<>>}
+ if *selected {
} else {<>>}
} else {<>>}
}
diff --git a/src/webview-ui/src/components/image_selection_list.rs b/src/webview-ui/src/components/image_selection_list.rs
index 92a578fc..009ec58d 100644
--- a/src/webview-ui/src/components/image_selection_list.rs
+++ b/src/webview-ui/src/components/image_selection_list.rs
@@ -5,7 +5,7 @@ use yew::prelude::*;
use yewdux::prelude::*;
use crate::{
- application_state::app_state::{AppState, StoreAction},
+ application_state::{app_state::{AppState, StoreAction}, images::DrawingContext},
common::{CurrentlyViewing, Image, ViewId},
components::image_list_item::ImageListItem,
};
@@ -69,7 +69,7 @@ fn ImageItemWrapper(props: &ImageItemWrapperProps) -> Html {
state
.drawing_options
.borrow()
- .get(&image_id)
+ .get(&image_id, &DrawingContext::BaseImage)
.and_then(|d| d.batch_item)
}
});
@@ -106,7 +106,12 @@ fn ImageItemWrapper(props: &ImageItemWrapperProps) -> Html {
{onclick}
class={entry_style.clone()}
>
-
+
}
}
diff --git a/src/webview-ui/src/components/main.rs b/src/webview-ui/src/components/main.rs
index a2044dad..52af1b5e 100644
--- a/src/webview-ui/src/components/main.rs
+++ b/src/webview-ui/src/components/main.rs
@@ -6,7 +6,7 @@ use yew::prelude::*;
use yewdux::{prelude::Dispatch, use_selector};
use crate::{
- application_state::app_state::AppState,
+ application_state::{app_state::AppState, images::DrawingContext},
common::{pixel_value::PixelValue, AppMode, ViewId},
components::{
main_toolbar::MainToolbar, sidebar::Sidebar, status_bar::StatusBar,
@@ -72,7 +72,7 @@ fn StatusBarWrapper(props: &StatusBarWrapperProps) -> Html {
.get()
.drawing_options
.borrow()
- .get(&image.info.image_id)
+ .get(&image.info.image_id, &DrawingContext::BaseImage)
.and_then(|d| d.batch_item)
.unwrap_or(0);
diff --git a/src/webview-ui/src/components/main_toolbar.rs b/src/webview-ui/src/components/main_toolbar.rs
index 9a389f24..e971ec07 100644
--- a/src/webview-ui/src/components/main_toolbar.rs
+++ b/src/webview-ui/src/components/main_toolbar.rs
@@ -9,10 +9,14 @@ use yew::prelude::*;
use yewdux::{prelude::use_selector, use_selector_with_deps, Dispatch};
use crate::{
- application_state::app_state::{AppState, StoreAction, UpdateGlobalDrawingOptions},
+ application_state::{
+ app_state::{AppState, OverlayAction, StoreAction, UpdateGlobalDrawingOptions},
+ images::DrawingContext,
+ views::OverlayItem,
+ },
coloring::Coloring,
colormap::ColorMapKind,
- common::{AppMode, Image, ViewId},
+ common::{AppMode, CurrentlyViewing, Image, SizeU32, ViewId},
components::{checkbox::Checkbox, display_options::DisplayOption, icon_button::IconButton},
vscode::vscode_requests::VSCodeRequests,
};
@@ -109,6 +113,281 @@ pub fn HeatmapColormapDropdown(props: &HeatmapColormapDropdownProps) -> Html {
}
}
+#[derive(PartialEq, Properties)]
+pub struct OverlayMenuItemProps {
+ overlay: OverlayItem,
+}
+
+#[function_component]
+pub fn OverlayMenuItem(props: &OverlayMenuItemProps) -> Html {
+ let OverlayMenuItemProps { overlay } = props;
+ let overlay = overlay.clone();
+
+ let info = use_selector_with_deps(
+ |state: &AppState, overlay: &OverlayItem| {
+ let images = state.images.borrow();
+ let image = images
+ .get(&overlay.id)
+ .unwrap_or_else(|| panic!("Image with id {:?} not found", overlay.id));
+ if let Image::Full(info) = image {
+ info.clone()
+ } else {
+ panic!("Overlay item is not a full image: {:?}", overlay.id);
+ }
+ },
+ overlay.clone(),
+ );
+
+ let cv = use_selector_with_deps(
+ move |state: &AppState, view_id: &ViewId| {
+ state.image_views.borrow().get_currently_viewing(*view_id)
+ },
+ overlay.view_id,
+ );
+ let cv_image_id = cv.as_ref().as_ref().map(|cv| cv.id().clone());
+ if cv_image_id.is_none() {
+ log::warn!(
+ "OverlayMenuItem: No currently viewing image found for view_id {:?}",
+ overlay.view_id
+ );
+ return html! {};
+ }
+ let cv_image_id = cv_image_id.unwrap();
+ let view_id = overlay.view_id;
+
+ let overlay_expression = use_selector_with_deps(
+ |state: &AppState, overlay_id| {
+ let images = state.images.borrow();
+ let info = images
+ .get(overlay_id)
+ .unwrap_or_else(|| panic!("Image with id {:?} not found", overlay_id))
+ .minimal();
+ info.expression.clone()
+ },
+ overlay.id.clone(),
+ );
+
+ let same_size = use_selector_with_deps(
+ {
+ let cv_image_id = cv_image_id.clone();
+ move |state: &AppState, overlay_id| {
+ let images = state.images.borrow();
+ let overlay_size = images.get(overlay_id).and_then(|image| {
+ if let Image::Full(info) = image {
+ Some(SizeU32 {
+ width: info.width,
+ height: info.height,
+ })
+ } else {
+ None
+ }
+ });
+ let cv_size = images.get(&cv_image_id).and_then(|image| {
+ if let Image::Full(info) = image {
+ Some(SizeU32 {
+ width: info.width,
+ height: info.height,
+ })
+ } else {
+ None
+ }
+ });
+ overlay_size == cv_size
+ }
+ },
+ overlay.id.clone(),
+ );
+
+ let drawing_options = use_selector_with_deps(
+ |state: &AppState, (image_id, drawing_context)| {
+ state
+ .drawing_options
+ .borrow()
+ .get(image_id, drawing_context)
+ .cloned()
+ .unwrap_or_default()
+ },
+ (overlay.id.clone(), DrawingContext::Overlay),
+ );
+
+ let dispatch = Dispatch::