Skip to content

Commit 1593d86

Browse files
committed
Return Point.OfFloat in Label:computeSize
This commit adapts Label to return Point.OfFloat object on Label:computeSizeInPixels ultimately returning Point.OfFloat on calling Label:computeSize. This allows precise scaling of Label by its parents. contributes to #2166
1 parent 7653450 commit 1593d86

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ public final class GridData {
399399
public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL;
400400

401401
float cacheWidth = -1, cacheHeight = -1;
402-
float defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1;
403-
float currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
402+
int defaultWhint, defaultHhint, currentWhint, currentHhint;
403+
float defaultWidth = -1, defaultHeight = -1, currentWidth = -1, currentHeight = -1;
404404

405405
/**
406406
* Constructs a new instance of GridData using

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -334,25 +334,19 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
334334
if (w > 0) {
335335
if (makeColumnsEqualWidth) {
336336
float equalWidth = (w + spanWidth) / hSpan;
337-
float remainder = (w + spanWidth) % hSpan;
338-
int last = -1;
339337
for (int k = 0; k < hSpan; k++) {
340-
widths [last=j-k] = Math.max (equalWidth, widths [j-k]);
338+
widths [j-k] = Math.max (equalWidth, widths [j-k]);
341339
}
342-
if (last > -1) widths [last] += remainder;
343340
} else {
344341
if (spanExpandCount == 0) {
345342
widths [j] += w;
346343
} else {
347344
float delta = w / spanExpandCount;
348-
float remainder = w % spanExpandCount;
349-
int last = -1;
350345
for (int k = 0; k < hSpan; k++) {
351346
if (expandColumn [j-k]) {
352-
widths [last=j-k] += delta;
347+
widths [j-k] += delta;
353348
}
354349
}
355-
if (last > -1) widths [last] += remainder;
356350
}
357351
}
358352
}
@@ -364,14 +358,11 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
364358
minWidths [j] += w;
365359
} else {
366360
float delta = w / spanExpandCount;
367-
float remainder = w % spanExpandCount;
368-
int last = -1;
369361
for (int k = 0; k < hSpan; k++) {
370362
if (expandColumn [j-k]) {
371-
minWidths [last=j-k] += delta;
363+
minWidths [j-k] += delta;
372364
}
373365
}
374-
if (last > -1) minWidths [last] += remainder;
375366
}
376367
}
377368
}
@@ -434,14 +425,11 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
434425
widths [j] += w;
435426
} else {
436427
float delta2 = w / spanExpandCount;
437-
float remainder2 = w % spanExpandCount;
438-
int last2 = -1;
439428
for (int k = 0; k < hSpan; k++) {
440429
if (expandColumn [j-k]) {
441-
widths [last2=j-k] += delta2;
430+
widths [j-k] += delta2;
442431
}
443432
}
444-
if (last2 > -1) widths [last2] += remainder2;
445433
}
446434
}
447435
}
@@ -547,14 +535,11 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
547535
heights [i] += h;
548536
} else {
549537
float delta = h / spanExpandCount;
550-
float remainder = h % spanExpandCount;
551-
int last = -1;
552538
for (int k = 0; k < vSpan; k++) {
553539
if (expandRow [i-k]) {
554-
heights [last=i-k] += delta;
540+
heights [i-k] += delta;
555541
}
556542
}
557-
if (last > -1) heights [last] += remainder;
558543
}
559544
}
560545
if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) {
@@ -565,14 +550,11 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
565550
minHeights [i] += h;
566551
} else {
567552
float delta = h / spanExpandCount;
568-
float remainder = h % spanExpandCount;
569-
int last = -1;
570553
for (int k = 0; k < vSpan; k++) {
571554
if (expandRow [i-k]) {
572-
minHeights [last=i-k] += delta;
555+
minHeights [i-k] += delta;
573556
}
574557
}
575-
if (last > -1) minHeights [last] += remainder;
576558
}
577559
}
578560
}
@@ -622,14 +604,11 @@ Point layout (Composite composite, boolean move, int x, int y, int width, int he
622604
heights [i] += h;
623605
} else {
624606
float delta2 = h / spanExpandCount;
625-
float remainder2 = h % spanExpandCount;
626-
int last2 = -1;
627607
for (int k = 0; k < vSpan; k++) {
628608
if (expandRow [i-k]) {
629-
heights [last2=i-k] += delta2;
609+
heights [i-k] += delta2;
630610
}
631611
}
632-
if (last2 > -1) heights [last2] += remainder2;
633612
}
634613
}
635614
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int checkStyle (int style) {
179179
if (hHint != SWT.DEFAULT) height = hHint;
180180
width += border * 2;
181181
height += border * 2;
182-
return new Point (width, height);
182+
return new Point.OfFloat (width, height);
183183
}
184184

185185
@Override

0 commit comments

Comments
 (0)