-
Notifications
You must be signed in to change notification settings - Fork 5
FlipBook: Image replacement and event handlers #15
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: master
Are you sure you want to change the base?
Conversation
SimpleImageIO/Image.cs
Outdated
| } | ||
|
|
||
| /// <summary> | ||
| /// Calculates the absolute Difference from two equal-sized images with equal channel count |
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.
| /// Calculates the absolute Difference from two equal-sized images with equal channel count | |
| /// Calculates the absolute difference |a - b| of two equal-sized images with equal channel count |
SimpleImageIO/FlipBook.cs
Outdated
| if (String.IsNullOrEmpty(this.containerId)) | ||
| this.containerId = id; |
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.
Why do you only store it the first time?
Seems like this could yield confusing behavior if the same flip book is generated multiple times.
SimpleImageIO/FlipBook.cs
Outdated
|
|
||
| // string json = $$""" | ||
| // { | ||
| // "width": {}, | ||
| // "height": {}, | ||
| // "containerId": "{}", | ||
| // "initialZoom": {}, | ||
| // "initialTMO": {}, | ||
| // "initialTMOOverrides": [ | ||
| // {} | ||
| // ], | ||
| // "names": [{{string.Join(',', nameStrs.Select(n => $"\"{n}\""))}}], | ||
| // "dataUrls": [{{string.Join(',', dataStrs.Select(n => $"\"{n}\""))}}], | ||
| // "types": [{{string.Join(',', typeStrs.Select(n => $"\"{n}\""))}}], | ||
| // "colorTheme": "{}", | ||
| // "groupName": "{{groupName}}", | ||
| // "hideTools": {} | ||
| // } | ||
| // """; |
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.
| // string json = $$""" | |
| // { | |
| // "width": {}, | |
| // "height": {}, | |
| // "containerId": "{}", | |
| // "initialZoom": {}, | |
| // "initialTMO": {}, | |
| // "initialTMOOverrides": [ | |
| // {} | |
| // ], | |
| // "names": [{{string.Join(',', nameStrs.Select(n => $"\"{n}\""))}}], | |
| // "dataUrls": [{{string.Join(',', dataStrs.Select(n => $"\"{n}\""))}}], | |
| // "types": [{{string.Join(',', typeStrs.Select(n => $"\"{n}\""))}}], | |
| // "colorTheme": "{}", | |
| // "groupName": "{{groupName}}", | |
| // "hideTools": {} | |
| // } | |
| // """; |
FlipViewer/src/ImageContainer.tsx
Outdated
| var relX = event.nativeEvent.offsetX;: nativeEvent. | ||
| var relY = event.nativeEvent.offsetY;: nativeEvent. |
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.
what happened here?
FlipViewer/src/ImageContainer.tsx
Outdated
| if (this.props.onWheel) | ||
| { | ||
| this.props.onWheel(event.deltaY); | ||
| } | ||
|
|
||
| return; |
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.
Not tested, but sounds like quite awkward UX to have ALT as a means to override the zoom behavior but also then forward this wheel event in the flip book context?
FlipViewer/src/flipviewer.ts
Outdated
| tms[book.state.selectedIdx].setPixels(images[0] as (Float32Array<ArrayBufferLike>)); | ||
| } | ||
|
|
||
| // flipBook.imageContainer.current.props.rawPixels[flipBook.state.selectedIdx] = images[0] as (Float32Array<ArrayBufferLike>); //TODO: maybe it doesnt work like that |
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.
?
…eImage() only really take Images instead of whole Tuple
…l scrolling so that user can add various number of custom actions keys on c# side
FlipViewer/src/ImageContainer.tsx
Outdated
| import { JSX } from 'react/jsx-runtime'; | ||
|
|
||
| export type OnClickHandler = (col: number, row: number, event: MouseEvent) => void | ||
| export type OnClickHandler = (buttom: number) => void |
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.
Why is the OnClickHandler now only reporting the button, not the clicked pixel?
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.
Because OnMouseOverHandler does that. C# stores the current pixel. In some situations, the mouse is not pressed (but only keys) and when I press keys for some actions on the c# side, I still have the current pixel coords.
…place magnifier around mouse (prettier)
…state also on the js side)
| export interface ListenerState { | ||
| /// Mouse state | ||
| mouseButtom: number; | ||
| mouseX: number; |
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.
Should document the coordinate system here: Relative to image? Screen space coordinates wrt the Container?
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.
"top left of image" / "relative to image" still does not specify the units ;) Is it pixels of the image? Browser pixels? Sth else?
| let magnifierResolution = 1; | ||
| let flagXSwapped = false; | ||
| let flagYSwapped = false; |
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.
This should be tracked in each container's individual state rather than globally.
Also, the swapping behaviour should probably reset to the default position when the mouse is clicked and only remain in the current state during move events.
| let isAnyKeyPressed = false; | ||
| export function setKeyPressed(value: boolean): void { | ||
| isAnyKeyPressed = value; | ||
| } |
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.
Is it a good idea to track this as global state across all flip books?
| export type OnClickHandler = (mouseButton: number, mouseX: number, mouseY: number, deltaY: number, ID: string, selectedIdx: number, keyPressed: string, isPressed: boolean) => void | ||
| export type OnWheelHandler = (mouseButton: number, mouseX: number, mouseY: number, deltaY: number, ID: string, selectedIdx: number, keyPressed: string, isPressed: boolean) => void | ||
| export type OnMouseOverHandler = (mouseButton: number, mouseX: number, mouseY: number, deltaY: number, ID: string, selectedIdx: number, keyPressed: string, isPressed: boolean) => void | ||
| export type OnKeyHandler = (mouseButton: number, mouseX: number, mouseY: number, deltaY: number, ID: string, selectedIdx: number, keyPressed: string, isPressed: boolean) => void |
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.
Does it make sense to send deltaY (I assume that is the mouse wheel motion?) for non-wheel events?
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.
And why do the click handlers now also report key event data?
|
|
||
| // Listener state that is forwared | ||
| export interface ListenerState { | ||
| /// Mouse state |
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.
Not really an informative comment. State of what exactly? What is the meaning of the value? How does a single number describe the state of your mouse?
| /// Key state (Handled by the Flipbook.tsx) | ||
| // ID of the Flipbook | ||
| ID: string; | ||
| // Which image is selected in a Flipbook | ||
| selectedIdx: number; | ||
| // Key pressed | ||
| keyPressed: string; | ||
| isPressed: boolean; |
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.
Logic here is unclear to me. Do you only track a single key at a time? What happens if multiple keys are pressed simultaneously?
No description provided.