Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * MENU DIALOG UEFI
- *
- */
- void button_draw(const char* text, int x, int y, int w, int h) {
- word colorAccent = RGB(ff8800);
- /* draw text */
- LIBAROMA_TEXT textp = libaroma_text(
- text,
- colorAccent,
- w - libaroma_dp(16),
- LIBAROMA_FONT(1,4)|
- LIBAROMA_TEXT_SINGLELINE|
- LIBAROMA_TEXT_CENTER|
- LIBAROMA_TEXT_FIXED_INDENT|
- LIBAROMA_TEXT_FIXED_COLOR|
- LIBAROMA_TEXT_NOHR,
- 100
- );
- int ty = y + (h>>1) - ((libaroma_text_height(textp)>>1));
- libaroma_text_draw(dc,textp,x + libaroma_dp(8),ty);
- libaroma_text_free(textp);
- }
- int button_width(const char* text) {
- /* draw text */
- LIBAROMA_TEXT textp = libaroma_text(
- text,
- 0,
- dc->w,
- LIBAROMA_FONT(1,4)|
- LIBAROMA_TEXT_SINGLELINE|
- LIBAROMA_TEXT_CENTER|
- LIBAROMA_TEXT_FIXED_INDENT|
- LIBAROMA_TEXT_FIXED_COLOR|
- LIBAROMA_TEXT_NOHR,
- 100
- );
- int w = libaroma_dp(8) + libaroma_text_width(textp) + libaroma_dp(8);
- libaroma_text_free(textp);
- return w;
- }
- int MenuShowDialog(
- const char * Title,
- const char * Message,
- const char * Button1,
- const char * Button2
- ){
- int Selection = 0;
- int MaxSelection = (Button1?1:0) + (Button2?1:0);
- /* COLORS */
- word colorTextSecondary = RGB(cccccc);
- word colorTextPrimary = RGB(ffffff);
- word colorBackground = RGB(444444);
- word colorSelection = RGB(aaaaaa);
- /*
- if(Initialized==FALSE)
- return -1;
- UINT32 OldMode = mGop->Mode->Mode;
- mGop->SetMode(mGop, gLKDisplay->GetPortraitMode());
- */
- /* Mask Dark */
- libaroma_draw_rect(
- dc, 0, 0, dc->w, dc->h, RGB(000000), 0x7a
- );
- /* Init Message & Title Text */
- int dialog_w = dc->w-libaroma_dp(48);
- LIBAROMA_TEXT messagetextp = libaroma_text(
- Message,
- colorTextSecondary,
- dialog_w-libaroma_dp(48),
- LIBAROMA_FONT(0,4)|
- LIBAROMA_TEXT_LEFT|
- LIBAROMA_TEXT_FIXED_INDENT|
- LIBAROMA_TEXT_FIXED_COLOR|
- LIBAROMA_TEXT_NOHR,
- 100
- );
- LIBAROMA_TEXT textp = libaroma_text(
- Title,
- colorTextPrimary,
- dialog_w-libaroma_dp(48),
- LIBAROMA_FONT(1,6)|
- LIBAROMA_TEXT_LEFT|
- LIBAROMA_TEXT_FIXED_INDENT|
- LIBAROMA_TEXT_FIXED_COLOR|
- LIBAROMA_TEXT_NOHR,
- 100
- );
- int dialog_h =
- libaroma_dp(120)+
- libaroma_text_height(textp)+
- libaroma_text_height(messagetextp);
- int dialog_x = libaroma_dp(24);
- int dialog_y = (dc->h>>1)-(dialog_h>>1);
- /* create & draw dialog canvas */
- LIBAROMA_CANVASP dialog_canvas = libaroma_canvas_ex(dialog_w,dialog_h,1);
- libaroma_canvas_setcolor(dialog_canvas,0,0);
- libaroma_gradient(dialog_canvas,
- 0,0,
- dialog_w, dialog_h,
- colorBackground,colorBackground,
- libaroma_dp(2), /* rounded 2dp */
- 0x1111 /* all corners */
- );
- /* draw texts */
- libaroma_text_draw(
- dialog_canvas,
- textp,
- libaroma_dp(24),
- libaroma_dp(24)
- );
- libaroma_text_free(textp);
- /* draw text */
- libaroma_text_draw(
- dialog_canvas,
- messagetextp,
- libaroma_dp(24),
- libaroma_dp(24)+libaroma_text_height(textp) + libaroma_dp(20)
- );
- libaroma_text_free(messagetextp);
- /* draw zshadow */
- libaroma_draw_zshadow(
- dc, dialog_canvas, dialog_x, dialog_y,
- 4 /* z-index = 4 */
- );
- /* draw dialog into display canvas */
- libaroma_draw(dc,dialog_canvas,dialog_x, dialog_y, 1);
- /* free dialog canvas */
- libaroma_canvas_free(dialog_canvas);
- int i; /* i is selection */
- for (i=0;i<2;i++){
- Selection=i;
- int button_y = dialog_y+dialog_h-libaroma_dp(52);
- /* clean button area */
- libaroma_draw_rect(dc, dialog_x, button_y, dialog_w, libaroma_dp(36), colorBackground, 0xff);
- if(Button1) {
- /* button1 */
- int button_w = button_width(Button1);
- int button_x = dialog_x+dialog_w-button_w-libaroma_dp(16);
- if(Selection==0) {
- libaroma_gradient_ex(dc,
- button_x,button_y,
- button_w, libaroma_dp(36),
- colorSelection,colorSelection,
- libaroma_dp(2), /* rounded 2dp */
- 0x1111, /* all corners */
- 0x40, 0x40 /* start & end alpha */
- );
- }
- button_draw(Button1, button_x, button_y-libaroma_dp(2), button_w, libaroma_dp(36));
- /* button2 */
- if(Button2) {
- button_w = button_width(Button2);
- button_x -= (libaroma_dp(8)+button_w);
- if(Selection==1) {
- libaroma_gradient_ex(dc,
- button_x,button_y,
- button_w, libaroma_dp(36),
- colorSelection,colorSelection,
- libaroma_dp(2), /* rounded 2dp */
- 0x1111, /* all corners */
- 0x40, 0x40 /* start & end alpha */
- );
- }
- button_draw(Button2, button_x, button_y-libaroma_dp(2), button_w, libaroma_dp(36));
- }
- }
- libaroma_sync();
- sleep(2);
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment