Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions CodenameOne/src/com/codename1/ui/Sheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,41 @@ public void paint(Graphics g, Rectangle rect) {
cnt.revalidate();

}
if (cnt.getComponentCount() > 0) {
boolean foundSheet = false;
Component blocker = null;
for (Component child : cnt) {
if (child instanceof Sheet) {
foundSheet = true;
} else if (Boolean.TRUE.equals(child.getClientProperty("SheetBlocker"))) {
blocker = child;
}
}

boolean needsBlocker = Form.activePeerCount > 0;
if (needsBlocker) {
if (blocker == null) {
blocker = new Button();
blocker.putClientProperty("SheetBlocker", Boolean.TRUE);
blocker.setUIID("Container");
blocker.getAllStyles().setBgTransparency(0);
int size = Math.max(CN.getDisplayWidth(), CN.getDisplayHeight()) * 2;
blocker.setPreferredSize(new com.codename1.ui.geom.Dimension(size, size));
((Button) blocker).addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
hide(duration);
}
});
cnt.addComponent(0, BorderLayout.CENTER, blocker);
}
} else {
if (blocker != null) {
cnt.removeComponent(blocker);
blocker = null;
}
}

if (foundSheet) {
$(".Sheet", cnt).each(new ComponentClosure() {
@Override
public void call(Component c) {
Expand Down Expand Up @@ -514,8 +548,18 @@ public void call(Component c) {
}

});
Component existing = cnt.getComponentAt(0);
cnt.replace(existing, this, null);
Component existing = null;
for(Component c : cnt) {
if (c instanceof Sheet) {
existing = c;
break;
}
}
if (existing != null) {
cnt.replace(existing, this, null);
} else {
cnt.add(getPosition(), this);
}
cnt.animateLayout(duration);
} else {
cnt.add(getPosition(), this);
Expand Down
Binary file modified scripts/android/screenshots/BrowserComponent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/kotlin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.codename1.ui.BrowserComponent;
import com.codename1.ui.Form;
import com.codename1.ui.Label;
import com.codename1.ui.Sheet;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.util.UITimer;
import com.codename1.util.SuccessCallback;
Expand Down Expand Up @@ -56,6 +58,10 @@ public void onSucess(BrowserComponent.JSRef result) {
return;
}

Sheet sheet = new Sheet(null, "Overlay Sheet");
sheet.getContentPane().add(new Label("This is a sheet covering part of the browser"));
sheet.show(0);

UITimer.timer(2000, false, form, readyRunnable);
readyRunnable = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package com.codenameone.examples.hellocodenameone.tests
import com.codename1.components.Accordion
import com.codename1.components.MultiButton
import com.codename1.components.Switch
import com.codename1.ui.Button
import com.codename1.ui.CheckBox
import com.codename1.ui.Container
import com.codename1.ui.Label
import com.codename1.ui.Slider
import com.codename1.ui.TextArea
import com.codename1.ui.TextField
import com.codename1.testing.TestUtils
import com.codename1.ui.*
import com.codename1.ui.layouts.BoxLayout

class KotlinUiTest : BaseTest() {
override fun runTest(): Boolean {
val kotlinForm = createForm("Kotlin", BoxLayout.y(), "kotlin")
var called = BooleanArray(1)
val kotlinForm = object : Form("Kotlin", BoxLayout.y()) {
override fun onShowCompleted() {
super.onShowCompleted()
called[0] = true
}
}
kotlinForm.addAll(
Label("Kotlin UI Test Components"),
Button("Kotlin Button"),
Expand Down Expand Up @@ -51,6 +52,21 @@ class KotlinUiTest : BaseTest() {

kotlinForm.add(accordion)
kotlinForm.show()

val sheet = Sheet(null, "Overlay Sheet")
sheet.contentPane.add(Label("This is a sheet covering part of the screen"))
sheet.show(0)

var timeout = 100;
while (sheet.parent == null && !called[0]) {
TestUtils.waitFor(10)
timeout--
TestUtils.assertNotEqual(0, timeout)
}

Cn1ssDeviceRunnerHelper.emitCurrentFormScreenshot("kotlin")
done()

return true
}
}
Loading