Fix scalebar position#637
Conversation
|
Is it necessary to have both the pixel and % option? I would use percentage in most cases, because I don't need to change it when resizing the image. What would be a good use case for pixel? If there's no good reason for it, I'd keep the % only, because the UI gets crowded. With the colorbar coming, adding more lines means that a scrollbar would appear. Without the option, it could fit in the line above. with this diff (I did not took care of the logic behind between % and pixel) diff --git a/src/templates/scalebar_form.template.html b/src/templates/scalebar_form.template.html
index 83028407..cc390136 100644
--- a/src/templates/scalebar_form.template.html
+++ b/src/templates/scalebar_form.template.html
@@ -17,7 +17,7 @@
<form class="scalebar_form">
<div class="row gy-2 gx-3 align-items-center" style="--bs-gutter-x: 0.3rem;">
<div class="col-auto input-group-sm">
- <label class="col-form-label col-form-label-sm" style="width:50px">Length</label>
+ <label class="col-form-label col-form-label-sm" style="width:40px">Length</label>
</div>
<div class="col-auto input-group-sm">
<input type="number" class="scalebar-length input-sm form-control"
@@ -107,24 +107,38 @@
<% } %>
</div>
</div>
+
<div class="row gy-2 gx-3 align-items-center" style="--bs-gutter-x: 0.3rem;">
<div class="col-auto input-group-sm">
- <label class="col-form-label col-form-label-sm" style="width:50px">Height</label>
+ <label class="col-form-label col-form-label-sm" style="width:40px">Height</label>
</div>
<div class="form-group col-auto scalebar_length input-group-sm">
<input type="number" class="label-text scalebar-height form-control input-sm"
- placeholder="Height" value="<%= height %>" style="width:52px" />
+ placeholder="Height" value="<%= height %>" style="width:35px" />
</div>
- <div class="col-auto input-group-sm" style="margin-right: 10px;">
+ <div class="col-auto input-group-sm" style="margin-right: 5px;">
<label class="col-form-label col-form-label-sm">px</label>
</div>
+
+
+ <div class="col-auto input-group-sm">
+ <label class="col-form-label col-form-label-sm" style="width:50px; padding-left: 5px;">Margin</label>
+ </div>
+ <div class="form-group col-auto scalebar_length input-group-sm">
+ <input type="number" class="label-text scalebar-margin form-control input-sm"
+ placeholder="Margin" value="<%= margin %>" style="width:35px" />
+ </div>
+ <div class="col-auto input-group-sm" style="margin-right: 2px;">
+ <label for="percentage" class="col-form-label col-form-label-sm">%</label>
+ </div>
+
<div class="col-auto input-group-sm">
<label class="form-check-label">Label</label>
<input type="checkbox" class="scalebar_label form-check-input" <% if (show_label) print("checked") %> />
</div>
- <div class="col-auto btn-group" style="padding: 0; width: 50px;">
+ <div class="col-auto btn-group" style="padding: 0; width: 40px;">
<button type="button" class="scalebar_font_size btn btn-outline-secondary btn-sm dropdown-toggle" title="Font Size"
data-bs-toggle="dropdown" style="width:33px; <% if (!show_label) print("display:none") %>">
<span class='dropdown_icon'><%= font_size %></span>
@@ -141,30 +155,4 @@
</div>
</div>
- <div class="row gy-2 gx-3 align-items-center" style="--bs-gutter-x: 0.3rem;">
- <div class="col-auto input-group-sm">
- <label class="col-form-label col-form-label-sm" style="width:50px">Margin</label>
- </div>
- <div class="form-group col-auto scalebar_length input-group-sm">
- <input type="number" class="label-text scalebar-margin form-control input-sm"
- placeholder="Margin" value="<%= margin %>" style="width:52px" />
- </div>
-
- <div class="col-auto input-group-sm">
- <input type="radio" name="scalebar-margin-unit" id="pixel" class="scalebar_margin_unit"
- value="px" <% if (margin_unit == "px") print("checked") %>/>
- </div>
- <div class="col-auto input-group-sm" style="margin-right: 10px;">
- <label for="pixel" class="col-form-label col-form-label-sm">px</label>
- </div>
- <div class="col-auto input-group-sm">
- <input type="radio" name="scalebar-margin-unit" id="percentage" class="scalebar_margin_unit"
- value="%" <% if (margin_unit == "%") print("checked") %>/>
- </div>
- <div class="col-auto input-group-sm" style="margin-right: 10px;">
- <label for="percentage" class="col-form-label col-form-label-sm">%</label>
- </div>
-
- </div>
-
</form>We could also wait for the colorbar PR to be merged and refine the UI then. |
Beacuse of this example. Different parts of tissues are used in insets, same magnification and same height, to have a nice layout at the end. Users are expected to have the scalebar at the same position as well. For that, I think the pixel option is necessary. |
|
Thanks for your work on this. I think that we could ONLY support |
|
Hi, I try to make things fitting in two lines, but it looks a bit squeezed.
I gave the choice between px and % in order to be backward compatible. But maybe we'll have to remove % to make UI nicer... I don't know what is the best solution here. Rémy. |
|
The Margin input needs to be larger, two digits isn't fitting. With pixels I could expect values larger than 100. I played around with the CSS. The main change is the flex display for the radio buttons. The left and right margin & padding set to 0 is to get the "units" closer to the input fields, so I could make the Margin input field larger with more space on the left of "Margin" label diff --git a/src/templates/scalebar_form.template.html b/src/templates/scalebar_form.template.html
index b915cbc0..b7399a9d 100644
--- a/src/templates/scalebar_form.template.html
+++ b/src/templates/scalebar_form.template.html
@@ -107,7 +107,7 @@
<% } %>
</div>
</div>
- <div class="row gy-2 gx-3 align-items-center" style="--bs-gutter-x: 0.3rem;">
+ <div class="row gy-2 gx-3 align-items-center" style="--bs-gutter-x: 0.3rem; margin-top: 0px;">
<div class="col-auto input-group-sm">
<label class="col-form-label col-form-label-sm" style="width:40px">Height</label>
</div>
@@ -115,28 +115,30 @@
<input type="number" class="label-text scalebar-height form-control input-sm"
placeholder="Height" value="<%= height %>" style="width:30px" />
</div>
- <div class="col-auto input-group-sm" style="margin-right: 5px;">
+ <div class="col-auto input-group-sm" style="margin-right: 0px; padding-left: 0px;">
<label class="col-form-label col-form-label-sm">px</label>
</div>
- <div class="col-auto input-group-sm">
+ <div class="col-auto input-group-sm" style="margin-left: 6px;">
<label class="col-form-label col-form-label-sm" style="width:40px">Margin</label>
</div>
<div class="form-group col-auto scalebar_length input-group-sm">
<input type="number" class="label-text scalebar-margin form-control input-sm"
- placeholder="Margin" value="<%= margin %>" style="width:30px" />
+ placeholder="Margin" value="<%= margin %>" style="width:38px; padding-left: 3px; padding-right: 3px;" />
</div>
- <div class="col-auto input-group-sm">
- <input type="radio" name="scalebar-margin-unit" id="pixel" style="vertical-align: bottom;" class="scalebar_margin_unit"
- value="px" <% if (margin_unit == "px") print("checked") %>/>
- <label for="pixel" class="col-form-label col-form-label-sm" style="margin-bottom: -5px;">px</label><br/>
- <input type="radio" name="scalebar-margin-unit" id="percentage" style="vertical-align: top;" class="scalebar_margin_unit"
- value="%" <% if (margin_unit == "%") print("checked") %>/>
- <label for="percentage" class="col-form-label col-form-label-sm" style="vertical-align: top; margin-top: -8px; font-size: 12px;">%</label><br/>
+ <div class="col-auto input-group-sm" style="display: flex; align-items: center; gap: 0px; flex-direction: column; align-items: flex-start; padding-left: 0px;">
+ <div style="display: flex; align-items: center;">
+ <input type="radio" name="scalebar-margin-unit" id="pixel" class="scalebar_margin_unit" value="px" <% if (margin_unit == "px") print("checked") %> />
+ <label for="pixel" class="col-form-label col-form-label-sm" style="font-size: 13px; margin-bottom: 0; margin-right: 5px; padding: 0px"> px</label>
+ </div>
+ <div style="display: flex; align-items: center;">
+ <input type="radio" name="scalebar-margin-unit" id="percentage" class="scalebar_margin_unit" value="%" <% if (margin_unit == "%") print("checked") %> />
+ <label for="percentage" class="col-form-label col-form-label-sm" style="font-size: 12px; margin-bottom: 0; padding: 0px"> %</label>
+ </div>
</div>
- <div class="col-auto input-group-sm">
+ <div class="col-auto input-group-sm" style="padding-left: 0px;">
<label class="form-check-label">Label</label>
<input type="checkbox" class="scalebar_label form-check-input" <% if (show_label) print("checked") %> />
</div>
@@ -153,7 +155,7 @@
}); %>
</ul>
</div>
- <div class="form-group col-auto scalebar_text" style="padding-left: 2px;">
+ <div class="form-group col-auto scalebar_text" style="padding-left: 0px;">
<% if (show_label) print("pt") %>
</div>
</div> |
|
Thanks @Tom-TBT for reviewing. |
| </div> | ||
| <div class="form-group col-auto scalebar_length input-group-sm"> | ||
| <input type="number" class="label-text scalebar-margin form-control input-sm" | ||
| placeholder="Margin" value="<%= margin %>" style="width:38px; padding-left: 3px; padding-right: 3px;" /> |
|
Apologies for the delayed response. I also just read the comments above and see that @Tom-TBT asked for the Margin input to allow for 3 or more digits! |
|
Do we want to keep the We could get around the backwards compatibility issue by calculating the The only minor issue I see is if you have a bunch of different sized panels that were previously all Ah - I just tried that and there's a bug (not coming from this PR) that I think I've noticed before... |
|
Hi @will-moore Thanks for your inputs.
I reduce a bit the input size to keep 3 digits instead of 4.
Sounds like a good idea but I wasn't able to separate the different attributes. There is a form that is submitted for scalebar lenght, color, position and height and the
From my side, we can keep px unit only and implement the trick you describe to be backward compatible but this is a subjective opinion. I don't see scenario where % is necessary but maybe @Tom-TBT can add more inputs on that, as he was more in favor of % than px. |
|
Conflicting PR. Removed from build OMERO-plugins-push#491. See the console output for more details.
--conflicts |
|
Conflicting PR. Removed from build OMERO-plugins-push#531. See the console output for more details.
--conflicts |
|
Conflicting PR. Removed from build OMERO-plugins-push#541. See the console output for more details.
--conflicts |
|
@Tom-TBT Do you have a strong feeling on whether we need to keep I think I'm generally in favour of doing the simplest thing, instead of trying to support all possible usages. Supporting more options leads to more complex UI etc, which makes it harder for users and developers. If we can just support
I think I prefer the 2nd option. The default number will also be the margin for all new scalebars. Then, ALL scalebars will be consistently aligned by default, addressing the main issue above. And users can easily choose a different margin if they want. Thoughts? |
|
Sorry I missed on replying to Rémy. No I'm not strongly in favour of keeping Then there's good and bad in both implementation you suggest. But setting it 10px makes it less confusing than an "random" & panel-dependant value. |
|
Ok sounds good for me 👍 . Let's just remove |
|
Should be done. Please tell me if everything works correctly. Thanks: |
| } | ||
| if (p.scalebar && !p.scalebar.margin_unit) { | ||
| p.scalebar.margin_unit = '%'; | ||
| p.scalebar.margin = 10; |
There was a problem hiding this comment.
I think !p.scalebar.margin should instead check if p.scalebar.margin == undefined because I think if the margin is 0 then !p.scalebar.margin will be True (assuming 0 is a valid margin)
There was a problem hiding this comment.
Ok, but shouldn't we do the same also with scalebar height (line 284) ?
There was a problem hiding this comment.
Hmmm - possibly, although you could argue that a scalebar height of 0 is not valid, whereas a margin of 0 is possibly valid (but still unlikely).
There was a problem hiding this comment.
Ah I see... fair enough. Let's correct only the margin
| json.height = json.height || 3; | ||
| json.margin = json.margin || 5; | ||
| json.margin_unit = json.margin_unit || '%'; | ||
| json.margin = json.margin || 10; |
There was a problem hiding this comment.
Also this won't support a margin of 0;
I think you want json.margin = json.margin ?? 10; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing
| "margin": 5, | ||
| "margin_unit": "%" | ||
| "margin": 10, | ||
| "margin_unit": "px" |
There was a problem hiding this comment.
Don't think we need margin_unit anywhere now
There was a problem hiding this comment.
Yes, you're right. I forget to check this file.
| sb_json.length = sb.length; | ||
| sb_json.height = sb.height; | ||
| sb_json.margin = sb.margin; | ||
| sb_json.margin_unit = sb.margin_unit; |
There was a problem hiding this comment.
Don't need margin_unit here now?
|
Conflicting PR. Removed from build OMERO-plugins-push#542. See the console output for more details.
--conflicts |
|
Conflicting PR. Removed from build OMERO-plugins-push#584. See the console output for more details.
|
|
Conflicting PR. Removed from build OMERO-plugins-push#593. See the console output for more details.
--conflicts |
|
Conflicting PR. Removed from build OMERO-plugins-push#1. See the console output for more details.
|
…o fix-scalebar-position
…mero-figure into fix-scalebar-position
|
Conflicts are fixed. |
will-moore
left a comment
There was a problem hiding this comment.
Testing on new merge-ci after conflicts resolved. Looking good, thanks.






Fixes #613
The margin can be set by the user (default 5%), as well as the unit (% or pixel)