From 8e14e05cbd40132a3bdf7aaeefa45bc370447460 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 23 Oct 2013 22:05:17 +0000 Subject: [PATCH] [KolibriN9] Appearance: beta version git-svn-id: svn://kolibrios.org@4078 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/appearance/appearance.c | 238 +++++++++++++++++++++++++++ programs/cmm/appearance/compile.bat | 5 + programs/cmm/appearance/other.h | 9 + programs/cmm/eolite/Eolite.c | 2 +- programs/cmm/eolite/include/menu.h | 7 +- programs/cmm/lib/list_box.h | 8 +- 6 files changed, 261 insertions(+), 8 deletions(-) create mode 100644 programs/cmm/appearance/appearance.c create mode 100644 programs/cmm/appearance/compile.bat create mode 100644 programs/cmm/appearance/other.h diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c new file mode 100644 index 0000000000..8c22f591b8 --- /dev/null +++ b/programs/cmm/appearance/appearance.c @@ -0,0 +1,238 @@ +//11.03.12 - start! + +#define MEMSIZE 0xFE800 +#include "..\lib\kolibri.h" +#include "..\lib\mem.h" +#include "..\lib\file_system.h" +#include "..\lib\strings.h" +#include "..\lib\list_box.h" +#include "..\lib\figures.h" + +#define WINDOW_HEADER "Appearance" + +#define PANEL_H 30 +#define SKINS_STANDART_PATH "/sys/skins/" +#define WALP_STANDART_PATH "/sys/wallpapers/" + +llist list[2]; +int active; +enum { SKINS, WALLPAPERS }; + +char folder_path[4096]; +char cur_file_path[4096]; +char temp_filename[4096]; +int files_mas[100]; +dword buf; + +int cur; + +system_colors sc; +proc_info Form; + +#include "other.h" + +//ADD PaNEL + + +//skins direktory, configurate, delete from list, delete from disk, make default + +void Open_Dir() +{ + int j, filesnum; + + list[active].count = 0; + free(buf); + if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return; + + for (j=0; jsc.work) + { + DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button); + WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename); + } + else + { + DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button); + WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename); + } + } + else + { + DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff); + WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename); + } + } + DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff); +} + +void GetFiles(int set_active) +{ + active = set_active; + if (active==SKINS) + { + strcpy(#folder_path, SKINS_STANDART_PATH); + Open_Dir(); + if (!list[active].count) notify("No skins were found"); + } + if (active==WALLPAPERS) + { + strcpy(#folder_path, WALP_STANDART_PATH); + Open_Dir(); + if (!list[active].count) notify("No wallpapers were found"); + } +} + +void Apply() +{ + if (active==SKINS) + { + strcpy(#cur_file_path, #folder_path); + cur = list[active].current; + strcat(#cur_file_path, files_mas[cur]*304 + buf+72); + SetSystemSkin(#cur_file_path); + } + if (active==WALLPAPERS) + { + strcpy(#cur_file_path, "\\S__"); + strcat(#cur_file_path, #folder_path); + cur = list[active].current; + strcat(#cur_file_path, files_mas[cur]*304 + buf+72); + RunProgram("/sys/media/kiv", #cur_file_path); + Draw_List(); + } +} + +OpenFile() +{ + if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path); + if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path); +} + + +void main() +{ + int id, key, mouse_clicked; + mouse mm; + + mem_Init(); + if (param) strcpy(#folder_path, #param); + list[SKINS].current = list[WALLPAPERS].current = 0; + list[SKINS].first = list[WALLPAPERS].first = 0; + GetFiles(WALLPAPERS); + list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18); + SetEventMask(0x27); + loop() + { + switch(WaitEvent()) + { + case evMouse: + mm.get(); + if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List(); + /* + if (mouse_clicked) + { + if (!mm.lkm) && (list[active].ProcessMouse(mm.x, mm.y)) Apply(); + mouse_clicked=0; + } + if (mm.lkm) && (list[active].MouseOver(mm.x, mm.y)) mouse_clicked=1; + */ + EAX = active; + if (mm.lkm) + { + if (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply(); + if if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply(); + } + break; + + case evButton: + id=GetButtonID(); + if (id==1) ExitProcess(); + if (id==2) TabClick(SKINS); + if (id==3) TabClick(WALLPAPERS); + break; + + case evKey: + key = GetKey(); + if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply(); + if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply(); + IF (key==013) OpenFile(); + if (key==9) //Tab + { + if (active==SKINS) + TabClick(WALLPAPERS); + else + TabClick(SKINS); + } + IF (key==182) //Del + { + DeleteFile(#cur_file_path); + Open_Dir(); + Apply(); + } + break; + + case evReDraw: + sc.get(); + DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER); + GetProcessInfo(#Form, SelfInfo); + IF (Form.status_window>=2) break; + DrawTabs(); + Draw_List(); + } + } +} + + +void DrawTabs() +{ + dword col_bg, col_text; + DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work); + + if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} + DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph); + DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, "Skins"); //вокруг рисовать пмятоуг + if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;} + DrawRectangle(90-1,7-1, 95+2, 21+2, sc.work_graph); + DrawCaptButton(90,7, 95, 21, 3, col_bg, col_text, "Wallpappers"); + + DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph); + DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee); +} + +void TabClick(int N) +{ + GetFiles(N); + DrawTabs(); + Draw_List(); +} + + + + +stop: diff --git a/programs/cmm/appearance/compile.bat b/programs/cmm/appearance/compile.bat new file mode 100644 index 0000000000..25c4202299 --- /dev/null +++ b/programs/cmm/appearance/compile.bat @@ -0,0 +1,5 @@ +..\C--\C-- appearance.c +@del appearance.kex +@rename appearance.com appearance.kex +@del warning.txt +@pause \ No newline at end of file diff --git a/programs/cmm/appearance/other.h b/programs/cmm/appearance/other.h new file mode 100644 index 0000000000..6e74f0cb86 --- /dev/null +++ b/programs/cmm/appearance/other.h @@ -0,0 +1,9 @@ +void Sort_by_Name(int a, b) +{ + int j, i = a; + if (a >= b) return; + for (j = a; j <= b; j++) + if (strcmp(files_mas[j]*304 + buf+72, files_mas[b]*304 + buf+72)<=0) { files_mas[i] >< files_mas[j]; i++;} + Sort_by_Name(a, i-2); + Sort_by_Name(i, b); +} \ No newline at end of file diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 97851fb2dc..ee73a91a08 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -177,7 +177,7 @@ void main() m.get(); - if (m.x > files.x) && (m.x < files.x + files.w) && (m.y > files.y) && (m.y < files.y+files.h) && (!can_select) + if (files.MouseOver(m.x, m.y)) && (!can_select) { m_selected = m.y - files.y / files.line_h; if (m.lkm) can_select = 1; diff --git a/programs/cmm/eolite/include/menu.h b/programs/cmm/eolite/include/menu.h index 4464fc99be..bb05377c99 100644 --- a/programs/cmm/eolite/include/menu.h +++ b/programs/cmm/eolite/include/menu.h @@ -97,7 +97,6 @@ void MenuListRedraw() { int start_y=0; int index; - int texty = menu.line_h/2-4; for (index=0; file_captions[index*3]!=0; index++) { if ((itdir) && (file_captions[index*3+2]>=200)) continue; @@ -110,10 +109,10 @@ void MenuListRedraw() else { DrawBar(2,start_y+2,menu.w-1,menu.line_h,sc.work); - WriteText(8,start_y+texty+3,0x80,0xf2f2f2,file_captions[index*3]); + WriteText(8,start_y+menu.text_y+3,0x80,0xf2f2f2,file_captions[index*3]); } - WriteText(7,start_y+texty+2,0x80,sc.work_text,file_captions[index*3]); - WriteText(-strlen(file_captions[index*3+1])*6-6+menu.w,start_y+texty+2,0x80,0x888888,file_captions[index*3+1]); + WriteText(7,start_y+menu.text_y+2,0x80,sc.work_text,file_captions[index*3]); + WriteText(-strlen(file_captions[index*3+1])*6-6+menu.w,start_y+menu.text_y+2,0x80,0x888888,file_captions[index*3+1]); start_y+=menu.line_h; } } \ No newline at end of file diff --git a/programs/cmm/lib/list_box.h b/programs/cmm/lib/list_box.h index e8d4123fd8..1b4ed3a1e1 100644 --- a/programs/cmm/lib/list_box.h +++ b/programs/cmm/lib/list_box.h @@ -2,9 +2,8 @@ struct llist { - int x, y, w, h, min_h, line_h; + int x, y, w, h, min_h, line_h, text_y; int count, visible, first, current; - int current_temp; void ClearList(); int ProcessKey(dword key); int MouseOver(int xx, yy); @@ -32,7 +31,9 @@ void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh) h = hh; min_h = min_hh; line_h = line_hh; + text_y = line_hh / 2 - 4; visible = h / line_h; + if (visible > count) visible=count; } @@ -60,10 +61,11 @@ int llist::MouseOver(int xx, yy) int llist::ProcessMouse(int xx, yy) { + int current_temp; if (MouseOver(xx, yy)) { current_temp = yy - y / line_h + first; - if (current_temp != current) + if (current_temp != current) && (current_temp