-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some more docs about GUI, button is mostly done
- Loading branch information
1 parent
29e5d77
commit a5121df
Showing
14 changed files
with
245 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: UBC (User Break Controller) | ||
description: User Break Controller | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/cpu/ubc.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
title: Button | ||
description: GUIButton | ||
--- | ||
|
||
Buttons are a fundamental GUI element that provides a clickable area with an associated action. They are commonly used in dialogs and serve as a convenient way for users to interact with the touchscreen. Below is a simplified documentation for the `GUIButton` class. | ||
|
||
:::tip[Need code ?] | ||
You can jump right to the [👨💻 Usage](#usage) or can refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/button.hpp) if you need more details. | ||
::: | ||
|
||
## Constructor | ||
|
||
```c | ||
GUIButton( | ||
uint16_t leftX, uint16_t topY, uint16_t rightX, uint16_t bottomY, | ||
const char *text, | ||
uint16_t eventID | ||
) | ||
``` | ||
|
||
Creates a **basic button** with the specified dimensions and text. | ||
|
||
- `leftX`: x-coordinate of the left side of the button. | ||
- `topY`: y-coordinate of the top side of the button. | ||
- `rightX`: x-coordinate of the right side of the button. | ||
- `bottomY`: y-coordinate of the bottom side of the button. | ||
- `text`: text displayed on the button, indicating the action it performs. | ||
- `eventID`: A unique identifier associated with the button, typically used to handle button clicks. | ||
|
||
### Optional "flags" | ||
|
||
```c | ||
GUIButton( | ||
uint16_t leftX, uint16_t topY, uint16_t rightX, uint16_t bottomY, | ||
const char *text, | ||
uint16_t eventID, int flags | ||
) | ||
``` | ||
|
||
Creates a **basic button** with the flag capacity. *For now*, the only flag known is the "FlagEnabled" and could be found on the [GUIButton.Flag](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/button.hpp#L7) enum. | ||
|
||
|
||
## Usage | ||
|
||
Let's create a button that says "Click Me !" : | ||
|
||
![A button that says "Click Me !"](/wiki/img/gui/button_clickme.png) | ||
|
||
|
||
```c++ | ||
// parent is the dialog or parent container | ||
|
||
// the BUTTON_CLICK_EVENT_ID on click | ||
const uint16_t BUTTON_CLICK_EVENT_ID = 1; | ||
|
||
GUIButton m_buttonOK = new GUIButton( | ||
parent.GetLeftX() + 10, | ||
parent.GetTopY() + 40, | ||
parent.GetLeftX() + 10 + 95, // width of 95 | ||
parent.GetTopY() + 40 + 30 // height of 30 | ||
"Click Me !", | ||
BUTTON_CLICK_EVENT_ID | ||
); | ||
|
||
// ... | ||
|
||
// On the parent.OnEvent, here a GUIDialog : | ||
virtual int OnEvent(struct GUIDialog_Wrapped *dialog, struct GUIDialog_OnEvent_Data *event) { | ||
if (event->GetEventID() == BUTTON_CLICK_EVENT_ID) { | ||
// TODO: do some action | ||
return 0; | ||
} | ||
// If we don't process the event, let the base class process it. | ||
return GUIDialog::OnEvent(dialog, event); | ||
} | ||
``` | ||
### Use in C++ dialog | ||
:::caution | ||
This section is **not finished**, but you can take a look at the [👨💻 demo gui](https://github.com/SnailMath/hollyhock-2/blob/04a4c086e1145a89d79dfe65158558398da6d8b1/demos/demo_gui/main.cpp#L21) for a complete example | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Dialog | ||
description: GUIDialog | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/dialog.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Drop Down Menu | ||
description: GUIDropDownMenuItem | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/dropDown.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Label | ||
description: GUILabel | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/label.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: longLabel | ||
description: GUILongLabel | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/longLabel.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: radioButton | ||
description: GUIRadioButton | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/radioButton.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: textBox | ||
description: GUITextBox | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/textBox.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Primitives & Utils | ||
description: GUIElement | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui/util.hpp) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Debug | ||
description: Functions useful during debugging | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/debug.hpp) | ||
::: | ||
|
||
|
||
It can be useful to print text or numbers to the screen whilst debugging, without creating a full GUI, or pause execution and wait for a key press. | ||
Thoroughly recommended only for debugging - prefer GUI elements for user-facing input/output! | ||
```cpp | ||
// Print "Hello, world!" at 0, 0 in black on white | ||
Debug_SetCursorPosition(0, 0); | ||
Debug_PrintString("Hello, world!", false); | ||
|
||
// Print "Inverted text" at 1, 1 in white on black | ||
Debug_SetCursorPosition(1, 1); | ||
Debug_PrintString("Inverted text", true); | ||
|
||
// Print the number 0x1322 at 3, 7 | ||
Debug_PrintNumberHex_Word(0x1322, 3, 7); | ||
|
||
// Print small text with a format string | ||
Debug_Printf(20, 20, false, 0, "Format strings are %s in %d!", "cool", 2018); | ||
|
||
// Draw the changes we made to VRAM onto the LCD | ||
// Defined in sdk/os/lcd.hpp | ||
LCD_Refresh(); | ||
|
||
// Block until the user presses a key | ||
Debug_WaitKey(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: GUI | ||
description: Functions and classes to create/display GUI elements. | ||
--- | ||
|
||
:::caution | ||
This doc is **WIP**, please refer to its [original SDK Code](https://github.com/SnailMath/hollyhock-2/blob/master/sdk/include/sdk/os/gui.hpp) | ||
::: | ||
|
||
|
||
__Example:__ Display a simple dialog with a label | ||
|
||
![The dialog as shown on the calculator, with "Dialog Title" as title and "Label Text" as body](/wiki/img/gui/dialog_label.png) | ||
|
||
Here we are using a [GUIDialog](../../gui/dialog/) that's wrapping a [GUILabel](../../gui/label/). The code should look like this : | ||
|
||
```cpp | ||
GUIDialog dialog( | ||
GUIDialog::Height25, | ||
GUIDialog::AlignTop, | ||
"Dialog Title", | ||
GUIDialog::KeyboardStateABC | ||
); | ||
|
||
GUILabel label( | ||
dialog.GetLeftX() + 10, | ||
dialog.GetTopY() + 10, | ||
"Label Text" | ||
); | ||
dialog.AddElement(label); | ||
|
||
dialog.ShowDialog(); | ||
``` | ||
Where the [Height25](../../gui/dialog/#Height25) means 1/4 of the screen height, and [AlignTop](../../gui/dialog/#AlignTop) that it'll be top-aligned, fixed to screen top. | ||
The [KeyboardStateABC](../../gui/dialog/#KeyboardStateABC) is a flag indicating what the keyboard should display if called on this dialog. Here the "ABC" tells it'll be the standard "abc" keyboard when pressing the "Keyboard" key. |