Thursday, March 17, 2011

Constantly Theme'd

One of the often requested features in LWUIT's themes has been the addition of constants for themes. Constants allow the theme designer to "hint" of desired functionality to the application code, e.g. a particular theme might have a constant indicating that it wants the scrollbar to fadeout when unused.
The LWUIT resource editor now includes an additional tab for creating such constants which can be used to add constant values. These can be added in the ant task by prepending the @ sign before the constant key in the theme and setting the value to the appropriate string.
Constants are always strings, they have some conventions where a constant ending with Bool is treated as a boolean true/false value and a constant ending with Int or Image (for image the string name of the image is stored but the image instance will be returned).

To use a constant one can use the UIManager's methods to get the appropriate constant type specifically:
getThemeConstant
isThemeConstant
getThemeImageConstant

Internally LWUIT has several builtin constants and the list is constantly growing as we add features to LWUIT, we will try to keep this list up to date when possible.



.
LWUIT ConstantDescription
.
centeredPopupBoolPopup of the combo box will appear in the center of the screen
.
checkBoxCheckDisImageCheckBox image to use instead of LWUIT drawing it on its own
.
checkBoxCheckedImageCheckBox image to use instead of LWUIT drawing it on its own
.
checkBoxUncheckDisImageCheckBox image to use instead of LWUIT drawing it on its own
.
checkBoxUncheckedImageCheckBox image to use instead of LWUIT drawing it on its own
.
comboImageCombo image to use instead of LWUIT drawing it on its own
.
commandBehaviorIndicates how commands should act, as a touch menu, native menu etc. Possible values: SoftKey, Touch, Bar, Title, Right, Native
.
defaultCommandImageImage to give a command with no icon
.
dialogButtonCommandsBoolPlace commands in the dialogs as buttons
.
dialogPositionPlace the dialog in an arbitrary border layout position (e.g. North, South, Center etc.)
.
dialogTransitionInDefault transition for dialog
.
dialogTransitionInImageDefault transition Image for dialog, causes a Timeline transition effect
.
dialogTransitionOutDefault transition for dialog
.
dialogTransitionOutImageDefault transition Image for dialog, causes a Timeline transition effect
.
disabledColorColor to use when disabling entries by default
.
dlgCommandButtonSizeIntMinimum size to give to command buttons in the dialog
.
dlgSlideDirectionSlide hints
.
dlgSlideInDirBoolSlide hints
.
dlgSlideOutDirBoolSlide hints



.
fadeScrollBarBoolFade transition hints
.
fadeScrollEdgeBoolFade transition hints
.
fadeScrollEdgeIntFade transition hints
.
firstCharRTLBoolIndicates the GenericListCellRenderer should determine RTL status based on the first character in the sentence
.
fixedSelectionIntNumber corresponding to the fixed selection constants in List
.
formTransitionInDefault transition for form
.
formTransitionInImageDefault transition Image for form, causes a Timeline transition effect
.
formTransitionOutDefault transition for form
.
formTransitionOutImageDefault transition Image for form, causes a Timeline transition effect
.
hideEmptyTitleBoolIndicates that a title with no content should be hidden even if the border for the title occupies space
.
ignorListFocusBoolHide the focus component of the list when the list doesn't have focus
.
listItemGapIntBuiltin item gap in the list, this defaults to 2 which predated padding/margin in LWUIT
.
menuHeightPercentAllows positioning and sizing the menu
.
menuPrefSizeBoolAllows positioning and sizing the menu
.
menuSlideDirectionDefines menu entrance effect
.
menuSlideInDirBoolDefines menu entrance effect
.
menuSlideOutDirBoolDefines menu entrance effect
.
menuTransitionInDefines menu entrance effect
.
menuTransitionInImageDefines menu entrance effect
.
menuTransitionOutDefines menu entrance effect



.
menuTransitionOutImageDefines menu entrance effect
.
menuWidthPercentAllows positioning and sizing the menu
.
otherPopupRendererBoolIndicates that a separate renderer UIID/instance should be used to the list within the combo box popup
.
popupCancelBodyBoolIndicates that a cancel button should appear within the combo box popup
.
popupTitleBoolIndicates that a title should appear within the combo box popup
.
pureTouchBoolIndicates the pure touch mode
.
radioSelectedDisImageRadio button image
.
radioSelectedImageRadio button image
.
radioUnselectedDisImageRadio button image
.
radioUnselectedImageRadio button image
.
rendererShowsNumbersBoolIndicates whether renderers should render the entry number
.
reverseSoftButtonsBoolSwaps the softbutton positions
.
slideDirectionDefault slide transition settings
.
slideInDirBoolDefault slide transition settings
.
slideOutDirBoolDefault slide transition settings
.
snapGridBoolSnap to grid toggle
.
tabsFillRowsBoolIndicates if the tabs should fill the row using flow layout
.
tabsGridBoolIndicates whether tabs should use a grid layout thus forcing all tabs to have identical sizes
.
tickerSpeedIntThe speed of label/button etc. tickering in ms.
.
tintColorThe aarrggbb hex color to tint the screen when a dialog is shown



.
touchCommandFillBoolIndicates how the touch menu should layout the commands within
.
touchCommandFlowBoolIndicates how the touch menu should layout the commands within
.
touchMenuBoolForce the touch menu
.
transitionSpeedIntIndicates the default speed for transitions

One "odd" behavior of constants is that once they are set by a theme they don't get "lost" when replacing the theme. E.g. if one would set the comboImage constant to a specific value in theme A and then switch to theme B that doesn't define the comboImage, the original theme A comboImage might remain. The reason for this is simple, when extracting the constant values components keep the values in cache locally and just don't track the change in value. Furthermore, since the components allow manually setting values its impractical for them to track whether a value was set by a constant or explicitly by the user.
The solution for this is to either manually reset undesired values before replacing a theme (e.g. for the case above by calling the default look and feel method for setting the combo image with a null value) or defining a constant value to replace the existing value.

BTW I haven't been blogging or posting videos as often as I should both because I have been a bit under the weather and because I have been quite swamped with work (checkout the SVN changes). Hopefully I'll feel a bit better next week and increase my blogging a bit.

6 comments:

  1. the resource editor isnt working ! after the new update.1282

    ReplyDelete
  2. Thanks that's my fault entirely :-(
    I fixed this right now, but for this to work for me I had to clear up the old version in the javaws -viewer cache.

    ReplyDelete
  3. Thanks I fixed the post, too much copy and paste late into the night.

    ReplyDelete
  4. I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively. https://www.miuiupdates.com/2021/03/best-miui-ios-theme-for-xiaomi.html

    ReplyDelete
  5. CapCut mod App provides a comprehensive and intuitive video editing solution for content creators. With its easy-to-use interface and access to premium features for free, this app is a must-try for anyone looking to edit their videos on their mobile devices. It's an Video Editor: For Android.

    ReplyDelete
  6. RealX Legacy is a fully compatible: MIUI theme that works just awesome on all Xiaomi Redmi and Poco devices.

    ReplyDelete