Skip to content

Commit

Permalink
Fixed background painting order for components. Previously the compon…
Browse files Browse the repository at this point in the history
…ent's parent's background would be painted over top of the component's siblings when painting its background. This caused some elements in the form layer pane to disappear during animations. Fixes #2564
  • Loading branch information
shannah committed Sep 28, 2018
1 parent 2d6d723 commit 0a6226e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ public void paintDirty() {
wrapper.setClip(dirty.getX(), dirty.getY(), d.getWidth(), d.getHeight());
cmp.setDirtyRegion(null);
}

cmp.paintComponent(wrapper);
getPaintableBounds(cmp, paintDirtyTmpRect);
int cmpAbsX = paintDirtyTmpRect.getX();
Expand Down
7 changes: 3 additions & 4 deletions CodenameOne/src/com/codename1/ui/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -2359,9 +2359,8 @@ private void drawPaintersImpl(com.codename1.ui.Graphics g, Component par, Compon
int transY = par.getAbsoluteY() + par.getScrollY();

g.translate(transX, transY);

((Container) par).paintIntersecting(g, c, x, y, w, h, false);



if (par.isBorderPainted()) {
Border b = par.getBorder();
if (b.isBackgroundPainter()) {
Expand All @@ -2386,6 +2385,7 @@ private void drawPaintersImpl(com.codename1.ui.Graphics g, Component par, Compon
p.paint(g, rect);
}
par.paintBackground(g);
((Container) par).paintIntersecting(g, c, x, y, w, h, false);
g.translate(-transX, -transY);
}

Expand Down Expand Up @@ -4978,7 +4978,6 @@ java.util.Set<Component> findNegativeScrolls(java.util.Set<Component> out) {
out.add(this);
}
if (this instanceof Container) {
System.out.println("Container: "+this+", scrollY="+getScrollY());
for (Component child : (Container)this) {
child.findNegativeScrolls(out);
}
Expand Down
2 changes: 0 additions & 2 deletions CodenameOne/src/com/codename1/ui/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,6 @@ void paintGlassImpl(Graphics g) {
}

void paintIntersecting(Graphics g, Component cmp, int x, int y, int w, int h, boolean above) {

if (layout.isOverlapSupported() && components.contains(cmp)) {
int indexOfComponent = components.indexOf(cmp);

Expand All @@ -1644,7 +1643,6 @@ void paintIntersecting(Graphics g, Component cmp, int x, int y, int w, int h, bo
endIndex = indexOfComponent;
}

int size = components.size();
for (int i = startIndex; i < endIndex; i++) {
Component cmp2 = (Component) components.get(i);
if(Rectangle.intersects(x, y, w, h,
Expand Down
1 change: 0 additions & 1 deletion CodenameOne/src/com/codename1/ui/Form.java
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,6 @@ boolean moveScrollTowards(int direction, Component c) {
*/
void fixNegativeScrolls() {
java.util.Set<Component> negativeScrolls = getContentPane().findNegativeScrolls(new java.util.HashSet<Component>());
System.out.println("NegativeScrolls: "+negativeScrolls);
for (Component cmp : negativeScrolls) {
int x = cmp.getAbsoluteX()+cmp.getWidth()/2;
int y = cmp.getAbsoluteY()+cmp.getHeight()/2;
Expand Down
8 changes: 8 additions & 0 deletions CodenameOne/src/com/codename1/ui/layouts/BorderLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,14 @@ public Component getEast() {
public Component getWest() {
return getComponentImpl(portraitWest, WEST);
}

/**
* Returns overlay component.
* @return The overlay component.
*/
public Component getOverlay() {
return overlay;
}

/**
* {@inheritDoc}
Expand Down

0 comments on commit 0a6226e

Please sign in to comment.