cmm tabs: slightly better implementation

git-svn-id: svn://kolibrios.org@7909 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-05-10 12:49:02 +00:00
parent c50bb3b7c6
commit d1df3e2bfe
7 changed files with 129 additions and 109 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -6,18 +6,19 @@
#endif #endif
#define MEMSIZE 200*1024 #define MEMSIZE 200*1024
#include "..\lib\mem.h" #include "../lib/mem.h"
#include "..\lib\strings.h" #include "../lib/strings.h"
#include "..\lib\io.h" #include "../lib/io.h"
#include "..\lib\list_box.h" #include "../lib/list_box.h"
#include "..\lib\gui.h" #include "../lib/obj/libimg.h"
#include "../lib/gui.h"
#include "..\lib\obj\box_lib.h" #include "../lib/obj/box_lib.h"
#include "..\lib\obj\proc_lib.h" #include "../lib/obj/proc_lib.h"
#include "..\lib\obj\libini.h" #include "../lib/obj/libini.h"
#include "..\lib\patterns\select_list.h" #include "../lib/patterns/select_list.h"
#include "..\lib\patterns\simple_open_dialog.h" #include "../lib/patterns/simple_open_dialog.h"
#include "ui_elements_preview.h" #include "ui_elements_preview.h"
@ -29,8 +30,8 @@
#ifdef LANG_RUS #ifdef LANG_RUS
?define WINDOW_HEADER "<EFBFBD> áâனª¨ ®ä®à¬«¥­¨ï" ?define WINDOW_HEADER "<EFBFBD> áâனª¨ ®ä®à¬«¥­¨ï"
?define T_SKINS "‘â¨«ì ®ª®­" ?define T_SKINS " ‘â¨«ì ®ª®­"
?define T_WALLPAPERS "Ž¡®¨" ?define T_WALLPAPERS " Ž¡®¨"
?define T_SELECT_FOLDER "‚ë¡à âì ¯ ¯ªã" ?define T_SELECT_FOLDER "‚ë¡à âì ¯ ¯ªã"
?define MENU_LIST "Žâªàëâì ä ©« |Enter\n“¤ «¨âì ä ©« |Del" ?define MENU_LIST "Žâªàëâì ä ©« |Enter\n“¤ «¨âì ä ©« |Del"
?define T_PICTURE_MODE " <20>®«®¦¥­¨¥ ª à⨭ª¨ " ?define T_PICTURE_MODE " <20>®«®¦¥­¨¥ ª à⨭ª¨ "
@ -39,8 +40,8 @@
?define T_UPDATE_DOCK "Ž¡­®¢«ïâì Dock-¯ ­¥«ì" ?define T_UPDATE_DOCK "Ž¡­®¢«ïâì Dock-¯ ­¥«ì"
#else #else
?define WINDOW_HEADER "Appearance" ?define WINDOW_HEADER "Appearance"
?define T_SKINS "Skins" ?define T_SKINS " Skins"
?define T_WALLPAPERS "Wallpapers" ?define T_WALLPAPERS " Wallpapers"
?define T_SELECT_FOLDER "Select folder" ?define T_SELECT_FOLDER "Select folder"
?define MENU_LIST "Open file |Enter\nDelete file |Del" ?define MENU_LIST "Open file |Enter\nDelete file |Del"
?define T_PICTURE_MODE " Picture Mode " ?define T_PICTURE_MODE " Picture Mode "
@ -56,9 +57,8 @@ char wallp_folder_path[4096];
signed int active_skin=-1, active_wallpaper=-1; signed int active_skin=-1, active_wallpaper=-1;
enum { enum {
SKINS=2, BASE_TAB_BUTTON_ID=2,
WALLPAPERS, BTN_SELECT_WALLP_FOLDER=10 };
BTN_SELECT_WALLP_FOLDER };
char folder_path[4096]; char folder_path[4096];
char cur_file_path[4096]; char cur_file_path[4096];
@ -71,7 +71,9 @@ int cur;
proc_info Form; proc_info Form;
block skp; block skp;
_tabs tabs = { SKINS, LP, LP, NULL, NULL }; enum {SKINS, WALLPAPERS};
_tabs tabs = { LP, LP, NULL, BASE_TAB_BUTTON_ID };
checkbox update_docky = { T_UPDATE_DOCK, false }; checkbox update_docky = { T_UPDATE_DOCK, false };
@ -98,17 +100,21 @@ void GetRealFolderPathes()
void main() void main()
{ {
int id, mouse_clicked; int id;
GetRealFolderPathes(); GetRealFolderPathes();
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
load_dll(libini, #lib_init,1); load_dll(libini, #lib_init,1);
load_dll(libio, #libio_init,1);
load_dll(libimg, #libimg_init,1);
load_dll(Proc_lib, #OpenDialog_init,0); load_dll(Proc_lib, #OpenDialog_init,0);
o_dialog.type = 2; //select folder o_dialog.type = 2; //select folder
OpenDialog_init stdcall (#o_dialog); OpenDialog_init stdcall (#o_dialog);
EventTabClick(SKINS); tabs.add(T_SKINS, #EventTabSkinsClick);
tabs.add(T_WALLPAPERS, #EventTabWallpappersClick);
tabs.draw_active_tab();
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
@ -133,9 +139,8 @@ void main()
case evButton: case evButton:
id=GetButtonID(); id=GetButtonID();
if (id==1) EventExit(); if (id==1) EventExit();
if (id==SKINS) EventTabClick(SKINS);
if (id==WALLPAPERS) EventTabClick(WALLPAPERS);
if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder(); if (id==BTN_SELECT_WALLP_FOLDER) EventSelectWallpFolder();
tabs.click(id);
checkbox1.click(id); checkbox1.click(id);
spinbox1.click(id); spinbox1.click(id);
if (update_docky.click(id)) EventUpdateDocky(); if (update_docky.click(id)) EventUpdateDocky();
@ -147,10 +152,7 @@ void main()
GetKeys(); GetKeys();
if (select_list.ProcessKey(key_scancode)) EventApply(); if (select_list.ProcessKey(key_scancode)) EventApply();
if (key_scancode==SCAN_CODE_ENTER) EventOpenFile(); if (key_scancode==SCAN_CODE_ENTER) EventOpenFile();
if (key_scancode==SCAN_CODE_TAB) { if (key_scancode==SCAN_CODE_TAB) tabs.click(tabs.active_tab ^ 1);
if (tabs.active_tab==SKINS) EventTabClick(WALLPAPERS);
else EventTabClick(SKINS);
}
if (key_scancode==SCAN_CODE_DEL) EventDeleteFile(); if (key_scancode==SCAN_CODE_DEL) EventDeleteFile();
if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus) if (! edit_cmm.flags & ed_focus) && (! edit_st.flags & ed_focus)
@ -198,17 +200,19 @@ void DrawWindowContent()
if (tabs.active_tab == SKINS) list_w=250; else list_w=350; if (tabs.active_tab == SKINS) list_w=250; else list_w=350;
tabs.w = Form.cwidth-LP-LP; tabs.w = Form.cwidth-LP-LP;
tabs.h = Form.cheight-LP-LP; tabs.draw();
tabs.draw_wrapper(); DrawIcon16(tabs.x + TAB_PADDING, 15, sc.work, 17);
tabs.draw_button(tabs.x+TAB_PADDING, SKINS, T_SKINS); DrawIcon16(strlen(T_SKINS)*8 + tabs.x + TAB_PADDING + TAB_PADDING, 15, sc.work, 6);
tabs.draw_button(strlen(T_SKINS)*8+tabs.x+TAB_PADDING+TAB_PADDING, WALLPAPERS, T_WALLPAPERS);
if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y;
select_list.CheckDoesValuesOkey();
id = select_list.cur_y; id = select_list.cur_y;
SelectList_Init( SelectList_Init(
tabs.x+TAB_PADDING, tabs.x+TAB_PADDING,
tabs.y+TAB_HEIGHT+TAB_PADDING, tabs.y+TAB_HEIGHT+TAB_PADDING,
list_w, list_w,
tabs.h - TAB_PADDING - TAB_PADDING - TAB_HEIGHT, Form.cheight-LP-LP - TAB_PADDING - TAB_PADDING - TAB_HEIGHT,
false false
); );
select_list.cur_y = id; select_list.cur_y = id;
@ -299,28 +303,27 @@ void SelectList_LineChanged()
// // // //
//===================================================// //===================================================//
void EventTabClick(int N) void EventTabSkinsClick()
{ {
tabs.click(N); active_wallpaper = select_list.cur_y;
if (tabs.active_tab == SKINS) strcpy(#folder_path, #skins_folder_path);
{ select_list.ClearList();
active_wallpaper = select_list.cur_y; Open_Dir();
strcpy(#folder_path, #skins_folder_path); if (!select_list.count) notify("'No skins were found' -E");
select_list.ClearList(); select_list.cur_y = active_skin;
Open_Dir();
if (!select_list.count) notify("'No skins were found' -E"); if (select_list.w) draw_window();
select_list.cur_y = active_skin; }
}
if (tabs.active_tab == WALLPAPERS) void EventTabWallpappersClick()
{ {
active_skin = select_list.cur_y; active_skin = select_list.cur_y;
strcpy(#folder_path, #wallp_folder_path); strcpy(#folder_path, #wallp_folder_path);
select_list.ClearList(); select_list.ClearList();
Open_Dir(); Open_Dir();
if (!select_list.count) notify("'No wallpapers were found' -E"); if (!select_list.count) notify("'No wallpapers were found' -E");
select_list.cur_y = active_wallpaper; select_list.cur_y = active_wallpaper;
}
if (select_list.cur_y>select_list.visible) select_list.first=select_list.cur_y; select_list.CheckDoesValuesOkey();
if (select_list.w) draw_window(); if (select_list.w) draw_window();
} }
@ -342,7 +345,7 @@ void EventSelectWallpFolder()
OpenDialog_start stdcall (#o_dialog); OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) { if (o_dialog.status) {
strcpy(#wallp_folder_path, #opendir_path); strcpy(#wallp_folder_path, #opendir_path);
EventTabClick(WALLPAPERS); EventTabWallpappersClick();
} }
} }

View File

@ -6,13 +6,10 @@
#define PANELH 28 #define PANELH 28
#define WIN_W 490 #define WIN_W 490
#define WIN_H 315 #define WIN_H 315
#define BASE_TAB_BUTTON_ID 97
proc_info Form; proc_info Form;
enum { _tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
PHRASE_TAB=20, CHARS_TAB
};
_tabs tabs = { PHRASE_TAB };
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
checkbox bold = { "Bold", false }; checkbox bold = { "Bold", false };
@ -27,6 +24,10 @@ void main()
kfont.init(#param); kfont.init(#param);
strcpy(#title, "Font preview: "); strcpy(#title, "Font preview: ");
strcat(#title, #param); strcat(#title, #param);
tabs.add("Phrase", #DrawPreviewPhrase);
tabs.add("Chars", #DrawPreviewChars);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
case evButton: case evButton:
@ -35,7 +36,7 @@ void main()
bold.click(btn); bold.click(btn);
smooth.click(btn); smooth.click(btn);
colored.click(btn); colored.click(btn);
if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); tabs.click(btn);
goto _DRAW_WINDOW_CONTENT; goto _DRAW_WINDOW_CONTENT;
case evReDraw: case evReDraw:
sc.get(); sc.get();
@ -53,8 +54,8 @@ void main()
smooth.draw(83,8); smooth.draw(83,8);
colored.draw(170,8); colored.draw(170,8);
tabs.draw_button(Form.cwidth-130, PHRASE_TAB, "Phrase"); tabs.draw();
tabs.draw_button(Form.cwidth-60, CHARS_TAB, "Chars"); tabs.draw_active_tab();
if (!kfont.font) if (!kfont.font)
{ {
@ -62,8 +63,6 @@ void main()
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
break; break;
} }
if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase();
if (tabs.active_tab==CHARS_TAB) DrawPreviewChars();
} }
} }

View File

@ -3,47 +3,79 @@
#endif #endif
#define TAB_HEIGHT 28 #define TAB_HEIGHT 28
#define NAME_SIZE 64
:struct _tabs :struct _tabs
{ {
int x,y,w;
int base_id;
int active_tab; int active_tab;
int x,y,w,h; char names[640];
dword draw_button(); int count;
dword events[10];
int click(); int click();
void draw_wrapper(); void draw();
void draw_active_tab();
void add();
dword draw_button();
}; };
:void _tabs::draw_wrapper() :void _tabs::draw()
{ {
DrawRectangle(x,y+TAB_HEIGHT,w-1,h-TAB_HEIGHT, sc.work_graph); int i, xx=x;
DrawBar(x+1,y+1+TAB_HEIGHT,w-3,1, sc.work_light);
if (w) {
DrawBar(x+1,y+0+TAB_HEIGHT,w,1, sc.work_graph);
DrawBar(x+1,y+1+TAB_HEIGHT,w,1, sc.work_light);
}
for (i=0; i<count; i++) {
xx += draw_button(xx + TAB_PADDING, i, i*NAME_SIZE + #names) + TAB_PADDING;
}
} }
:dword _tabs::draw_button(dword xx, but_id, text) :void _tabs::draw_active_tab()
{
events[active_tab]();
}
:void _tabs::add(dword text, event)
{
strcpy(count*NAME_SIZE + #names, text);
events[count] = event;
count++;
}
:dword _tabs::draw_button(dword xx, _id, text)
{ {
dword col_bg, col_text; dword col_bg, col_text;
dword ww=strlen(text)*8, hh=TAB_HEIGHT; dword ww=strlen(text)*8;
if (but_id==active_tab) if (_id==active_tab)
{ {
col_bg=0xE44C9C; col_bg = 0xE44C9C;
col_text=sc.work_text; col_text = sc.work_text;
} }
else else
{ {
col_bg=0xC3A1B7; col_bg = 0xC3A1B7;
col_text= MixColors(sc.work, sc.work_text, 120); col_text = MixColors(sc.work, sc.work_text, 120);
} }
DefineHiddenButton(xx-2,y, ww-1+4,hh-1, but_id); DefineHiddenButton(xx-2,y, ww-1+4,TAB_HEIGHT-1, _id + base_id);
WriteText(xx, y+6, 0x90, col_text, text); WriteText(xx, y+6, 0x90, col_text, text);
DrawBar(xx, y+hh-3, ww, 3, col_bg); DrawBar(xx, y+TAB_HEIGHT-3, ww, 3, col_bg);
//DrawStandartCaptButton(xx, y, but_id, text); //GetFreeButtonId() return ww;
return xx;
} }
:int _tabs::click(int N) :int _tabs::click(int _id)
{ {
if (N==active_tab) return false; if (_id < base_id) || (_id > base_id + count) || (_id == active_tab) {
active_tab = N; return false;
}
active_tab = _id - base_id;
events[active_tab]();
return true; return true;
} }

View File

@ -37,6 +37,7 @@
#define WIN_CONTENT_W 400 #define WIN_CONTENT_W 400
#define WIN_CONTENT_H 465 #define WIN_CONTENT_H 465
#define ICONGAP 26 #define ICONGAP 26
#define BASE_TAB_BUTTON_ID 10
proc_info Form; proc_info Form;
#ifdef LANG_RUS #ifdef LANG_RUS
@ -51,13 +52,7 @@ proc_info Form;
#define T_APP_TITLE "System Monitor" #define T_APP_TITLE "System Monitor"
#endif #endif
enum { _tabs tabs = { 4, 10, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, BASE_TAB_BUTTON_ID };
TAB_GENERAL=20,
TAB_DRIVES,
TAB_PROCESSES
};
_tabs tabs = { TAB_GENERAL, 4, 10, WIN_CONTENT_W+WIN_PAD+WIN_PAD-4-4, TAB_HEIGHT };
//===================================================// //===================================================//
// // // //
@ -75,10 +70,7 @@ int Sysmon__DefineAndDrawWindow()
if (Form.status_window>2) return false; if (Form.status_window>2) return false;
//if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; } //if (Form.width < 300) { MoveSize(OLD,OLD,300,OLD); break; }
//if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; } //if (Form.height < 200) { MoveSize(OLD,OLD,OLD,200); break; }
tabs.draw_wrapper(); tabs.draw();
butx = tabs.draw_button(tabs.x+TAB_PADDING, TAB_GENERAL, T_CPU_AND_RAM);
butx = tabs.draw_button(strlen(T_CPU_AND_RAM)*8+TAB_PADDING+butx, TAB_DRIVES, T_DRIVES);
tabs.draw_button(strlen(T_DRIVES)*8+TAB_PADDING+butx, TAB_PROCESSES, T_PROCESSES);
return true; return true;
} }
@ -86,18 +78,7 @@ int Sysmon__ButtonEvent()
{ {
int bid = GetButtonID(); int bid = GetButtonID();
if (1==bid) ExitProcess(); if (1==bid) ExitProcess();
if (TAB_GENERAL==bid) { tabs.click();
tabs.active_tab = TAB_GENERAL;
CPUnRAM__Main();
}
if (TAB_PROCESSES==bid) {
tabs.active_tab = TAB_PROCESSES;
Processes__Main();
}
if (TAB_DRIVES==bid) {
tabs.active_tab = TAB_DRIVES;
Drives__Main();
}
return bid; return bid;
} }
@ -117,5 +98,10 @@ void main()
load_dll(libimg, #libimg_init,1); load_dll(libimg, #libimg_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);
tabs.add(T_CPU_AND_RAM, #CPUnRAM__Main);
tabs.add(T_DRIVES, #Drives__Main);
tabs.add(T_PROCESSES, #Processes__Main);
CPUnRAM__Main(); CPUnRAM__Main();
} }

Binary file not shown.

View File

@ -2,7 +2,7 @@ struc system_colors
{ {
.taskbar dd 0x586786 .taskbar dd 0x586786
.taskbar_text dd 0xFEFEFE .taskbar_text dd 0xFEFEFE
.work_dark dd 0xC0BBB4 .work_dark dd 0xC5BDB9
.work_light dd 0xECE9E5 .work_light dd 0xECE9E5
.window_title dd 0x333333 .window_title dd 0x333333
.work dd 0xDDD7CF .work dd 0xDDD7CF