Skip to content

calc: center minus/plus symbols and level numbers in group boxes#15177

Merged
pedropintosilva merged 1 commit intomainfrom
private/banobepascal/group-icons
Apr 2, 2026
Merged

calc: center minus/plus symbols and level numbers in group boxes#15177
pedropintosilva merged 1 commit intomainfrom
private/banobepascal/group-icons

Conversation

@banobepascal
Copy link
Copy Markdown
Contributor

Change-Id: I752f6a0a5eed762d83e680c2da1ab06b3fabde3c

Summary

  • The plus and minus symbols inside the row and column group boxes were not visually centered because their line endpoints were uneven. The drawing logic used 25% and 75% of the box size, but the end coordinate had an extra app.roundedDpiScale, which pushed the line too far on one side. Removing that extra offset makes the padding even on both sides and centers the symbols properly.

  • The level numbers in the header boxes also appeared slightly off vertically. Although the text is drawn with textBaseline = 'middle', the previous offset of + 2 * app.dpiScale pushed the numbers too far from the visual center. Reducing it to + app.dpiScale reuslting in better alignment without over adjusting.

PREVIEW

2026-03-24_04-19

@pedropintosilva
Copy link
Copy Markdown
Contributor

I love it, it looks much better!

@mmeeks
Copy link
Copy Markdown
Contributor

mmeeks commented Mar 24, 2026

Looks good, but please make sure you're testing this at eg. 125% zoom - never at just 100% :-)

While we are here, the vertical centering of the text is also really un-necessarily ugly:
image

Seems we also have some un-helpful offset in the row headings too:

image

If we have to err very slightly here, conventional wisdom suggests it is better to be ever so marginally above vertical center.

@banobepascal banobepascal force-pushed the private/banobepascal/group-icons branch 2 times, most recently from b2a4d8d to f36f14c Compare March 26, 2026 13:00
@banobepascal
Copy link
Copy Markdown
Contributor Author

banobepascal commented Mar 26, 2026

If we have to err very slightly here, conventional wisdom suggests it is better to be ever so marginally above vertical center.

Before the level numbers would also overflow the group boxes when the font is adjusted in the browser settings

For example this was at browser font Very large (24px)

2026-03-26_18-16

This PR addresses the above overflow issue by adjusting the positioning of the level numbers so they remain within the group boxes. The numbers are now positioned slightly above the vertical center, which provides better visual balance and avoids clipping at larger font sizes.

Browser font size: Very large (24px) at zoom level 125%)

2026-03-26_18-28

Browser font size: medium (9px) at zoom level 125%

2026-03-26_18-26

Browser font size: Very small (9px) at zoom level 175%

2026-03-26_18-11

cc @eszkadev

this.context.beginPath();
this.context.fillStyle = this.backgroundColor;
this.context.fillRect(this.transformRectX(startX, this._groupHeadSize), startY, this._groupHeadSize, this._groupHeadSize);
this.context.strokeStyle = 'black';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems we are using hardcoded color here^ which leads to:

Image

