Skip to content
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

Merged
merged 16 commits into from
Nov 8, 2018

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Oct 8, 2018

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):

  • https://___.webknossos.xyz

Steps to test:

  • Open a tracing an reset the layout. There should be no more whitespace between the viewports.
  • close all tracings, clear the local storage and then open a tracing. The default layout should not have any free space between the viewports.
  • There is a maximum width for the viewports, so that the right menu is always visible
  • Test this by resizing the window to a dimension where the height is greater than the width and the reset the layout. The right menu should be still visible.

Issues:


@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Oct 9, 2018

@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
Do you think a changelog entry is necessary? I don't think so, because these changes do not have a direct impact to the user.

@MichaelBuessemeyer MichaelBuessemeyer changed the title Added default layouts for wide screen windows Reduce the free space between viewports in tracing Oct 10, 2018
Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Nice! Works well and the code also looks good (except for the 500; see my other comment).

One thing though: There is still a noticable gap on my screen. Could it be that the height of the tab title has to be used during the calculation?

image

const unmemoizedGetDefaultLayouts = () => {
let { height, width } = getGroundTruthLayoutRect();
// prevent default height and width
if (height === 500 && width === 500 && window.innerWidth) {
Copy link
Member

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.

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Oct 14, 2018

@philippotto
I applied the feedback of you but while doing so I ran into two kinda strange bug/errors:
The first is an error by flow, that appears when trying to export the headerHeight from tracing_layout_view. The actual trigger for this error is importing the constant to default_layout_configs.
The error thrown, says that the children of NmlUploadZoneContainer are not of the same type. 1.
2..
For a quickfix I move the constant into the Constants.js

The second error appeared with the new way of handling the default-layouts: Importing default_layout_configs.js into the store increases the "load/compile-time" => the time until the actual store object is available. But other modules like the test modules do not wait for this. This creates a lot of testing errors. Removing the defaultLayoutSchema from the default state of the store and also removing the whole import solves the problem. So I just set the layouts to an empty object.
The Problem: The same error appears in layout_persistence when directly trying to load the stored layouts with: Store.dispatch(setStoredLayoutsAction(readStoredLayoutConfigs()));. Here I added a timeout as a quick workaround.

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 🙂 ?

@MichaelBuessemeyer
Copy link
Contributor Author

@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);
Copy link
Member

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?

Copy link
Contributor Author

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.minto Math.max.
Or do you @philippotto think that a minimum width is not needed?

Copy link
Contributor Author

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);
Copy link
Member

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 = () => {
Copy link
Member

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.

Copy link
Contributor Author

@MichaelBuessemeyer MichaelBuessemeyer Oct 25, 2018

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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,
Copy link
Member

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();
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current version of getGroundTruthLayoutRectguarantees 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 ...

@MichaelBuessemeyer
Copy link
Contributor Author

@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 tracing_layout_view in default_layout_configs. So I moved headerHeight into default_layout_configs but I do not like the idea. Do you have an suggestions where to put it?

Maybe add a new constant to Constants.js that has all needed constants for the layouting stored?

@philippotto
Copy link
Member

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:

  • create a new layout "test"
  • customize it
  • switch layout to default
  • switch back to "test" layout <-- this layout looks exactly like the default layout and misses my customizations

@MichaelBuessemeyer
Copy link
Contributor Author

@philippotto fixed it 😄 🎉

Copy link
Member

@philippotto philippotto left a 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.

@fm3 fm3 added the Epic label Nov 5, 2018
@MichaelBuessemeyer MichaelBuessemeyer merged commit 67ce04c into master Nov 8, 2018
@daniel-wer daniel-wer deleted the add-default-wide-screen-layout branch November 9, 2018 14:46
@daniel-wer daniel-wer mentioned this pull request Nov 9, 2018
1 task
jfrohnhofen added a commit that referenced this pull request Nov 22, 2018
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce gaps in default layout by using window dimensions in definition
3 participants