- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.layout.Pane
-
- javafx.scene.layout.BorderPane
-
- com.gluonhq.charm.glisten.mvc.View
-
- All Implemented Interfaces:
Styleable
,EventTarget
- Direct Known Subclasses:
SplashView
@DefaultProperty("center") public class View extends BorderPane
View is a layout container that closely matches the typical layout of many mobile application. All user interfaces are built using views. Each view has a unique name and it needs to be passed to construct a View instance.
Layers
can be placed on top of a View by callingLayer.show()
. By doing this, it is possible to present popup cards and other context-specific information to users.Developers create and add Views to an application using the
AppManager
class. For this the methodAppManager.addViewFactory(String, Supplier)
is called passing in the name of the View, which must be unique, and a View factory which when called by Glisten, should return a new instance of this particular View. The most important view factory is the one that specifies the 'home view', which is shown when the application first starts. For example, the following sample is an application with a single View that has theLabel
with the text 'Hello World' as its contents:public class HelloWorld extends MobileApplication { @Override public void init() { addViewFactory(HOME_VIEW, () -> { Label helloWorld = new Label("Hello world!"); return new View(helloWorld) { @Override protected void updateAppBar(AppBar appBar) { appBar.setTitleText("Some title"); } }; }); } }
From the user interacting with a View a change to another View might be desirable. To do this, developers should call
AppManager.switchView(String)
or a similar method.Views can update the contents of the AppBar by overriding
updateAppBar(AppBar)
. In order to hide an AppBar from a View,Node.visibleProperty()
should be set to false.For more information about Views and how they fit into the overall Glisten framework checkout the API documentation of the
AppManager
class.- Since:
- 1.0.0
- See Also:
AppManager
,Layer
-
-
Property Summary
Properties Type Property Description ObjectProperty<EventHandler<LifecycleEvent>>
onCloseRequest
Called when there is an external request to close thisView
.ObjectProperty<EventHandler<LifecycleEvent>>
onHidden
Called just after the View has been hidden.ObjectProperty<EventHandler<LifecycleEvent>>
onHiding
Called just prior to the View being hidden.ObjectProperty<EventHandler<LifecycleEvent>>
onShowing
Called just prior to the View being shown.ObjectProperty<EventHandler<LifecycleEvent>>
onShown
Called just after the View is shown.ReadOnlyBooleanProperty
showing
A boolean property used to represent whether this View is currently starting being shown on screen.ObjectProperty<Function<View,MobileTransition>>
showTransitionFactory
Specifies aMobileTransition
which should be used as factory to create a transition used by the View during its appearance.-
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
-
Properties inherited from class javafx.scene.Parent
needsLayout
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
-
Field Summary
-
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MobileApplication
getApplication()
Deprecated.UsegetAppManager()
instead.AppManager
getAppManager()
Convenience method that returns theAppManager
instance that this View finds itself contained within.EventHandler<LifecycleEvent>
getOnCloseRequest()
Gets the value of the property onCloseRequest.EventHandler<LifecycleEvent>
getOnHidden()
Gets the value of the property onHidden.EventHandler<LifecycleEvent>
getOnHiding()
Gets the value of the property onHiding.EventHandler<LifecycleEvent>
getOnShowing()
Gets the value of the property onShowing.EventHandler<LifecycleEvent>
getOnShown()
Gets the value of the property onShown.MobileTransition
getShowTransition()
Returns current show transition for theView
This method never returns null, so transition can be played safelyFunction<View,MobileTransition>
getShowTransitionFactory()
Gets the value of the property showTransitionFactory.boolean
isShowing()
Gets the value of the property showing.ObjectProperty<EventHandler<LifecycleEvent>>
onCloseRequestProperty()
Called when there is an external request to close thisView
.ObjectProperty<EventHandler<LifecycleEvent>>
onHiddenProperty()
Called just after the View has been hidden.ObjectProperty<EventHandler<LifecycleEvent>>
onHidingProperty()
Called just prior to the View being hidden.ObjectProperty<EventHandler<LifecycleEvent>>
onShowingProperty()
Called just prior to the View being shown.ObjectProperty<EventHandler<LifecycleEvent>>
onShownProperty()
Called just after the View is shown.void
setOnCloseRequest(EventHandler<LifecycleEvent> value)
Sets the value of the property onCloseRequest.void
setOnHidden(EventHandler<LifecycleEvent> value)
Sets the value of the property onHidden.void
setOnHiding(EventHandler<LifecycleEvent> value)
Sets the value of the property onHiding.void
setOnShowing(EventHandler<LifecycleEvent> value)
Sets the value of the property onShowing.void
setOnShown(EventHandler<LifecycleEvent> value)
Sets the value of the property onShown.void
setShowTransitionFactory(Function<View,MobileTransition> value)
Sets the value of the property showTransitionFactory.ReadOnlyBooleanProperty
showingProperty()
A boolean property used to represent whether this View is currently starting being shown on screen.ObjectProperty<Function<View,MobileTransition>>
showTransitionFactoryProperty()
Specifies aMobileTransition
which should be used as factory to create a transition used by the View during its appearance.protected void
updateAppBar(AppBar appBar)
If the view uses anAppBar
it is the responsibility of the developer to appropriately set it up in this method.-
Methods inherited from class javafx.scene.layout.BorderPane
bottomProperty, centerProperty, clearConstraints, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getAlignment, getBottom, getCenter, getContentBias, getLeft, getMargin, getRight, getTop, layoutChildren, leftProperty, rightProperty, setAlignment, setBottom, setCenter, setLeft, setMargin, setRight, setTop, topProperty
-
Methods inherited from class javafx.scene.layout.Pane
getChildren
-
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
-
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javafx.css.Styleable
getStyleableNode
-
-
-
-
Property Detail
-
showing
public final ReadOnlyBooleanProperty showingProperty
A boolean property used to represent whether this View is currently starting being shown on screen.- See Also:
isShowing()
-
showTransitionFactory
public final ObjectProperty<Function<View,MobileTransition>> showTransitionFactoryProperty
Specifies aMobileTransition
which should be used as factory to create a transition used by the View during its appearance. Given a View the factory should return aMobileTransition
.
-
onShowing
public final ObjectProperty<EventHandler<LifecycleEvent>> onShowingProperty
Called just prior to the View being shown. This happens just before the transition to show the View starts.- See Also:
getOnShowing()
,setOnShowing(EventHandler)
-
onShown
public final ObjectProperty<EventHandler<LifecycleEvent>> onShownProperty
Called just after the View is shown. This happens just after the show transition ends.- See Also:
getOnShown()
,setOnShown(EventHandler)
-
onHiding
public final ObjectProperty<EventHandler<LifecycleEvent>> onHidingProperty
Called just prior to the View being hidden.- See Also:
getOnHiding()
,setOnHiding(EventHandler)
-
onHidden
public final ObjectProperty<EventHandler<LifecycleEvent>> onHiddenProperty
Called just after the View has been hidden. This allows the developer to clean up resources or perform other tasks when the View is hidden.- See Also:
getOnHidden()
,setOnHidden(EventHandler)
-
onCloseRequest
public final ObjectProperty<EventHandler<LifecycleEvent>> onCloseRequestProperty
Called when there is an external request to close thisView
. If in the event handler the received event is consumed the View will no longer hide.
-
-
Constructor Detail
-
View
public View()
Creates a new View instance with no content- Since:
- 5.0.0
-
View
public View(Node content)
Creates a new View instance with the given content.- Parameters:
content
- The given content for the View
-
-
Method Detail
-
showingProperty
public final ReadOnlyBooleanProperty showingProperty()
A boolean property used to represent whether this View is currently starting being shown on screen.- See Also:
isShowing()
-
isShowing
public final boolean isShowing()
Gets the value of the property showing.- Property description:
- A boolean property used to represent whether this View is currently starting being shown on screen.
-
showTransitionFactoryProperty
public final ObjectProperty<Function<View,MobileTransition>> showTransitionFactoryProperty()
Specifies aMobileTransition
which should be used as factory to create a transition used by the View during its appearance. Given a View the factory should return aMobileTransition
.
-
getShowTransitionFactory
public final Function<View,MobileTransition> getShowTransitionFactory()
Gets the value of the property showTransitionFactory.- Property description:
- Specifies a
MobileTransition
which should be used as factory to create a transition used by the View during its appearance. Given a View the factory should return aMobileTransition
.
-
setShowTransitionFactory
public final void setShowTransitionFactory(Function<View,MobileTransition> value)
Sets the value of the property showTransitionFactory.- Property description:
- Specifies a
MobileTransition
which should be used as factory to create a transition used by the View during its appearance. Given a View the factory should return aMobileTransition
.
-
onShowingProperty
public final ObjectProperty<EventHandler<LifecycleEvent>> onShowingProperty()
Called just prior to the View being shown. This happens just before the transition to show the View starts.- See Also:
getOnShowing()
,setOnShowing(EventHandler)
-
setOnShowing
public final void setOnShowing(EventHandler<LifecycleEvent> value)
Sets the value of the property onShowing.- Property description:
- Called just prior to the View being shown. This happens just before the transition to show the View starts.
-
getOnShowing
public final EventHandler<LifecycleEvent> getOnShowing()
Gets the value of the property onShowing.- Property description:
- Called just prior to the View being shown. This happens just before the transition to show the View starts.
-
onShownProperty
public final ObjectProperty<EventHandler<LifecycleEvent>> onShownProperty()
Called just after the View is shown. This happens just after the show transition ends.- See Also:
getOnShown()
,setOnShown(EventHandler)
-
setOnShown
public final void setOnShown(EventHandler<LifecycleEvent> value)
Sets the value of the property onShown.- Property description:
- Called just after the View is shown. This happens just after the show transition ends.
-
getOnShown
public final EventHandler<LifecycleEvent> getOnShown()
Gets the value of the property onShown.- Property description:
- Called just after the View is shown. This happens just after the show transition ends.
-
onHidingProperty
public final ObjectProperty<EventHandler<LifecycleEvent>> onHidingProperty()
Called just prior to the View being hidden.- See Also:
getOnHiding()
,setOnHiding(EventHandler)
-
setOnHiding
public final void setOnHiding(EventHandler<LifecycleEvent> value)
Sets the value of the property onHiding.- Property description:
- Called just prior to the View being hidden.
-
getOnHiding
public final EventHandler<LifecycleEvent> getOnHiding()
Gets the value of the property onHiding.- Property description:
- Called just prior to the View being hidden.
-
onHiddenProperty
public final ObjectProperty<EventHandler<LifecycleEvent>> onHiddenProperty()
Called just after the View has been hidden. This allows the developer to clean up resources or perform other tasks when the View is hidden.- See Also:
getOnHidden()
,setOnHidden(EventHandler)
-
setOnHidden
public final void setOnHidden(EventHandler<LifecycleEvent> value)
Sets the value of the property onHidden.- Property description:
- Called just after the View has been hidden. This allows the developer to clean up resources or perform other tasks when the View is hidden.
-
getOnHidden
public final EventHandler<LifecycleEvent> getOnHidden()
Gets the value of the property onHidden.- Property description:
- Called just after the View has been hidden. This allows the developer to clean up resources or perform other tasks when the View is hidden.
-
onCloseRequestProperty
public final ObjectProperty<EventHandler<LifecycleEvent>> onCloseRequestProperty()
Called when there is an external request to close thisView
. If in the event handler the received event is consumed the View will no longer hide.
-
setOnCloseRequest
public final void setOnCloseRequest(EventHandler<LifecycleEvent> value)
Sets the value of the property onCloseRequest.- Property description:
- Called when there is an external request to close this
View
. If in the event handler the received event is consumed the View will no longer hide.
-
getOnCloseRequest
public final EventHandler<LifecycleEvent> getOnCloseRequest()
Gets the value of the property onCloseRequest.- Property description:
- Called when there is an external request to close this
View
. If in the event handler the received event is consumed the View will no longer hide.
-
getShowTransition
public MobileTransition getShowTransition()
Returns current show transition for theView
This method never returns null, so transition can be played safely- Returns:
- Current transition or
NoTransition
if factory returned null
-
updateAppBar
protected void updateAppBar(AppBar appBar)
If the view uses anAppBar
it is the responsibility of the developer to appropriately set it up in this method. Every time the view is shown, this method will be called with a "clean"AppBar
i.e. without any elements in it.- Parameters:
appBar
- theAppBar
- See Also:
AppBar.clear()
-
getApplication
@Deprecated public final MobileApplication getApplication()
Deprecated.UsegetAppManager()
instead.Convenience method that returns theMobileApplication
instance that this View finds itself contained within.- Returns:
- the
MobileApplication
instance
-
getAppManager
public final AppManager getAppManager()
Convenience method that returns theAppManager
instance that this View finds itself contained within.- Returns:
- the
AppManager
instance
-
-