Skip to content

Commit e78adbe

Browse files
committed
Keep default picker layout unchanged without custom buttons
1 parent f3ec29b commit e78adbe

3 files changed

Lines changed: 47 additions & 8 deletions

File tree

CodenameOne/src/com/codename1/ui/spinner/Picker.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,21 @@ protected void deinitialize() {
585585
.setBgTransparency(0)
586586
.setMargin(0)
587587
.setPaddingMillimeters(3f, 0);
588-
Container spinnerSection = new Container(new BorderLayout());
589-
spinnerSection.add(BorderLayout.CENTER, wrapper);
590588
Container topCustomButtons = createLightweightPopupButtonRow(spinner, LightweightPopupButtonPlacement.ABOVE_SPINNER, isTablet);
591-
if (topCustomButtons != null) {
592-
spinnerSection.add(BorderLayout.NORTH, topCustomButtons);
593-
}
594589
Container bottomCustomButtons = createLightweightPopupButtonRow(spinner, LightweightPopupButtonPlacement.BELOW_SPINNER, isTablet);
595-
if (bottomCustomButtons != null) {
596-
spinnerSection.add(BorderLayout.SOUTH, bottomCustomButtons);
590+
if (topCustomButtons != null || bottomCustomButtons != null) {
591+
Container spinnerSection = new Container(new BorderLayout());
592+
spinnerSection.add(BorderLayout.CENTER, wrapper);
593+
if (topCustomButtons != null) {
594+
spinnerSection.add(BorderLayout.NORTH, topCustomButtons);
595+
}
596+
if (bottomCustomButtons != null) {
597+
spinnerSection.add(BorderLayout.SOUTH, bottomCustomButtons);
598+
}
599+
dlg.getContentPane().add(BorderLayout.CENTER, spinnerSection);
600+
} else {
601+
dlg.getContentPane().add(BorderLayout.CENTER, wrapper);
597602
}
598-
dlg.getContentPane().add(BorderLayout.CENTER, spinnerSection);
599603

600604

601605
Button doneButton = new Button("Done", isTablet ? "PickerButtonTablet" : "PickerButton");

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public final class Cn1ssDeviceRunner extends DeviceRunner {
7474
new TabsScreenshotTest(),
7575
new TextAreaAlignmentScreenshotTest(),
7676
new ValidatorLightweightPickerScreenshotTest(),
77+
new LightweightPickerDefaultScreenshotTest(),
7778
new LightweightPickerButtonsScreenshotTest(),
7879
new ToastBarTopPositionScreenshotTest(),
7980
// Keep this as the last screenshot test; orientation changes can leak into subsequent screenshots.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.codenameone.examples.hellocodenameone.tests;
2+
3+
import com.codename1.ui.Display;
4+
import com.codename1.ui.Form;
5+
import com.codename1.ui.layouts.BoxLayout;
6+
import com.codename1.ui.spinner.Picker;
7+
import com.codename1.ui.util.UITimer;
8+
9+
import java.util.Date;
10+
11+
/**
12+
* Baseline screenshot for lightweight picker popup without any custom quick-action buttons.
13+
*/
14+
public class LightweightPickerDefaultScreenshotTest extends BaseTest {
15+
private Picker picker;
16+
17+
@Override
18+
public boolean runTest() {
19+
Form form = createForm("Picker Default Popup", BoxLayout.y(), "LightweightPickerDefault");
20+
picker = new Picker();
21+
picker.setType(Display.PICKER_TYPE_DATE);
22+
picker.setUseLightweightPopup(true);
23+
picker.setDate(new Date());
24+
form.add(picker);
25+
form.show();
26+
return true;
27+
}
28+
29+
@Override
30+
protected void registerReadyCallback(Form parent, Runnable run) {
31+
picker.startEditingAsync();
32+
UITimer.timer(1000, false, parent, run);
33+
}
34+
}

0 commit comments

Comments
 (0)