Skip to content

Conversation

@OpaKnoppi
Copy link

No description provided.

}

/// <summary>
/// Calculates the absolute Difference from two equal-sized images with equal channel count
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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

Comment on lines 436 to 437
if (String.IsNullOrEmpty(this.containerId))
this.containerId = id;
Copy link
Owner

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.

Comment on lines 557 to 575

// 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": {}
// }
// """;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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": {}
// }
// """;

Comment on lines 303 to 304
var relX = event.nativeEvent.offsetX;: nativeEvent.
var relY = event.nativeEvent.offsetY;: nativeEvent.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened here?

Comment on lines 282 to 287
if (this.props.onWheel)
{
this.props.onWheel(event.deltaY);
}

return;
Copy link
Owner

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?

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

import { JSX } from 'react/jsx-runtime';

export type OnClickHandler = (col: number, row: number, event: MouseEvent) => void
export type OnClickHandler = (buttom: number) => void
Copy link
Owner

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?

Copy link
Author

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.

@pgrit pgrit changed the title template changes FlipBook: Image replacement and event handlers Jan 15, 2026
export interface ListenerState {
/// Mouse state
mouseButtom: number;
mouseX: number;
Copy link
Owner

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?

Copy link
Owner

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?

Comment on lines +34 to +36
let magnifierResolution = 1;
let flagXSwapped = false;
let flagYSwapped = false;
Copy link
Owner

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.

Comment on lines +38 to +41
let isAnyKeyPressed = false;
export function setKeyPressed(value: boolean): void {
isAnyKeyPressed = value;
}
Copy link
Owner

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?

Comment on lines +8 to +11
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
Copy link
Owner

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?

Copy link
Owner

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
Copy link
Owner

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?

Comment on lines +23 to +30
/// 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;
Copy link
Owner

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?

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.

2 participants