DrvInst: keyboard navigation

git-svn-id: svn://kolibrios.org@7031 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2017-09-28 09:59:41 +00:00
parent 568c1af24d
commit 29387f168a
5 changed files with 66 additions and 39 deletions

View File

@ -81,30 +81,33 @@ byte process_sections(dword sec_name, f_name)
void main() void main()
{ {
int id;
load_dll(libio, #libio_init,1); load_dll(libio, #libio_init,1);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
GetIniData(); GetIniData();
SetEventMask(0x27); SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evMouse: case evMouse:
if (!CheckActiveProcess(Form.ID)) break;
SelectList_ProcessMouse(); SelectList_ProcessMouse();
break; break;
case evButton: case evButton:
id=GetButtonID(); Event_ProcessButtonId(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();
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
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 (select_list.ProcessKey(key_scancode)) SelectList_LineChanged();
if (key_scancode == SCAN_CODE_TAB)
{
ActiveButtonSwitch(11, 12);
Draw_DriverListWindow();
}
}
break; break;
case evReDraw: case evReDraw:
@ -113,7 +116,7 @@ void main()
} }
void draw_intro_window() void Draw_IntroWindow()
{ {
incn y; incn y;
y.n = Form.cheight/2 - 80; y.n = Form.cheight/2 - 80;
@ -121,11 +124,12 @@ void draw_intro_window()
WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE); WriteTextB(30,y.n,0x81,0xB92234,T_CAUTION_TITLE);
y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140, y.n = DrawTextViewArea(30, y.inc(30), Form.cwidth-60, Form.cheight-140,
T_CAUTION_PARAGRAPH, -1, system.color.work_text); 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); DrawStandartCaptButton(30, y.inc(10), BUTTON_ID_ASSEPT_RISK, T_ASSEPT_RISK);
} }
void draw_driver_list_window() void Draw_DriverListWindow()
{ {
int PADDING = 12; int PADDING = 12;
int right_frame_x = Form.cwidth*46/100; int right_frame_x = Form.cwidth*46/100;
@ -169,7 +173,7 @@ void SelectList_DrawLine(dword i)
void SelectList_LineChanged() 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() void Event_DrawWindow()
{ {
system.color.get(); system.color.get();
@ -198,14 +210,15 @@ void Event_DrawWindow()
if (Form.status_window>2) return; if (Form.status_window>2) return;
if (Form.width < 450) { MoveSize(OLD,OLD,450,OLD); return; } if (Form.width < 450) { MoveSize(OLD,OLD,450,OLD); return; }
if (Form.height < 250) { MoveSize(OLD,OLD,OLD,250); 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_INTRO) Draw_IntroWindow();
if (window_step == WINDOW_STEP_DRIVER_LIST) draw_driver_list_window(); if (window_step == WINDOW_STEP_DRIVER_LIST) Draw_DriverListWindow();
return; return;
} }
void Event_AsseptRisk() void Event_AsseptRisk()
{ {
window_step = WINDOW_STEP_DRIVER_LIST; window_step = WINDOW_STEP_DRIVER_LIST;
active_button_id = BUTTON_ID_INSTALL;
Event_DrawWindow(); Event_DrawWindow();
} }
@ -216,5 +229,7 @@ void Event_ShowReadme()
void Event_RunInstall() 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");
} }

View File

@ -50,6 +50,7 @@
WriteText(tx,ty,0x90,color_t,text); WriteText(tx,ty,0x90,color_t,text);
} }
:int active_button_id = 0;
:int DrawStandartCaptButton(dword x, y, id, text) :int DrawStandartCaptButton(dword x, y, id, text)
{ {
int padding_v = 5; int padding_v = 5;
@ -57,15 +58,30 @@
int right_margin = 12; int right_margin = 12;
int tx = x + padding_h; int tx = x + padding_h;
int ty = y + padding_v+1; int ty = y + padding_v+1;
int tw = strlen(text)*8;
int h = padding_v + padding_v + 16; //16 font height 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); 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+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text);
WriteText(tx,ty,0x90,system.color.work_button_text,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; return w + right_margin;
} }
:void ActiveButtonSwitch(int min, max)
{
active_button_id++;
if (active_button_id>max) || (active_button_id<max) active_button_id=min;
}
:void WriteTextCenter(dword x,y,w,color_t,text) :void WriteTextCenter(dword x,y,w,color_t,text)
{ {
WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
@ -200,7 +216,7 @@
{ {
int w; int w;
WriteText(x,y,font_type,0x4E00E7,inscription); WriteText(x,y,font_type,0x4E00E7,inscription);
if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*8;
DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
DrawBar(x,y+8,w,1,0x4E00E7); DrawBar(x,y+8,w,1,0x4E00E7);
} }

View File

@ -324,7 +324,6 @@
__file_F70.rezerv = 0; __file_F70.rezerv = 0;
__file_F70.param2 = rparam; __file_F70.param2 = rparam;
__file_F70.name = path.path(rpath); __file_F70.name = path.path(rpath);
debugln(__file_F70.name);
$mov eax,70 $mov eax,70
$mov ebx,#__file_F70.func $mov ebx,#__file_F70.func
$int 0x40 $int 0x40

View File

@ -57,22 +57,11 @@ char program_path[4096];
#define EVM_MOUSE_FILTER 0x80000000 #define EVM_MOUSE_FILTER 0x80000000
#define EVM_CURSOR_FILTER 0x40000000 #define EVM_CURSOR_FILTER 0x40000000
//Button options //Button options
#define BT_DEL 0x80000000 #define BT_DEL 0x80000000
#define BT_HIDE 0x40000000 #define BT_HIDE 0x40000000
#define BT_NOFRAME 0x20000000 #define BT_NOFRAME 0x20000000
//allow event mask
#define EVENT_MASK_REDRAW 000000001b
#define EVENT_MASK_KEYBOARD 000000010b
#define EVENT_MASK_BUTTONS 000000100b
#define EVENT_MASK_DESKTOP 000010000b
#define EVENT_MASK_MOUSE 000100000b
#define EVENT_MASK_IPC 001000000b
#define EVENT_MASK_NETWORK 010000000b
#define EVENT_MASK_DEBUG 100000000b
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include "../lib/system.h" #include "../lib/system.h"

View File

@ -5,6 +5,7 @@
{ {
byte b,g,r; byte b,g,r;
void DwordToRgb(); void DwordToRgb();
void SetRgb();
dword RgbToDword(); dword RgbToDword();
} rgb; } rgb;
@ -15,6 +16,13 @@
r = _dword & 0xFF; _dword >>= 8; r = _dword & 0xFF; _dword >>= 8;
} }
:void _rgb::SetRgb(dword _r, _g, _b)
{
r = _r;
g = _g;
b = _b;
}
:dword _rgb::RgbToDword() :dword _rgb::RgbToDword()
{ {
dword _r, _g, _b; dword _r, _g, _b;