From f0a72aeaa5fe8224e7ad1e78c3687140a388453e Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Wed, 16 Apr 2025 18:56:17 -0400 Subject: [PATCH] Applications/Internet/Cyberia: Add hanbaga menu boilerplate Not functional yet, just laying the foundation. --- Applications/Internet/Cyberia.app/Cyberia.HC | 32 ++++++++++++++++-- .../Cyberia.app/Resources/hanbaga.png | Bin 0 -> 843 bytes 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Applications/Internet/Cyberia.app/Resources/hanbaga.png diff --git a/Applications/Internet/Cyberia.app/Cyberia.HC b/Applications/Internet/Cyberia.app/Cyberia.HC index 2720507..4a3ff1d 100644 --- a/Applications/Internet/Cyberia.app/Cyberia.HC +++ b/Applications/Internet/Cyberia.app/Cyberia.HC @@ -12,6 +12,7 @@ U8* previous_hovered_href = NULL; ButtonWidget* backbtn1 = NULL; ButtonWidget* fwdbtn1 = NULL; ButtonWidget* refreshbtn1 = NULL; +ButtonWidget* hanbagabtn1 = NULL; Context2DWidget* background1 = NULL; TextInputWidget* addressbar1 = NULL; @@ -22,6 +23,11 @@ I64 old_window_width = -1; I64 old_window_height = -1; I64 old_mouse_z = Mouse.z; +Window* hanbaga_menu = Menu.New("Cyberia"); +Menu.AddItem(hanbaga_menu, "New Tab", NULL, &Reboot, NULL, NULL); +Menu.AddItem(hanbaga_menu, "New Window", NULL, NULL, NULL, NULL); +Menu.AddItem(hanbaga_menu, "New Private Window", NULL, NULL, NULL, NULL); + class @browser { HtmlRenderer* renderer; @@ -144,6 +150,15 @@ U8* @browser_tls_connection_state(@http_response* resp) } extern U0 @cyberia_navigate(Bool refresh = FALSE); +U0 @cyberia_hanbaga_show(Widget* widget) +{ + hanbaga_menu->x = win->x + win->width - hanbaga_menu->width - 5; + hanbaga_menu->y = win->y + hanbagabtn1->y + hanbagabtn1->height + 24; + Gui.Window.Show(hanbaga_menu); + Gui.Window.SetFocus(hanbaga_menu); + Gui.Window.Refresh(hanbaga_menu); +} + U0 @cyberia_link_clicked(Widget* widget) { @html_dom_node* node = @self_or_ancestor_matches_tag_name(widget->data, "a"); @@ -492,6 +507,9 @@ U0 @cyberia_navigate(Bool refresh = FALSE) append->next->widget = refreshbtn1; append = append->next; append->next = CAlloc(sizeof(@window_widgets_list), browser->task); + append->next->widget = hanbagabtn1; + append = append->next; + append->next = CAlloc(sizeof(@window_widgets_list), browser->task); append->next->widget = addressbar1; append = append->next; append->next = CAlloc(sizeof(@window_widgets_list), browser->task); @@ -563,7 +581,8 @@ U0 @cyberia_win_repaint(Window*) if (!win || !addressbar1 || !background1 || !vscroll1 || !status1 || !statusbackdrop1) return; - addressbar1->width = win->width - 110; + hanbagabtn1->x = win->width - hanbagabtn1->width - 9; + addressbar1->width = hanbagabtn1->x - addressbar1->x - 3; background1->width = 0; background1->height = 0; background1->ctx->width = win->width; @@ -697,6 +716,12 @@ U0 @cyberia_init() refreshbtn1->disabled = TRUE; refreshbtn1->width = refreshbtn1->image->width + 8; + hanbagabtn1 = Gui.CreateWidget(win, WIDGET_TYPE_BUTTON, U64_MAX, 0, 24, 24); + Gui.Widget.SetText(hanbagabtn1, ""); + Gui.Widget.SetCallback(hanbagabtn1, "clicked", &@cyberia_hanbaga_show); + hanbagabtn1->image = @image_file_to_context2d("M:/Applications/Internet/Cyberia.app/Resources/hanbaga.png"); + hanbagabtn1->width = hanbagabtn1->image->width + 8; + background1 = Gui.CreateWidget(win, WIDGET_TYPE_CONTEXT2D, 0, 36, 0, 0); background1->ctx = NewContext2D(Display.Width(), Display.Height()); background1->ctx->fill(Color(255, 255, 255)); @@ -722,8 +747,11 @@ U0 @cyberia_init() U0 Main() { - while (1) + while (1) { + if (Compositor.active_win != hanbaga_menu && Gui.Window.IsVisible(hanbaga_menu)) + Gui.Window.Hide(hanbaga_menu); Sleep(1); + } } Main; diff --git a/Applications/Internet/Cyberia.app/Resources/hanbaga.png b/Applications/Internet/Cyberia.app/Resources/hanbaga.png new file mode 100644 index 0000000000000000000000000000000000000000..c5d5e571239185e2c8cb2659275e13a2b9c3333d GIT binary patch literal 843 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4mJh`h6m-gKNuJo7>k44ofy`glX=O&z|89D z;uzxLy>*IbhKQp`+y3yoGhL2LOz+sSAW+17k&_;mR+ER{BB5q={-nGnaeXa0k&mxj zFF4z<9BgKZ;Zv&U;;sl36kM#ZNafv*M5DHoCAPJDRgzCUU^&^mZ1<}8zx7vt{|`T; z((YqqC#;&msTkj6eKjv<5sN;nl*lt5vBu^fS1$e+^5AaaPqbhwS;zhL_l5mlRje88 zHUi6*SWTkz(cf#eECxtkUoO}2p|rPj~=D&G5BJ=d#x|J~BuYm&f|2M2UHNQ@xHioIS8Nr*Qr%y)y^g#6R8b+b?=(p38?# z8MBzyw>NA*U~@obS}W%d(HV26zF@qtNh)i;qv2Vj140I>vi(*^!ZLX>itjhPTq*eI zROedZ%9X258#6I$a@2Uv_GnhvA^kH$_*BRP@eP7IbQQREH%Pw~DB)IhoVRM#OJ$`? z>sNhllzg_QXreg7-_H53r#+YaWyY~*?!5XN9HcyGZ*PM_7{8_QC; zH!lg-*m^)P;imj0KEa=BR%JKxXVxw5unD>9+7uJ|MC`}s%+0!I5B4b8NIEMVR=N{- zHTT?3?|TRK*uRlkzUO%bQ_OaWwlyDpYUUKD@BQ9B=kbbFIRRJaI+$OW))`mV(>Goi098`U=Ky!_yC0&CO6mtHJp`AMnMcm=#N z)=73CJ7VK3n>Uin;koA>Km=HK!f8s!UxpI&qP$hrFD z#~!8&*{W+MDcrkzeo19Yz=b_R%}