Skip to content

Commit 1e46c46

Browse files
committed
Update theming constants and animation docs
1 parent 3cc0d68 commit 1e46c46

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

docs/developer-guide/Advanced-Theming.asciidoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ SoftKey, Touch, Bar, Title, Right, Native
186186
|defaultEmblemImage
187187
|The emblem painted on the side of the multibutton, by default this is an arrow on some platforms
188188

189+
|emblemUiid
190+
|Overrides the UIID applied to emblem labels rendered by composite buttons such as `MultiButton` and `SpanMultiButton`.
191+
192+
|iconUiid
193+
|Allows theming the icon component used by `SpanLabel`, `SpanButton`, `MultiButton`, and `SpanMultiButton` when they fetch icon styling via theme constants.
194+
195+
|textUiid
196+
|Overrides the text component UIID for `SpanLabel`, `SpanButton`, `MultiButton`, and `SpanMultiButton` instances when provided as a theme constant.
197+
189198
|dialogTransitionOutImage
190199
|Default transition https://www.codenameone.com/javadoc/com/codename1/ui/Image.html[Image] for dialog, causes a https://www.codenameone.com/javadoc/com/codename1/ui/animations/Timeline.html[Timeline] transition effect
191200

@@ -279,6 +288,9 @@ SoftKey, Touch, Bar, Title, Right, Native
279288
|infiniteDefaultColor
280289
|Hex RGB color used for the auto-generated material spinner when `infiniteImage` isn't supplied. Defaults to `777777`
281290

291+
|interactionDialogSpeedInt
292+
|Controls the duration in milliseconds that `InteractionDialog` uses when animating into and out of the layered pane (including the directional dispose helpers). Defaults to `400` if the constant is not defined.
293+
282294
|includeNativeBool
283295
|True to derive from the platform native theme, false to create a blank theme that only uses the basic defaults
284296

@@ -504,6 +516,15 @@ SoftKey, Touch, Bar, Title, Right, Native
504516
|sideSwipeSensitiveInt
505517
|Indicates the region of the screen that is sensitive to side swipe in the side menu bar, defaults to 10 (percent)
506518

519+
|sigButtonOKUIID
520+
|Defines the UIID applied to the confirmation button in the signature capture dialog (defaults to `Button`).
521+
522+
|sigButtonResetUIID
523+
|Defines the UIID applied to the reset/clear button in the signature capture dialog (defaults to `Button`).
524+
525+
|sigButtonCancelUIID
526+
|Defines the UIID applied to the cancel button in the signature capture dialog (defaults to `Button`).
527+
507528
|slideDirection
508529
|Default slide transition settings
509530

docs/developer-guide/Animations.asciidoc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This won't work since these methods are meant for the layout manager, which is i
2929

3030
If you add components to a form that is currently showing, it is your responsibility to invoke `revalidate`/`layoutContainer` to arrange the newly added components (see <<layout-reflows,Layout Reflows>>).
3131

32-
`animateLayout()` method is a fancy form of revalidate that animates the components into their laid out position. After changing the layout & invoking this method the components move to their new sizes/positions seamlessly.
32+
`animateLayout()` method is a fancy form of revalidate that animates the components into their laid out position. After changing the layout & invoking this method the components move to their new sizes/positions seamlessly. `Form` exposes convenience wrappers such as `animateLayout*()` that simply forward to the underlying content pane, so you can usually call the methods directly on the form unless you specifically need to animate a nested container.
3333

3434
This sort of behavior creates a special case where setting the size/position makes sense. When we set the size/position in the demo code here we are positioning the components at the animation start position above the frame.
3535

@@ -45,15 +45,15 @@ fall.addActionListener((e) -> {
4545
b.setY(-fall.getHeight());
4646
hi.add(b);
4747
}
48-
hi.getContentPane().animateLayout(20000); // <2>
48+
hi.animateLayout(20000); // <2>
4949
});
5050
hi.add(fall);
5151
----
5252

5353
There are a couple of things that you should notice about this example:
5454

5555
<1> We used a button to do the animation rather than doing it on show. Since `show()` implicitly lays out the components it wouldn't have worked correctly.
56-
<2> We used `hi.getContentPane().animateLayout(20000);` & not `hi.animateLayout(20000);`. You need to animate the "actual" container and `Form` is a special case.
56+
<2> We used `hi.animateLayout(20000);`, which delegates to the `Form` content pane. If you need to animate a specific container (e.g. a nested layout), call `animateLayout()` on that container instead.
5757

5858

5959
This results in:
@@ -71,7 +71,7 @@ image:img/developer-guide/layout-animation-7.png[Frame 7]
7171

7272
While layout animations are really powerful effects for adding elements into the UI and drawing attention to them. The inverse of removing an element from the UI is often more important. E.g. when we delete or remove an element we want to animate it out.
7373

