-
Notifications
You must be signed in to change notification settings - Fork 24
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
Reduce the free space between viewports in tracing #3333
Conversation
…usted to current window aspact ratio
@philippotto I removed all changes and added the requested viewport width adjustment to the default layout. So this PR should be ready for a review. Edit |
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.
const unmemoizedGetDefaultLayouts = () => { | ||
let { height, width } = getGroundTruthLayoutRect(); | ||
// prevent default height and width | ||
if (height === 500 && width === 500 && window.innerWidth) { |
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.
Can we avoid these magic numbers? Two possible solutions:
- getGroundTruthLayoutRect either returns the proper height/width or null (but never the dummy values of 500). then, other callers of getGroundTruthLayoutRect would need to check for null and then use the 500 fallback value if this makes sense
- or: use window.innerWidth etc. inside getGroundTruthLayoutRect as a fallback. However, we have to be careful here, since the layout is a bit fickle during initialization. if the rect is too large, it can happen that the layout is initialized too big and that scrollbars screw up the correct dimensions. this is why, I'd go with the first option.
@philippotto The second error appeared with the new way of handling the default-layouts: Importing In both cases I don't think my solution is very good. So can we talk about this next time we see each other at office 🙂 ? |
@philippotto I resolved the circular imports and also adjusted the width evaluation to the height of the viewport layouts (removed the header height from the evaluation) => This PR should be ready for another review. |
const unmemoizedGetDefaultLayouts = () => { | ||
const layoutContainer = getGroundTruthLayoutRect(); | ||
layoutContainer.height -= layoutHeaderHeight * 2; | ||
const viewportWidth = Math.min(((layoutContainer.height / 2) * 100) / layoutContainer.width, 40); |
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.
Where is the 40 coming from?
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.
The idea behind it, is that i want the viewport to have at least a width of 40px. I put the 40 into a constant and changed Math.min
to Math.max
.
Or do you @philippotto think that a minimum width is not needed?
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.
Ah wait, having a close look at the case, where the minimum would apply tells me that this idea is nonsense 🙂
const unmemoizedGetDefaultLayouts = () => { | ||
const layoutContainer = getGroundTruthLayoutRect(); | ||
layoutContainer.height -= layoutHeaderHeight * 2; | ||
const viewportWidth = Math.min(((layoutContainer.height / 2) * 100) / layoutContainer.width, 40); |
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.
Where is the 40 coming from?
type ExtractReturn<Fn> = $Call<<T>(() => T) => T, Fn>; | ||
type Layout = $Keys<ExtractReturn<typeof unmemoizedGetDefaultLayouts>>; | ||
|
||
export const getDefaultLayoutSchema = () => { |
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.
I'm not sure Schema
is the best word choice here. How about Config
?
Also, I think it would be better if the function name also reflected that it resets the default layouts.
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 do you think of getCurrentDefaultLayoutConfig
?
const { width } = getGroundTruthLayoutRect(); | ||
let { width } = getGroundTruthLayoutRect(); | ||
if (width === undefined) { | ||
width = 500; |
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.
Now, the 500
is scattered around in this file. Can you extract it into a dummyExtent
variable?
const { width } = getGroundTruthLayoutRect(); | ||
let { width } = getGroundTruthLayoutRect(); | ||
if (width === undefined) { | ||
width = 500; |
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.
Now, the 500
is scattered around in this file. Can you extract it into a dummyExtent
variable?
const { width } = getGroundTruthLayoutRect(); | ||
let { width } = getGroundTruthLayoutRect(); | ||
if (width === undefined) { | ||
width = 500; |
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.
Now, the 500
is scattered around in this file. Can you extract it into a minimumExtent
variable?
} | ||
// migrate to newset schema | ||
const withMulipleLayoutsSchema = { | ||
OrthoLayoutView: { | ||
"Custom Layout": layouts.OrthoLayoutView || defaultLayouts.OrthoLayoutView, | ||
"Custom Layout": layouts.OrthoLayoutView || getDefaultLayouts().OrthoLayoutView, |
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.
Please store getDefaultLayouts()
in a variable (above line 40) and use that within the four occurrences here (I know, that the method call is memoized, but this is not clear to the reader of this function and also this might change in the future).
@@ -66,7 +62,11 @@ const updateSizeForGl = gl => { | |||
if (!container) { | |||
return; | |||
} | |||
const { width, height } = getGroundTruthLayoutRect(); | |||
let { width, height } = getGroundTruthLayoutRect(); |
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.
I'd create a function "castOptionalExtent" which takes width and height and turns them into 500 if they are undefined. So that you can write: const { width, height } = castOptionalExtent(getGroundTruthLayoutRect());
. This pattern can be used at the multiple places, too.
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.
The current version of getGroundTruthLayoutRect
guarantees to return a valid width
and height
(that is 500 when every way of determining the bounds failed). So there is no need to handle this anymore. I think I had already removed the checks like in line 52, but I think I was wrong ...
@philippotto Could you please have a look at the changes I commited and the comments I wrote. I also found another circular import that is causing errors. The key here is to not import Maybe add a new constant to |
I just tested your PR here (https://adddefaultwidescreenlayout.webknossos.xyz/datasets/Connectomics_Department/2017-05-31_mSEM_scMS109_bk_100um_v01/view#41472,18944,1536,0,1.30) and the reduction of whitespace seems to work pretty well! However, the stored layouts seem to reset for me? Steps to reproduce:
|
@philippotto fixed it 😄 🎉 |
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.
Nice 👍 This will be a valuable improvement for the users.
* master: Fix rgb support (#3455) Fix docker uid/gid + binaryData permissions. Persist postgres db (#3428) Script to merge volume tracing into on-disk segmentation (#3431) Hotfix for editing TaskTypes (#3451) fix keyboardjs module (#3450) Fix guessed dataset boundingbox for non-zero-aligned datasets (#3437) voxeliterator now checks if the passed map has elements (#3405) integrate .importjs (#3436) Re-write logic for selecting zoom level and support non-uniform buckets per dimension (#3398) fixing selecting bug and improving style of layout dropdown (#3443) refresh screenshots (#3445) Reduce the free space between viewports in tracing (#3333) Scala linter and formatter (#3357) ignore reported datasets of non-existent organization (#3438) Only provide shortcut for tree search and not for comment search (#3407) Update Datastore+Tracingstore Standalone Deployment Templates (#3424) In yarn refresh-schema, also invalidate Tables.scala (#3430) Remove BaseDirService that watched binaryData symlinks (#3416) Ensure that resolutions array is dense (#3406) Fix bucket-collection related rendering bug (#3409)
This PR adjusts the default width of a layout container of a viewport to its height so that there will be no more unused whitespace.
URL of deployed dev instance (used for testing):
Steps to test:
Issues:
[ ] Updated changelog[ ] Updated migration guide if applicable[ ] Updated documentation if applicable[ ] Needs datastore update after deployment