Skip to content

Commit cf4f710

Browse files
committed
Restored code that Jules removed, probably incorrectly
1 parent 8a115e2 commit cf4f710

File tree

3 files changed

+41
-34
lines changed

3 files changed

+41
-34
lines changed

CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2635,7 +2635,7 @@ protected boolean hasDragStarted(final int x, final int y) {
26352635
if (getCurrentForm() == null) {
26362636
return false;
26372637
}
2638-
if (dragActivationCounter <= 0) {
2638+
if (dragActivationCounter == 0) {
26392639
dragActivationX = x;
26402640
dragActivationY = y;
26412641
dragActivationCounter++;
@@ -7961,6 +7961,9 @@ public boolean isSimulator() {
79617961
* @param s the style object to draw
79627962
*/
79637963
public void paintComponentBackground(Object nativeGraphics, int x, int y, int width, int height, Style s) {
7964+
if (width <= 0 || height <= 0) {
7965+
return;
7966+
}
79647967
Image bgImageOrig = s.getBgImage();
79657968
if (bgImageOrig == null) {
79667969
if (s.getBackgroundType() >= Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL) {

CodenameOne/src/com/codename1/ui/Component.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,6 +3219,9 @@ protected Border getBorder() {
32193219
* @param g the component graphics
32203220
*/
32213221
void paintComponentBackground(Graphics g) {
3222+
if (isFlatten() || !opaque) {
3223+
return;
3224+
}
32223225
paintBackgroundImpl(g);
32233226
}
32243227

CodenameOne/src/com/codename1/ui/layouts/mig/Grid.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
package com.codename1.ui.layouts.mig;
2-
3-
import com.codename1.compat.java.util.Objects;
4-
import com.codename1.ui.Display;
5-
6-
import java.util.ArrayList;
7-
import java.util.Arrays;
8-
import java.util.Collection;
9-
import java.util.HashMap;
10-
import java.util.Iterator;
11-
import java.util.LinkedHashMap;
12-
import java.util.Map;
13-
import java.util.TreeSet;
141
/*
152
* License (BSD):
163
* ==============
@@ -45,6 +32,20 @@
4532
* Date: 2006-sep-08
4633
*/
4734

35+
package com.codename1.ui.layouts.mig;
36+
37+
import com.codename1.compat.java.util.Objects;
38+
import com.codename1.ui.Display;
39+
40+
import java.util.ArrayList;
41+
import java.util.Arrays;
42+
import java.util.Collection;
43+
import java.util.HashMap;
44+
import java.util.Iterator;
45+
import java.util.LinkedHashMap;
46+
import java.util.Map;
47+
import java.util.TreeSet;
48+
4849
/**
4950
* Holds components in a grid. Does most of the logic behind the layout manager.
5051
*/
@@ -197,12 +198,12 @@ public Grid(ContainerWrapper container, LC lc, AC rowConstr, AC colConstr, Map<?
197198
continue; // The "external" component should not be handled further.
198199
}
199200

200-
String sgX = rootCc.getHorizontal().getSizeGroup();
201-
if (sgX != null) {
201+
String sgX = rootCc.getHorizontal().getSizeGroup();
202+
if (sgX != null) {
202203
sizeGroupsX++;
203204
}
204-
String sgY = rootCc.getVertical().getSizeGroup();
205-
if (sgY != null) {
205+
String sgY = rootCc.getVertical().getSizeGroup();
206+
if (sgY != null) {
206207
sizeGroupsY++;
207208
}
208209

@@ -256,7 +257,7 @@ public Grid(ContainerWrapper container, LC lc, AC rowConstr, AC colConstr, Map<?
256257
}
257258
}
258259
} else {
259-
if (cx >= 0 || cy >= 0) {
260+
if (cx >= 0 && cy >= 0) {
260261
if (cy >= 0) {
261262
cellXY[0] = cx;
262263
cellXY[1] = cy;
@@ -290,7 +291,7 @@ public Grid(ContainerWrapper container, LC lc, AC rowConstr, AC colConstr, Map<?
290291
setCell(cellXY[1], cellXY[0], cell);
291292

292293
// Add a rectangle so we can know that spanned cells occupy more space.
293-
if (spanx != 1 || spany != 1) {
294+
if (spanx > 1 || spany > 1) {
294295
spannedRects.add(new int[]{cellXY[0], cellXY[1], spanx, spany});
295296
}
296297
}
@@ -1061,13 +1062,13 @@ private static synchronized void saveGrid(ComponentWrapper parComp, LinkedHashMa
10611062

10621063
ArrayList<WeakCell> weakCells = new ArrayList<WeakCell>(grid.size());
10631064

1064-
for (Map.Entry<Integer, Cell> entry : grid.entrySet()) {
1065-
Integer xyInt = entry.getKey();
1066-
Cell cell = entry.getValue();
1067-
if (xyInt != null) {
1068-
int x = xyInt & 0x0000ffff;
1069-
int y = xyInt >> 16;
1070-
1065+
for (Map.Entry<Integer, Cell> entry : grid.entrySet()) {
1066+
Integer xyInt = entry.getKey();
1067+
Cell cell = entry.getValue();
1068+
if (xyInt != null) {
1069+
int x = xyInt & 0x0000ffff;
1070+
int y = xyInt >> 16;
1071+
10711072
for (CompWrap cw : cell.compWraps) {
10721073
weakCells.add(new WeakCell(cw.comp.getComponent(), x, y, cell.spanx, cell.spany));
10731074
}
@@ -1501,11 +1502,11 @@ private void clearGroupLinkBounds() {
15011502
return;
15021503
}
15031504

1504-
for (Map.Entry<String, Boolean> entry : linkTargetIDs.entrySet()) {
1505-
if (Boolean.TRUE.equals(entry.getValue())) {
1506-
LinkHandler.clearBounds(container.getLayout(), entry.getKey());
1507-
}
1508-
}
1505+
for (Map.Entry<String, Boolean> entry : linkTargetIDs.entrySet()) {
1506+
if (Boolean.TRUE.equals(entry.getValue())) {
1507+
LinkHandler.clearBounds(container.getLayout(), entry.getKey());
1508+
}
1509+
}
15091510
}
15101511

15111512
private void resetLinkValues(boolean parentSize, boolean compLinks) {
@@ -1620,8 +1621,8 @@ private int[] getAbsoluteDimBounds(CompWrap cw, int refSize, boolean isHor) {
16201621

16211622
// If absolute, use those coordinates instead.
16221623
if (pos != null) {
1623-
UnitValue stUV = pos[isHor ? 0 : 1];
1624-
UnitValue endUV = pos[isHor ? 2 : 3];
1624+
UnitValue stUV = pos[isHor ? 0 : 1];
1625+
UnitValue endUV = pos[isHor ? 2 : 3];
16251626

16261627
int minSz = cw.getSize(LayoutUtil.MIN, isHor);
16271628
int maxSz = cw.getSize(LayoutUtil.MAX, isHor);

0 commit comments

Comments
 (0)