mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
JS: Expose button event type in gui/widget button callback (#4252)
* JS: Expose button event type in gui/widget button callback --nobuild * js_sdk: bump major version * unit_tests: fix js test * js: fix gui widget demo --------- Co-authored-by: Anna Antonenko <portasynthinca3@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ export type IconData = symbol & { "__tag__": "icon" };
|
||||
* Gets a built-in firmware icon for use in GUI
|
||||
* @param icon Name of the icon
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
export declare function getBuiltin(icon: BuiltinIcon): IconData;
|
||||
|
||||
@@ -14,5 +15,6 @@ export declare function getBuiltin(icon: BuiltinIcon): IconData;
|
||||
* Loads a .fxbm icon (XBM Flipper sprite, from flipperzero-game-engine) for use in GUI
|
||||
* @param path Path to the .fxbm file
|
||||
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
export declare function loadFxbm(path: string): IconData;
|
||||
|
||||
@@ -133,17 +133,20 @@ export declare class View<Props extends Properties, Child> {
|
||||
* Adds a child to the View
|
||||
* @param child Child to add
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
addChild<C extends Child>(child: C): void;
|
||||
/**
|
||||
* Removes all children from the View
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
resetChildren(): void;
|
||||
/**
|
||||
* Removes all previous children from the View and assigns new children
|
||||
* @param children The list of children to assign
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
setChildren(children: Child[]): void;
|
||||
}
|
||||
@@ -158,7 +161,9 @@ export declare class ViewFactory<Props extends Properties, Child, V extends View
|
||||
* Create view instance with custom values, can be changed later with set()
|
||||
* @param initial Dictionary of property names to values
|
||||
* @param children Optional list of children to add to the view
|
||||
* @version Added in JS SDK 0.1; amended in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Added in JS SDK 0.1
|
||||
* @version Amended in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
*/
|
||||
makeWith(initial: Partial<Props>, children?: Child[]): V;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* This view has the elements as its children.
|
||||
*
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
* @module
|
||||
*/
|
||||
|
||||
@@ -42,9 +43,21 @@ type TextBoxElement = { element: "text_box", stripToDots: boolean } & Position &
|
||||
type TextScrollElement = { element: "text_scroll" } & Position & Size & Text;
|
||||
type ButtonElement = { element: "button", button: "left" | "center" | "right" } & Text;
|
||||
type IconElement = { element: "icon", iconData: IconData } & Position;
|
||||
type RectElement = { element: "rect", radius: number, fill: boolean } & Position & Size; /** @version Amended in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
||||
type CircleElement = { element: "circle", radius: number, fill: boolean } & Position; /** @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
||||
type LineElement = { element: "line", x1: number, y1: number, x2: number, y2: number }; /** @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"` */
|
||||
/**
|
||||
* @version Amended in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
* */
|
||||
type RectElement = { element: "rect", radius: number, fill: boolean } & Position & Size;
|
||||
/**
|
||||
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
* */
|
||||
type CircleElement = { element: "circle", radius: number, fill: boolean } & Position;
|
||||
/**
|
||||
* @version Added in JS SDK 0.3, extra feature `"gui-widget-extras"`
|
||||
* @version Baseline since JS SDK 1.0
|
||||
* */
|
||||
type LineElement = { element: "line", x1: number, y1: number, x2: number, y2: number };
|
||||
|
||||
type Element = StringMultilineElement
|
||||
| StringElement
|
||||
@@ -58,12 +71,16 @@ type Element = StringMultilineElement
|
||||
|
||||
type Props = {};
|
||||
type Child = Element;
|
||||
declare class ButtonEvent {
|
||||
key: "left" | "center" | "right";
|
||||
type: "press" | "release" | "short" | "long" | "repeat";
|
||||
}
|
||||
declare class Widget extends View<Props, Child> {
|
||||
/**
|
||||
* Event source for buttons. Only gets fired if there's a corresponding
|
||||
* button element.
|
||||
*/
|
||||
button: Contract<"left" | "center" | "right">;
|
||||
button: Contract<ButtonEvent>;
|
||||
}
|
||||
declare class WidgetFactory extends ViewFactory<Props, Child, Widget> { }
|
||||
declare const factory: WidgetFactory;
|
||||
|
||||
Reference in New Issue
Block a user