74-
Layout animations don't really do that since they will try to bring the animated item into place. What we want is the exact opposite of a layout animation and that is the "unlayout animation".
74+
Layout animations don't really do that since they will try to bring the animated item into place. What we want is the exact opposite of a layout animation and that is the "unlayout animation". `Container.animateUnlayout(int, int, Runnable)` and the `Form.animateUnlayout*()` helpers let you trigger this transition either asynchronously (with a completion callback) or synchronously via the `AndWait` variants.
7575

7676
The "unlayout animation" takes a valid laid out state and shifts the components to an invalid state that we defined in advance. E.g. we can fix the example above to flip the "fall" button into a "rise" button when the buttons come into place and this will allow the buttons to float back up to where they came from in the exact reverse order.
7777

@@ -92,14 +92,14 @@ fall.addActionListener((e) -> {
9292
b.setY(-fall.getHeight());
9393
hi.add(b);
9494
}
95-
hi.getContentPane().animateLayout(20000);
95+
hi.animateLayout(20000);
9696
} else {
9797
fall.setText("Fall");
9898
for(int iter = 1 ; iter < hi.getContentPane().getComponentCount() ; iter++) { // <1>
9999
Component c = hi.getContentPane().getComponentAt(iter);
100100
c.setY(-fall.getHeight()); // <2>
101101
}
102-
hi.getContentPane().animateUnlayoutAndWait(20000, 255); // <3>
102+
hi.animateUnlayoutAndWait(20000, 255); // <3>
103103
hi.removeAll(); // <4>
104104
hi.add(fall);
105105
hi.revalidate();
@@ -112,7 +112,7 @@ You will notice some similarities with the unlayout animation but the difference
112112

113113
<1> We loop over existing components (not newly created ones)
114114
<2> We set the desired end position not the desired starting position
115-
<3> We used the `AndWait` variant of the animate unlayout call. We could have used the async call as well.
115+
<3> We used the `animateUnlayoutAndWait(...)` variant to block until completion; `animateUnlayout(duration, opacity, callback)` provides the non-blocking alternative when you want to continue immediately and run code from a callback instead.
116116
<4> After the animation completes we need to actually remove the elements since the UI is now in an invalid position with elements outside of the screen but still physically there!
117117

118118
==== Hiding & Visibility
@@ -121,9 +121,9 @@ A common trick for animating Components in Codename One is to set their preferre
121121

122122
Instead of using that trick you can use `setHidden`/`isHidden` who effectively encapsulate this functionality and a bit more.
123123

124-
One of the issues `setHidden` tries to solve is the fact that preferred size doesn't include the margin in the total and thus a component might still occupy space despite being hidden. To solve this the margin is set to `0` when hiding and restored to its original value when showing the component again by resetting the UIID (which resets all style modifications).
124+
One of the issues `setHidden` tries to solve is the fact that preferred size doesn't include the margin in the total and thus a component might still occupy space despite being hidden. When you request the margin adjustment the current margins are cached, the component is given zero margins while hidden, and those cached values are restored when it is shown again—without resetting the UIID or other style state.
125125

126-
This functionality might be undesirable which is why there is a version of the `setHidden` method that accepts a boolean flag indicating whether the margin/UIID should be manipulated. You can effectively `hide`/`show` a component without deprecated code using something like this:
126+
This functionality might be undesirable which is why there is a version of the `setHidden` method that accepts a boolean flag indicating whether the margin cache should be manipulated. You can effectively `hide`/`show` a component without deprecated code using something like this:
127127

128128
[source,java]
129129
----
@@ -145,13 +145,13 @@ TIP: Notice that the code above uses `setVisible()`, which shouldn't be confused
145145

146146
Most animations have two or three variants:
147147

148-
- Standard animation e.g. `animateLayout(int)`
149-
- And wait variant e.g. `animateLayoutAndWait(int)`
150-
- Callback variant e.g. `animateUnlayout(int, int, Runnable)`
148+
- Standard animation e.g. `animateLayout(int)` or the non-blocking `animateUnlayout(int, int, Runnable)`
149+
- And wait variant e.g. `animateLayoutAndWait(int)` / `animateUnlayoutAndWait(int, int)`
150+
- Callback variant e.g. `animateLayoutFade(int, int, Runnable)`
151151

152152
The standard animation is invoked when we don't care about the completion of the animation. We can do this for a standard animation.
153153

154-
NOTE: The unlayout animations don't have a standard variant. Since they leave the UI in an invalid state we must always do something once the animation completes so a standard variant makes no sense
154+
NOTE: Unlayout animations always leave the container in an invalid state, so even the standard helper expects you to tidy up either in the callback or immediately after the animation finishes.
155155

156156
The `AndWait` variant blocks the calling thread until the animation completes. This is really useful for sequencing animations one after the other e.g this code from the kitchen sink demo:
157157

@@ -180,7 +180,7 @@ The callback variant is similar to the `invokeAndBlock` variant but uses a more
180180

181181
[source,java]
182182
----
183-
hi.getContentPane().animateUnlayout(20000, 255, () -> {
183+
hi.animateUnlayout(20000, 255, () -> {
184184
hi.removeAll();
185185
hi.add(fall);
186186
hi.revalidate();

0 commit comments

Comments
 (0)