Back

CreateAppBarElegant

Hello World
Content:
- Methods

A more elegant appbar implementation.

abe = MUI.CreateAppBarElegant( title, leadingIcon, options ) → Object

Example - Just a title

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Absolute", "FillXY")

        apb = MUI.CreateAppBarElegant("My Title")
        var apbHeight = apb.GetHeight()

        scr = app.CreateScroller(1, 1, "NoScrollBar")

            pageLay = MUI.CreateLayout("Linear", "VCenter")
            pageLay.SetSize(1, 1.2)
            pageLay.SetPadding(0, 0, apbHeight, 0)
                var txt = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ..."
                pageLay.AddChild( MUI.CreateTextParagraph(txt) )
            scr.AddChild(pageLay)

        lay.AddChild(scr)
        lay.AddChild(apb)

    app.AddLayout(lay)

    /*
    * We add the app bar after the scroller to make sure
    * that the app bar will stay on top of
    * the page layout
    *
    * Btw, apb.GetHeight() is a function that returns the exact height of the appbar
    */

}
Copy All       Run      

Example - Sample page

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Absolute", "FillXY")

        apb = MUI.CreateAppBar("My Title", "arrow_back", "search")
        apb.SetOnMenuTouch(OnMenuTouch)

        var apbHeight = apb.GetHeight()

        scr = app.CreateScroller(1, 1, "NoScrollBar")

            pageLay = MUI.CreateLayout("Linear", "VCenter")
            pageLay.SetSize(1, 1.2)
            pageLay.SetPadding(0, 0, apbHeight, 0)
                var txt = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ..."
                pageLay.AddChild( MUI.CreateTextParagraph(txt) )
            scr.AddChild(pageLay)

        lay.AddChild(scr)
        lay.AddChild(apb)

    app.AddLayout(lay)
}

function OnMenuTouch()
{
    lay.Animate("SlideToBottom")
}
Copy All       Run      

Example - Complete controls

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Absolute", "FillXY")

        apb = MUI.CreateAppBar("My Title", "menu", "search,more_vert")
        var apbHeight = apb.GetHeight()

        scr = app.CreateScroller(1, 1, "NoScrollBar")

            pageLay = MUI.CreateLayout("Linear", "VCenter")
            pageLay.SetSize(1, 1.2)
            pageLay.SetPadding(0, 0, apbHeight, 0)
                var txt = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ..."
                pageLay.AddChild( MUI.CreateTextParagraph(txt) )
            scr.AddChild(pageLay)

        lay.AddChild(scr)
        lay.AddChild(apb)

    app.AddLayout(lay)
}
Copy All       Run      

Example - Dark mode

cfg.Dark
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Absolute", "FillXY")

        apb = MUI.CreateAppBar("My Title", "menu", "search,more_vert")
        apb.SetOnMenuTouch(OnMenuTouch)
        apb.SetOnControlTouch(OnControlTouch)

        var apbHeight = apb.GetHeight()

        scr = app.CreateScroller(1, 1, "NoScrollBar")

            pageLay = MUI.CreateLayout("Linear", "VCenter")
            pageLay.SetSize(1, 1.2)
            pageLay.SetPadding(0, 0, apbHeight, 0)
                var txt = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ..."
                pageLay.AddChild( MUI.CreateTextParagraph(txt) )
            scr.AddChild(pageLay)

        lay.AddChild(scr)
        lay.AddChild(apb)

    app.AddLayout(lay)
}

function OnMenuTouch()
{
    app.ShowPopup("You click the menu. Might as well display a drawer.")
}

function OnControlTouch(text, index)
{
    app.ShowPopup("You click " + text + ": Control index = "+index)
}
Copy All       Run      

Methods

The following methods are available on the AppBarElegant object:

Focus()
GetAbsHeight() → Number: integer
GetAbsWidth() → Number: integer
GetHeight( options ) → Number
GetLeft( options ) → Number
GetParent() → app object
GetPosition( options ) → Object: { left, top, right, bottom }
GetTop( options ) → Number
GetVisibility() → String: “Show” or “Hide” or “Gone”
GetWidth( options ) → Number
Gone()
Hide()
IsEnabled() → Boolean
IsOverlap( obj, depth ) → Boolean
IsVisible() → Boolean
Show()
Boolean
app object
Number
Number: fraction (0..1)
Number: integer
Number: milliseconds
String:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
String: “Title text”
String: “Material icon font”
String: comma “,” separated: “material icon font for the right controls”
String: “px”
String: “screen”, “px”
String: “New material icon font”
String:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...:
“New color of the heading icon”
String: “New title text”
String: “Show” or “Hide” or “Gone”
String: “Linear.None” or “Quadratic.In/Out” or “Cubic.In/Out” or “Quartic.In/Out” or “Quintic.In/Out” or “Sinusoidal.In/Out” or “Exponential.In/Out” or “Circular.In/Out” or “Elastic.In/Out” or “Back.In/Out” or “Bounce.In/Out”
Object: { x, y, w, w, sw, sh, rot }
function( btnTxt, index )
function()
abe.ClearFocus
Removes the focus of the control so that the user no longer has immediate access to it.
abe.Focus
Set the focus to the control so that the user can interact with it immediately.
abe.GetAbsHeight
Get the absolute height of the control in pixels.
abe.GetAbsWidth
Get the absolute width of the control in pixels.
abe.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
abe.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
abe.GetParent
Returns the parent control object where the object was added to - commonly a layout.
abe.GetPosition
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
abe.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
abe.GetVisibility
Returns the current visibility state of the control. The Values are:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
abe.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
abe.Gone
Hides the control without consuming any more layout space as if it were never there.
abe.Hide
Hide the control but keep the layout space free.
abe.IsEnabled
Returns whether the control is currently useable by the user.
abe.IsOverlap
Returns whether the control overlaps with another by a given distance.
abe.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
abe.SetEnabled
En/Disable the control physically and visually so that the user can/can not access the control. Events like OnTouch will still be fired.
abe.SetMenuIcon
Sets a new heading icon
abe.SetMenuIconColor
Change the color of the heading icon
abe.SetOnControlTouch
Calls a function when the right controls are click
abe.SetOnMenuTouch
Calls a function when the heading icon is click
abe.SetPosition
Defines the position and size for the control if the parent is an absolute layout.
abe.SetTitleText
Sets a new title
abe.SetTitleTextColor
Change the color of the title
abe.SetVisibility
Change the visibility of the control to one of the available modes:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
abe.Show
Set the visibility of the control to “Show”.
abe.Tween
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.

The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.

With the amount of repeats you can control how many times you want to play the animation.

If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.

Finally the callback function will be called after the animation has finished. Well, it's about time!