Skip to content

applets/taskmanager: Fix layout count for multiple rows/columns

Ismael Asensio requested to merge work/iasensio/tasks-multirow into master

The previous calculations for the number of rows and columns of the task grid layout implicitly assumed that the full stripes or lines would be full, which led to incorrect sizing.

We do a small refactor to depend less on the orientation and commonalize the horizontal and vertical cases as much as possible, so the algorithm is more straightforward.

  1. First calculate the effective number of "stripes" (that is the multiple rows or columns in which the grid will be arranged). This depends on the user preferences but it's also limited by the applet's size and the number of tasks.
  2. Then calculate the other dimension of the grid, dividing the number of tasks by the effective stripes. This arranges the tasks evenly and fixes the sizing of the grid layout.
  3. Finally assign each dimension to rows or columns depending on the orientation

I've tested this with the different options for a different number of maximum rows and tasks.

The icon size is now a bit broken (both in master and here after !2239 (merged)) for the multirow case, but it's unrelated. The introduced property stripeCount might be handy for this sort of things.

BEFORE AFTER
Screenshot_20240510_100056 Screenshot_20240511_043749
Screenshot_20240510_100106 Screenshot_20240511_043804
Screenshot_20240510_100114 Screenshot_20240511_043914
Screenshot_20240510_101126 Screenshot_20240511_043920

Merge request reports

Loading