From a5121df3e6af8374d18994c6772c58ee4672e7b4 Mon Sep 17 00:00:00 2001 From: PC Date: Mon, 20 Nov 2023 22:40:15 +0000 Subject: [PATCH] Adding some more docs about GUI, button is mostly done --- astro.config.mjs | 39 +++++--- public/img/gui/button_clickme.png | Bin 0 -> 533 bytes public/img/gui/dialog_label.png | Bin 0 -> 1930 bytes src/content/docs/reference/cpu/ubc.mdx | 8 ++ src/content/docs/reference/gui/button.mdx | 83 ++++++++++++++++++ src/content/docs/reference/gui/dialog.mdx | 8 ++ src/content/docs/reference/gui/dropDown.mdx | 8 ++ src/content/docs/reference/gui/label.mdx | 8 ++ src/content/docs/reference/gui/longLabel.mdx | 8 ++ .../docs/reference/gui/radioButton.mdx | 8 ++ src/content/docs/reference/gui/textBox.mdx | 8 ++ src/content/docs/reference/gui/util.mdx | 8 ++ src/content/docs/reference/os/debug.mdx | 34 +++++++ src/content/docs/reference/os/gui.mdx | 35 ++++++++ 14 files changed, 245 insertions(+), 10 deletions(-) create mode 100644 public/img/gui/button_clickme.png create mode 100644 public/img/gui/dialog_label.png create mode 100644 src/content/docs/reference/cpu/ubc.mdx create mode 100644 src/content/docs/reference/gui/button.mdx create mode 100644 src/content/docs/reference/gui/dialog.mdx create mode 100644 src/content/docs/reference/gui/dropDown.mdx create mode 100644 src/content/docs/reference/gui/label.mdx create mode 100644 src/content/docs/reference/gui/longLabel.mdx create mode 100644 src/content/docs/reference/gui/radioButton.mdx create mode 100644 src/content/docs/reference/gui/textBox.mdx create mode 100644 src/content/docs/reference/gui/util.mdx create mode 100644 src/content/docs/reference/os/debug.mdx create mode 100644 src/content/docs/reference/os/gui.mdx diff --git a/astro.config.mjs b/astro.config.mjs index 1374a6e..484a2bf 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -27,19 +27,38 @@ export default defineConfig({ { label: 'Building', link: '/getting-started/building/' }, ], }, - { - label: 'Guides', - collapsed: true, - autogenerate: { directory: 'guides' }, - items: [ - // Each item here is one entry in the navigation menu. - { label: 'Example Guide', link: '/guides/example/' }, - ], - }, + // { + // label: 'Guides', + // collapsed: true, + // autogenerate: { directory: 'guides' }, + // items: [ + // // Each item here is one entry in the navigation menu. + // { label: 'Example Guide', link: '/guides/example/' }, + // ], + // }, { label: 'Reference', collapsed: true, - autogenerate: { directory: 'reference' }, + items: [ + { + label: '📱 GUI', + collapsed: true, + autogenerate: { directory: 'reference/gui' }, + + }, + { + label: '📟 OS', + collapsed: true, + autogenerate: { directory: 'reference/os' }, + + }, + { + label: '🧮 CPU', + collapsed: true, + autogenerate: { directory: 'reference/cpu' }, + + } + ] }, { label: 'Tutorials', diff --git a/public/img/gui/button_clickme.png b/public/img/gui/button_clickme.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a45ebe91f2ed2750b4851115c9ea55b28d58e9 GIT binary patch literal 533 zcmV+w0_y#VP)aGd>AWnNJh0klf$PM|!btR@dt zicPFJDV;)YSw@Ve7;4Fm9|x592-%nKNt=v2i4JsqOP(B%$WEdF|%E% z{aWH#p2Vqg-b#`8N{@J(*>x)Zu8qI+CC}+7a}|rEqX@kNXl?v;0DXD`PypQ&P?#rB zD9ZsTAw_l}58M#1$3|87k@xe(ob*ItynYI49 z5gtE1g&LPSX(~?MSq?KD%~_t5?S-8gEpa3qRqh?)-AGNQ7~0tl+J2n8f3UyjJa1=b zr{9wCr@h_U>$mNeuhU#)kuGp%w^DjYaB#`78<`v-#ObN++vF$$?UZ=!);;}=ocI#} zVr)zizqt$tN{MF)<-G^mN^{F2YwS3bXGoVwXY*5PQ8EKM|0ePwS0M~aao=w= zs+`btkqlFH9a37bjwUFGDWv~wqYceXIWo{;%xDi_+z;7zM2B=&UDeN{!^R!n$@GPn zeM`ZWX&W|$-e#jDh}Qc>5_3Afs{O}1KR$sp$e37pvbk~?_y<+qYwaW)vRzC!XJD2?8LT|eN^1e*&se(1BQP(CeOJ5{IB?^NM z2b!}}Op|s~w8r~V^@}JTx{>$ndK>e>;R-dvGFN&3Nl0^=1AwO*sm34>n)Rr&pk4Y(v(sq31i^77lvB}$%(2> zOFl0`)>gXq=~L;fcgG`HNb5yhV%sxbRvG;BD&)GV#H!)O@2AH%zWM>row@tnXx=Wd z?8A<)U4afnnXl>UWLXCm{{pW4*ct;O)k90cHL+1no|lA_$eDsf4zJISbhC?Y^D(!c zl96wgul8n}jJCkhUGmN zzJpjo$cInUF6J9t8Jl6E?0cj`ctt45xDJLdrY- zIDgf-uHMafxsekx&Tg+as_K#X6+VEwM!h_qOZih>?vcL`d2~YAM3rWaWRMm}gA1EC zs&@S2Gm3jST=(cXZzZD9ARe}R%svZ;c1Y`=DGs#cL)g;S{60EGOX4I?@`YEo3&VwE^de~2i z3N^&f?uAh4z;U!`j<>J}>tjFhM`wGC!@y`>6uoZj!pV>w+a2or?vM^a|Gz*zatUbtu zG>DmV%{^8(TdZAb-b3y@s%>yHAj3@|!Vomg=4Uddu6$^ccC*-4ZEiwaNwYm=8%7Y~ zhDeZfu)ncSiIlxs6DqQ56e#urgy>|cLNE(tEE!jPy80yMxA6p%3V$fK4cv}pSxb~N z&o@j<5G`uLS-U|*ICe+Gl4|f6+>Qz4DwG%4Z>wLr`e@M>Ojn%kHE5oiU4l2<0a3!M z(#0V5E>slw0t5ysiogK>0J^%Q0ziZX&=fpZFspw6(GpDUZ}v;#f0F;M{%_^K$^S_F zKZM&+ESh+>UV5bDSy`mckmg1k)GGetEventID() == 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 +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/dialog.mdx b/src/content/docs/reference/gui/dialog.mdx new file mode 100644 index 0000000..0eaca1b --- /dev/null +++ b/src/content/docs/reference/gui/dialog.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/dropDown.mdx b/src/content/docs/reference/gui/dropDown.mdx new file mode 100644 index 0000000..dfcab6f --- /dev/null +++ b/src/content/docs/reference/gui/dropDown.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/label.mdx b/src/content/docs/reference/gui/label.mdx new file mode 100644 index 0000000..4e8621e --- /dev/null +++ b/src/content/docs/reference/gui/label.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/longLabel.mdx b/src/content/docs/reference/gui/longLabel.mdx new file mode 100644 index 0000000..2fb1266 --- /dev/null +++ b/src/content/docs/reference/gui/longLabel.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/radioButton.mdx b/src/content/docs/reference/gui/radioButton.mdx new file mode 100644 index 0000000..5ce83a5 --- /dev/null +++ b/src/content/docs/reference/gui/radioButton.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/textBox.mdx b/src/content/docs/reference/gui/textBox.mdx new file mode 100644 index 0000000..94d2170 --- /dev/null +++ b/src/content/docs/reference/gui/textBox.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/gui/util.mdx b/src/content/docs/reference/gui/util.mdx new file mode 100644 index 0000000..4c30c34 --- /dev/null +++ b/src/content/docs/reference/gui/util.mdx @@ -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) +::: \ No newline at end of file diff --git a/src/content/docs/reference/os/debug.mdx b/src/content/docs/reference/os/debug.mdx new file mode 100644 index 0000000..a19ada4 --- /dev/null +++ b/src/content/docs/reference/os/debug.mdx @@ -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(); +``` \ No newline at end of file diff --git a/src/content/docs/reference/os/gui.mdx b/src/content/docs/reference/os/gui.mdx new file mode 100644 index 0000000..011cd70 --- /dev/null +++ b/src/content/docs/reference/os/gui.mdx @@ -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.