we should leverage what we already have from getColors(); on a second thought I wonder if even that conditional should be updated so to use css vars (let's postpone this for another discussion/PR)

@github-project-automation github-project-automation Bot moved this from To Review to In Progress in Collabora Online Mar 30, 2026
@pedropintosilva
Copy link
Copy Markdown
Contributor

pedropintosilva commented Mar 30, 2026

Additionally we seem to have some sub-pixel anti-aliasing artifact on Y axis which leads to the perceived blurriness:

image

The screenshot was taken in chrome with browser zoom at 200% and in RTL (&lang=ar)

(I have added pixel grid and decrease highlight values in GIMP so it's easier to perceive)

Notice, the neighbor gray pixel appears (on the left edge) one pixel above the minus line; And (on the right edge) one pixel above and one pixel bellow the minus line.

maybe something to do with the offset ?

// Control.GroupBase.ts:270-271:                                                                                                                           
                                                                                                                                                             
  this.context.moveTo(startX + 0.5 + this._groupHeadSize * 0.25, startY + 0.5 + this._groupHeadSize / 2);                                                    
  this.context.lineTo(startX + 0.5 + this._groupHeadSize * 0.75, startY + 0.5 + this._groupHeadSize / 2);

@banobepascal banobepascal force-pushed the private/banobepascal/group-icons branch from f36f14c to 6dbb036 Compare March 31, 2026 00:11
@pedropintosilva
Copy link
Copy Markdown
Contributor

pedropintosilva commented Mar 31, 2026

Thanks @banobepascal the dark mode is now fixed and the minus is now without artifacts

image

but the plus seems to still have half px up and half px down

Edit the vertical stroke of the + uses bare startY + ... without the + 0.5 offset that the horizontal stroke has. Shouldn't it be:
this.context.moveTo(startX + 0.5 + this._groupHeadSize / 2, startY + 0.5 + this._groupHeadSize * 0.25);
this.context.lineTo(startX + 0.5 + this._groupHeadSize / 2, startY + 0.5 + this._groupHeadSize * 0.75);

?

@banobepascal banobepascal force-pushed the private/banobepascal/group-icons branch from 6dbb036 to 0bd908b Compare March 31, 2026 10:14
@banobepascal
Copy link
Copy Markdown
Contributor Author

but the plus seems to still have half px up and half px down

Edit the vertical stroke of the + uses bare startY + ... without the + 0.5 offset that the horizontal stroke has. Shouldn't it be: this.context.moveTo(startX + 0.5 + this._groupHeadSize / 2, startY + 0.5 + this._groupHeadSize * 0.25); this.context.lineTo(startX + 0.5 + this._groupHeadSize / 2, startY + 0.5 + this._groupHeadSize * 0.75);

?

Thanks Pedro, the missing + 0.5 offset was causing the half pixel anti-aliasing artifact on Y axis . I’ve added it, and the stroke now aligns cleanly within the pixel boundaries.

200% zoom Chrome

2026-03-31_13-30

@pedropintosilva pedropintosilva self-requested a review March 31, 2026 18:10
Copy link
Copy Markdown
Contributor

@pedropintosilva pedropintosilva left a comment

Choose a reason for hiding this comment

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

Needs another +1

@github-project-automation github-project-automation Bot moved this from In Progress to To Test in Collabora Online Mar 31, 2026
 - The plus/minus symbol and box drawing code was duplicated between
   ColumnGroup and RowGroup. Move it into a shared drawGroupBoxes method
   in GroupBase to eliminate the duplication.

 - The connector lines between group heads and tail markers used lineWidth
   2.0, which looked thick relative to the 1px box strokes. Change them
   to lineWidth 1.0 and align coordinates to the pixel grid with +0.5
   offsets so they render as crisp single-pixel lines.

 - The level number vertical position used a fixed 2*dpiScale offset that
   did not account for varying box sizes. Replace it with ctrlHeadSize/1.9
   so the text sits closer to the true visual center of the box.

 - Fix canvas anti-aliasing (blurring)  on outline group +/- icons

Signed-off-by: Banobe Pascal <banobe.pascal@collabora.com>
Change-Id: Id52679b46e397db7293617f532b213795c3e25e6
@mohit-marathe mohit-marathe force-pushed the private/banobepascal/group-icons branch from 0bd908b to 6adde60 Compare April 1, 2026 04:32
Copy link
Copy Markdown
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

New look is better. I think drawGroupBoxes is centralized and the other changes are visual. Looks good to me thank you.

@pedropintosilva pedropintosilva merged commit fcf317f into main Apr 2, 2026
17 checks passed
@pedropintosilva pedropintosilva deleted the private/banobepascal/group-icons branch April 2, 2026 13:38
@github-project-automation github-project-automation Bot moved this from To Test to Done in Collabora Online Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants