From 29387f168afd248e98c59091cf7532545ad5e0cf Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 28 Sep 2017 09:59:41 +0000 Subject: [PATCH] DrvInst: keyboard navigation git-svn-id: svn://kolibrios.org@7031 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/drvinst/drvinst.c | 45 ++++++++++++++++++++++----------- programs/cmm/lib/gui.h | 20 +++++++++++++-- programs/cmm/lib/io.h | 1 - programs/cmm/lib/kolibri.h | 31 ++++++++--------------- programs/cmm/lib/patterns/rgb.h | 8 ++++++ 5 files changed, 66 insertions(+), 39 deletions(-) diff --git a/programs/cmm/drvinst/drvinst.c b/programs/cmm/drvinst/drvinst.c index e90a0beb10..eac409b84c 100644 --- a/programs/cmm/drvinst/drvinst.c +++ b/programs/cmm/drvinst/drvinst.c @@ -81,30 +81,33 @@ byte process_sections(dword sec_name, f_name) void main() { - int id; load_dll(libio, #libio_init,1); load_dll(libini, #lib_init,1); load_dll(boxlib, #box_lib_init,0); GetIniData(); - SetEventMask(0x27); + SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); loop() switch(WaitEvent()) { case evMouse: - if (!CheckActiveProcess(Form.ID)) break; SelectList_ProcessMouse(); break; case evButton: - id=GetButtonID(); - if (id==1) ExitProcess(); - if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk(); - if (id==BUTTON_ID_README) Event_ShowReadme(); - if (id==BUTTON_ID_INSTALL) Event_RunInstall(); + Event_ProcessButtonId(GetButtonID()); break; case evKey: GetKeys(); - if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); + if (key_scancode == SCAN_CODE_ENTER) Event_ProcessButtonId(active_button_id); + if (window_step == WINDOW_STEP_DRIVER_LIST) + { + if (select_list.ProcessKey(key_scancode)) SelectList_LineChanged(); + if (key_scancode == SCAN_CODE_TAB) + { + ActiveButtonSwitch(11, 12); + Draw_DriverListWindow(); + } + } break; case evReDraw: @@ -113,7 +116,7 @@ void main() } -void draw_intro_window() +void Draw_IntroWindow() { incn y; y.n = Form.cheight/2 - 80; @@ -121,11 +124,12 @@ void draw_intro_window() WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE); y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, T_CAUTION_PARAGRAPH, -1, system.color.work_text); + active_button_id = BUTTON_ID_ASSEPT_RISK; DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK); } -void draw_driver_list_window() +void Draw_DriverListWindow() { int PADDING = 12; int right_frame_x = Form.cwidth*46/100; @@ -169,7 +173,7 @@ void SelectList_DrawLine(dword i) void SelectList_LineChanged() { - draw_driver_list_window(); + Draw_DriverListWindow(); } @@ -190,6 +194,14 @@ void GetCurrentSectionData() // // //===================================================// +void Event_ProcessButtonId(int id) +{ + if (id==1) ExitProcess(); + if (id==BUTTON_ID_ASSEPT_RISK) Event_AsseptRisk(); + if (id==BUTTON_ID_README) Event_ShowReadme(); + if (id==BUTTON_ID_INSTALL) Event_RunInstall(); +} + void Event_DrawWindow() { system.color.get(); @@ -198,14 +210,15 @@ void Event_DrawWindow() if (Form.status_window>2) return; if (Form.width < 450) { MoveSize(OLD,OLD,450,OLD); return; } if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); return; } - if (window_step == WINDOW_STEP_INTRO) draw_intro_window(); - if (window_step == WINDOW_STEP_DRIVER_LIST) draw_driver_list_window(); + if (window_step == WINDOW_STEP_INTRO) Draw_IntroWindow(); + if (window_step == WINDOW_STEP_DRIVER_LIST) Draw_DriverListWindow(); return; } void Event_AsseptRisk() { window_step = WINDOW_STEP_DRIVER_LIST; + active_button_id = BUTTON_ID_INSTALL; Event_DrawWindow(); } @@ -216,5 +229,7 @@ void Event_ShowReadme() void Event_RunInstall() { - io.run(#cur_install_path, NULL); + int result; + result = io.run(#cur_install_path, NULL); + if (result) notify("'Driver installation started.\nPlease, open BOARD to check status.'I"); } \ No newline at end of file diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index ddf1705c29..2b261d755d 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -50,6 +50,7 @@ WriteText(tx,ty,0x90,color_t,text); } +:int active_button_id = 0; :int DrawStandartCaptButton(dword x, y, id, text) { int padding_v = 5; @@ -57,15 +58,30 @@ int right_margin = 12; int tx = x + padding_h; int ty = y + padding_v+1; + int tw = strlen(text)*8; int h = padding_v + padding_v + 16; //16 font height - int w = strlen(text)*8 + padding_h + padding_h; + int w = tw + padding_h + padding_h; + if (id>0) DefineButton(x,y,w,h,id,system.color.work_button); + WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text); WriteText(tx,ty,0x90,system.color.work_button_text,text); + + if (active_button_id==id) { + DrawBar(tx,ty+15,tw,1, MixColors(system.color.work_button,0,230)); + DrawBar(tx,ty+14,tw,1, system.color.work_button_text); + } + return w + right_margin; } +:void ActiveButtonSwitch(int min, max) +{ + active_button_id++; + if (active_button_id>max) || (active_button_id>= 8; } +:void _rgb::SetRgb(dword _r, _g, _b) +{ + r = _r; + g = _g; + b = _b; +} + :dword _rgb::RgbToDword() { dword _r, _g, _b;