-
Notifications
You must be signed in to change notification settings - Fork 87
Built in views
borealis has a number of built-in views that you can use to build a fancy app with minimal code. Here are some of them, what they do and how they work.
This is a simple layout that takes a collection of views and draws them at their given coordinates. The layout takes care of all the plumbing so that you don't have to rewrite this->contentView->willAppear()
7 times in your app.
You only have to implement layout()
to resize and reposition the children, as well as both focus methods if you need navigation.
To make the use of navigation simpler inside an absolute layout, the library provides a NavigationMap
class. As its name suggests, it contains the navigation map of your view: it tells the system where to go when the focus is on a view and the user presses a key.
Using a navigation map is very easy, you just need to add your routes first, then use the getNextFocus()
of the map inside the layout getNextFocus()
. The example app contains code to demonstrate that.
The AppletFrame
can be used as a root frame for most applications.
It mimicks the Switch Settings app with a title (and an optional icon) in a header, a footer with some text on the left and a hint view on the right, and finally a fullscreen content panel in the center.
This layout allows you to stack views linearly, either vertically or horizontally. It supports some metrics parameters such as spacing between views and margins around the whole layout.
A classic button, with multiple possible styles (plain, bordered...). It can display text and an icon if needed.
You don't need to re-bind the A button action to execute code on click. Instead, use the provided click listener.
This is a small and simple title with an optional blue rectangle next to it. Can be used to separate sections in a page.
This displays the actions available for the currently focused view. See the page about inputs and actions for more details on actions and hints.
Displays an image, either from a file or from memory. The view supports multiple scaling and cropping methods.
Allows to write text in multiple different styles and sizes. Labels can either be multiline, which enables line wrapping, or single line.
Multiple alignment methods are available, but be careful as some are uninmplemented or only available for multiline or single line labels.
You can use custom fonts, color and size for individual labels.
This layout contains multiple views stacked on top of one another, but only displays one at a time.
Think of it like a pile of cards, with only one visible on the top.
You can change the visible view at any time.
This is a convenient way to make a "list" of views as you can see on the Switch Settings app. In practice, it's a wrapper around BoxLayout
and ScrollView
.
To match HOS, this view applies different spacing rules for specific child view patterns. It may lack some and screw up spacing on your particular list. If it does, please submit a PR with correct spacing rules.
Lists can hold what's known as "list items", allowing you to rapidly create simple lists of choices. List items contain a text and an optional description. They can also hold a "value", displayed on the right of the item. They are best used in a settings-like page.
Multiple types of list items exist:
-
ListItem
: generic one, bound to an action and nothing else -
SelectListItem
: automatically opens a dropdown to select the value from a predetermined list -
ToggleListItem
: holds a boolean value than can be toggled by clicking the item -
InputListItem
: automatically opens the software keyboard to prompt the user for a new value -
IntegerInputListItem
: holds an integer value that can be changed by clicking the item (opens software keyboard)
All the non-generic list items types have listeners to detect when the user changes the value (after typing it in the keyboard for instance).
Same goes for A button presses, you should not re-bind the action but instead use the provided listener.
Simple view to display one Material icon (represented by its UTF-8 character). This view internally uses the material
font so all Material icons are available, but shared symbols are not.
Allows to report progress to the user. The display flags allow you to select how to display the progress: with a bar, a spinner or both.
A simple progress spinner. Used internally by ProgressDisplay
, but can be used on its own as well.
A solid color rectangle.
Automatically scrolls its child view to follow the focused view. The child view must be bigger than the ScrollView
in order to scroll.
Typically used with a BoxLayout
. If you do so, remember to use setResize
to tell the layout to resize itself otherwise it will not grow bigger than the ScrollView
.
Only supports vertical scrolling for now.
A variant of lists with a special gradient background. Used internally by TabFrame
but can be used on its own.
Should actually be rewritten using List
.
This view allows creating a "staged" setup wizard-like dialog. Similarly to the HOS first-boot setup screen, the user goes from one step to the other until they reach the end of the wizard. The "progress" can be seen on the top-right corner of the dialog (how many steps are completed / how many are left to complete).
You control how and when users go from one step to the other, and if they can go back or not.
Special AppletFrame
containing a Sidebar
, made to easily create a tabbed application. The view takes a list of tabs (tab name and associated content view) and takes care of everything.
Allows creating a simple, static, two-columns only table as seen in the Switch Wi-Fi Network info page.
You cannot change the table content after you created it (it's static), but the class is simple to use.
Special AppletFrame
containing a sidebar on the right side of the screen, with an icon, some text and a big button at the bottom. It mimicks the game details in the Switch Settings app.
The left part of the layout can be filled with anything, usually a list.