Skip to content

Commit 1df3c77

Browse files
committed
Merge branch 'master' into javascript-port-initial-work
2 parents 17e2f40 + 0aab53c commit 1df3c77

220 files changed

Lines changed: 17999 additions & 14093 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,15 @@ public static void lockOrientation(boolean portrait) {
842842
Display.impl.lockOrientation(portrait);
843843
}
844844

845+
/// Returns true if orientation was locked using #lockOrientation(boolean) and not yet unlocked via #unlockOrientation().
846+
///
847+
/// #### Returns
848+
///
849+
/// true if orientation is currently marked as locked
850+
public static boolean isLockOrientation() {
851+
return Display.getInstance().isLockOrientation();
852+
}
853+
845854
/// This is the reverse method for lock orientation allowing orientation lock to be disabled
846855
public static void unlockOrientation() {
847856
Display.impl.unlockOrientation();

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ public final class Display extends CN1Constants {
309309
private int previousKeyPressed;
310310
private int lastKeyPressed;
311311
private int lastDragOffset;
312+
private boolean lockOrientation;
312313
private boolean disableScreenshots;
313314

314315
// huge false positive from PMD...
@@ -4073,6 +4074,16 @@ public boolean isPortrait() {
40734074
return impl.isPortrait();
40744075
}
40754076

4077+
4078+
/// Returns true if orientation was locked using #lockOrientation(boolean) and not yet unlocked via #unlockOrientation().
4079+
///
4080+
/// #### Returns
4081+
///
4082+
/// true if orientation is currently marked as locked
4083+
public boolean isLockOrientation() {
4084+
return lockOrientation;
4085+
}
4086+
40764087
/// Returns true if the device allows forcing the orientation via code, feature phones do not allow this
40774088
/// although some include a jad property allowing for this feature
40784089
///
@@ -4115,6 +4126,7 @@ public boolean canForceOrientation() {
41154126
/// - #canForceOrientation()
41164127
public void lockOrientation(boolean portrait) {
41174128
impl.lockOrientation(portrait);
4129+
lockOrientation = true;
41184130
}
41194131

41204132
/// This is the reverse method for lock orientation allowing orientation lock to be disabled
@@ -4132,6 +4144,7 @@ public void lockOrientation(boolean portrait) {
41324144
/// - #canForceOrientation()
41334145
public void unlockOrientation() {
41344146
impl.unlockOrientation();
4147+
lockOrientation = false;
41354148
}
41364149

41374150
/// Indicates whether the device is a tablet, notice that this is often a guess

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

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ public class Sheet extends Container {
122122
private static final int DEFAULT_TRANSITION_DURATION = 300;
123123
private final Sheet parentSheet;
124124
private final Label title = new Label();
125+
private Component titleComponent = title;
125126
private final EventDispatcher closeListeners = new EventDispatcher();
126127
private final EventDispatcher backListeners = new EventDispatcher();
127128
private final Button backButton = new Button(FontImage.MATERIAL_CLOSE);
128129
private final Container commandsContainer = new Container(BoxLayout.x());
130+
private final Container titleComponentContainer = FlowLayout.encloseCenterMiddle(title);
129131
private final Container titleBar = BorderLayout.center(LayeredLayout.encloseIn(
130-
BorderLayout.center(FlowLayout.encloseCenterMiddle(title)),
132+
BorderLayout.center(titleComponentContainer),
131133
BorderLayout.centerEastWest(null, commandsContainer, backButton)
132134
));
133135
private final Container contentPane = new Container(BoxLayout.y());
@@ -399,6 +401,77 @@ public Container getCommandsContainer() {
399401
return commandsContainer;
400402
}
401403

404+
/// Gets the title text displayed in the default title label.
405+
///
406+
/// #### Returns
407+
///
408+
/// The sheet title text.
409+
///
410+
/// #### Since
411+
///
412+
/// 8.0
413+
public String getTitle() {
414+
return title.getText();
415+
}
416+
417+
/// Sets the title text displayed in the default title label.
418+
///
419+
/// If a custom title component is currently installed via {@link #setTitleComponent(Component)},
420+
/// this method still updates the default title label so that it will be shown if the title
421+
/// component is reset back to null.
422+
///
423+
/// #### Parameters
424+
///
425+
/// - `title`: The title text.
426+
///
427+
/// #### Since
428+
///
429+
/// 8.0
430+
public void setTitle(String title) {
431+
this.title.setText(title);
432+
}
433+
434+
/// Gets the component currently used in the center of the title bar.
435+
///
436+
/// #### Returns
437+
///
438+
/// The current title component.
439+
///
440+
/// #### Since
441+
///
442+
/// 8.0
443+
public Component getTitleComponent() {
444+
return titleComponent;
445+
}
446+
447+
/// Sets the title component rendered in the center of the title bar.
448+
///
449+
/// This allows for custom title layouts such as including an image above the title text.
450+
/// If `null` is passed, the default title label is restored.
451+
///
452+
/// #### Parameters
453+
///
454+
/// - `cmp`: The component to use for the title area, or `null` to restore the default title label.
455+
///
456+
/// #### Since
457+
///
458+
/// 8.0
459+
public void setTitleComponent(Component cmp) {
460+
if (cmp == null) {
461+
cmp = title;
462+
}
463+
if (cmp == titleComponent) { //NOPMD CompareObjectsWithEquals
464+
return;
465+
}
466+
if (cmp.getParent() != null) {
467+
cmp.remove();
468+
}
469+
titleComponentContainer.removeAll();
470+
titleComponentContainer.add(cmp);
471+
titleComponent = cmp;
472+
titleComponentContainer.revalidateLater();
473+
}
474+
402475
private void initUI() {
403476
setLayout(new BorderLayout());
404477
contentPane.setSafeArea(true);
@@ -449,7 +522,7 @@ public void show(final int duration) {
449522

450523
// Set the padding in the content pane to match the corner radius
451524
Style s = getStyle();
452-
Style titleParentStyle = title.getParent().getStyle();
525+
Style titleParentStyle = titleComponentContainer.getStyle();
453526
titleParentStyle.setMarginLeft(titleMargin);
454527
titleParentStyle.setMarginRight(titleMargin);
455528
Border border = s.getBorder();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,10 @@ private Component createTabImpl(RadioButton b) {
583583
/// component instance
584584
protected Component createTab(String title, Font font, char icon, float size) {
585585
RadioButton b = new RadioButton(title != null ? title : "");
586-
FontImage.setIcon(b, font, icon, size);
586+
if (tabUIID != null) {
587+
b.setUIID(tabUIID);
588+
}
589+
b.setFontIcon(font, icon, size);
587590
createTabImpl(b);
588591
return b;
589592
}

CodenameOne/src/com/codename1/ui/plaf/LookAndFeel.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,19 @@ public int getFadeScrollBarSpeed() {
14901490

14911491
/// #### Parameters
14921492
///
1493-
/// - `fadeScrollBarSpeed`: the fadeScrollBarSpeed to set
1493+
/// - `fadeScrollBarSpeed`: per-frame opacity decrement used for fading the scrollbar.
1494+
/// Larger values fade out faster.
1495+
///
1496+
/// #### Notes
1497+
///
1498+
/// - This value is **not milliseconds**.
1499+
/// - Approximate fade duration in milliseconds:
1500+
/// `durationMs ~= (255 / fadeScrollBarSpeed) * (1000 / Display.getInstance().getFrameRate())`
1501+
/// - At 60 FPS, common values are:
1502+
/// - `5` -> about `850ms`
1503+
/// - `3` -> about `1400ms`
1504+
/// - `2` -> about `2100ms`
1505+
/// - `1` -> about `4250ms`
14941506
public void setFadeScrollBarSpeed(int fadeScrollBarSpeed) {
14951507
this.fadeScrollBarSpeed = fadeScrollBarSpeed;
14961508
}

0 commit comments

Comments
 (0)