From bacea4f8136bf96695a9d05bfa852e02b75e1f7a Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Fri, 20 Apr 2018 09:43:15 +0000 Subject: [PATCH] EasyShot going GOLD, added to distro git-svn-id: svn://kolibrios.org@7245 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/Tupfile.lua | 1 + programs/cmm/easyshot/easyshot.c | 112 ++++++++++++++---- programs/cmm/eolite/Eolite.c | 2 +- programs/cmm/eolite/include/settings.h | 9 +- programs/cmm/lib/gui.h | 12 +- programs/cmm/lib/obj/libimg.h | 2 +- programs/cmm/lib/obj/proc_lib.h | 16 +-- .../cmm/lib/patterns/simple_open_dialog.h | 4 - programs/cmm/liza/login.c | 8 +- 9 files changed, 119 insertions(+), 47 deletions(-) diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 64a3131488..6f1a2bb1ba 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -569,6 +569,7 @@ end -- tup.getconfig('NO_JWASM') ~= 'full' if tup.getconfig('NO_CMM') ~= 'full' then tup.append_table(img_files, { {"APP_PLUS", PROGS .. "/cmm/app_plus/app_plus.com"}, + {"EASYSHOT", PROGS .. "/cmm/easyshot/easyshot.com"}, {"TXTREAD", PROGS .. "/cmm/txtread/txtread.com"}, {"TMPDISK", PROGS .. "/cmm/tmpdisk/tmpdisk.com"}, {"GAME_CENTER", PROGS .. "/cmm/software_widget/software_widget.com"}, diff --git a/programs/cmm/easyshot/easyshot.c b/programs/cmm/easyshot/easyshot.c index 294ce563d4..c12a7a1909 100644 --- a/programs/cmm/easyshot/easyshot.c +++ b/programs/cmm/easyshot/easyshot.c @@ -6,6 +6,7 @@ #include "../lib/obj/libimg.h" #include "../lib/obj/box_lib.h" +#include "../lib/obj/proc_lib.h" #ifndef AUTOBUILD #include "lang.h--" @@ -13,12 +14,24 @@ /* === TRANSLATIONS === */ -#define T_WTITLE "EasyShot v0.76" +#define T_WTITLE "EasyShot v1.0" #ifdef LANG_RUS ?define T_TAKE_SCREENSHOT " Сделать скриншот" + ?define T_SETTINGS "Настройки" + ?define T_EDITBOX_FRAME " Путь сохранения скриншота " + ?define T_DELAY "Задержка в секундах" + ?define T_MINIMIZE "Свертуть окно при снимке" + ?define T_NO_DIR "'Папка не существует!' -E" + ?define T_SET_PATH "Задать" #else ?define T_TAKE_SCREENSHOT " Take a screenshot" + ?define T_SETTINGS "Settings" + ?define T_EDITBOX_FRAME " Save path " + ?define T_DELAY "Delay in seconds" + ?define T_MINIMIZE "Minimize window" + ?define T_NO_DIR "'Directory does not exists!' -E" + ?define T_SET_PATH "Set" #endif /* === DATA === */ @@ -35,15 +48,38 @@ enum { #define PD 18 //padding +char save_path[4096]; +char save_path_stable[4096]; +char open_dir[4096]; -char save_path[4096] = "/tmp0/1"; dword mouse_dd1; -edit_box edit_box_path = {270,10,70,0xffffff,0x94AECE,0xFFFfff,0xffffff, +edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff, 0x10000000,sizeof(save_path),#save_path,#mouse_dd1, 0b}; -more_less_box delay = { 1, 0, 64, "Delay in seconds" }; -checkbox minimise = { "Minimize window", true }; +more_less_box delay = { 1, 0, 64, T_DELAY }; +checkbox minimize = { T_MINIMIZE, true }; +proc_info Settings; + +opendialog open_folder_dialog = +{ + 2, //0-file, 2-save, 3-select folder + #Settings, + #communication_area_name, + 0, + 0, //dword opendir_path, + #open_dir, //dword dir_default_path, + #open_dialog_path, + #DrawSettingsWindow, + 0, + #open_dir, //dword openfile_path, + 0, //dword filename_area, + 0, //dword filter_area, + 420, + NULL, + 320, + NULL +}; /* === CODE === */ @@ -54,11 +90,20 @@ void main() load_dll(libio, #libio_init, 1); load_dll(libimg, #libimg_init, 1); load_dll(boxlib, #box_lib_init,0); + load_dll(Proc_lib, #OpenDialog_init,0); + OpenDialog_init stdcall (#open_folder_dialog); + system.color.get(); Libimg_LoadImage(#skin, "/sys/icons16.png"); + Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffFFFfff, system.color.work_button); + Libimg_ReplaceColor(skin.image, skin.w, skin.h, 0xffCACBD6, MixColors(system.color.work_button, 0, 200)); screenshot_length = screen.width * screen.height * 3; screenshot = malloc(screenshot_length); + strcpy(#save_path_stable, "/tmp0/1"); + strcpy(#save_path, #save_path_stable); + edit_save.size = strlen(#save_path); + loop() switch(WaitEvent()) { case evButton: @@ -91,11 +136,11 @@ void DrawMainContent() } void EventTakeScreenshot() { - if (minimise.checked) MinimizeWindow(); + if (minimize.checked) MinimizeWindow(); pause(delay.value*100); CopyScreen(screenshot, 0, 0, screen.width, screen.height); ActivateWindow(GetProcessSlot(Form.ID)); - if (!minimise.checked) DrawMainContent(); + if (!minimize.checked) DrawMainContent(); EventSaveImageFile(); } @@ -105,7 +150,7 @@ void EventSaveImageFile() char save_file_name[4096]; do { i++; - sprintf(#save_file_name, "%s/screen_%i.png", #save_path, i); + sprintf(#save_file_name, "%s/screen_%i.png", #save_path_stable, i); } while (file_exists(#save_file_name)); save_image(screenshot, screen.width, screen.height, #save_file_name); } @@ -113,43 +158,70 @@ void EventSaveImageFile() void SettingsWindow() { - int id; - SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); + #define BTN_OD 10 + #define BTN_SET 11 + int id, butw; + SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); loop() switch(WaitEvent()) { case evMouse: - //edit_box_mouse stdcall (#address_box); + edit_box_mouse stdcall (#edit_save); break; case evKey: GetKeys(); if (SCAN_CODE_ESC == key_scancode) ExitProcess(); + EAX= key_ascii << 8; + edit_box_key stdcall (#edit_save); break; case evButton: id = GetButtonID(); if (CLOSE_BTN == id) ExitProcess(); + if (BTN_OD == id) { + OpenDialog_start stdcall (#open_folder_dialog); + if (open_folder_dialog.status) { + strcpy(#save_path, open_folder_dialog.opendir_path); + edit_save.size = edit_save.pos = edit_save.shift + = edit_save.shift_old = strlen(#save_path); + } + } + if (BTN_SET == id) { + if (save_path[0]) && (dir_exists(#save_path)) { + strcpy(#save_path_stable, #save_path); + strrtrim(#save_path_stable); + if (save_path_stable[strlen(#save_path_stable)-1]=='/') + save_path_stable[strlen(#save_path_stable)-1]=NULL; //no "/" at the end + } + else notify(T_NO_DIR); + + } delay.click(id); - minimise.click(id); + minimize.click(id); break; case evReDraw: - DefineAndDrawWindow(Form.left+100, Form.top-40, 330, 170, 0x34, system.color.work, "Settings",0); - _DRAW_CONTENT: - minimise.draw(15, 10); - delay.draw(15, 40); - //DrawEditBox(#edit_box_path); + DrawSettingsWindow(); } } +void DrawSettingsWindow() +{ + DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0); + GetProcessInfo(#Settings, SelfInfo); + minimize.draw(15, 15); + delay.draw(15, 45); + DrawFrame(15, 85, 360, 95, T_EDITBOX_FRAME); + DrawEditBoxPos(32, 110, #edit_save); + DrawStandartCaptButton(edit_save.left + edit_save.width + 15, edit_save.top-3, BTN_OD, "..."); + DrawStandartCaptButton(edit_save.left, edit_save.top+32, BTN_SET, T_SET_PATH); +} + int DrawIconButton(dword x, y, id, text, icon) { int btwidth; - system.color.work_button = 0xFFFfff; - system.color.work_button_text = 0; btwidth = DrawStandartCaptButton(x, y, id, text); img_draw stdcall(skin.image, x+12, y+5, 16, 16, 0, icon*16); - system.color.get(); return btwidth; } diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 9142d8f2e8..3ef79b711b 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -162,7 +162,7 @@ void main() if (param) { - if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" in the end + if (strlen(#param)>1) && (param[strlen(#param)-1]=='/') param[strlen(#param)-1]=NULL; //no "/" at the end if (dir_exists(#param)==true) { diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index fe92905344..ebcb1b837d 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -25,7 +25,7 @@ ?define USE_TWO_PANELS "Two panels" ?define FONT_SIZE_LABEL "Font size" ?define LIST_LINE_HEIGHT "List line height" - ?define SAVE_PATH_AS_DEFAULT "Сurrent path" + ?define SAVE_PATH_AS_DEFAULT "Current path" ?define SAVE_START_PATH_AS_DEFAULT "Typed path" ?define EDIT_FILE_ASSOCIATIONS "Edit file associations" ?define START_PATH " Start path: " @@ -74,8 +74,7 @@ void settings_dialog() else if (id==6) { strcpy(#path_start,#path); - path_start_ed.size = strlen(#path_start); - path_start_ed.pos = strlen(#path_start); + path_start_ed.size = path_start_ed.pos = strlen(#path_start); ini.SetString("DefaultPath", #path, strlen(#path)); edit_box_draw stdcall (#path_start_ed); break; @@ -141,9 +140,7 @@ void DrawSettingsCheckBoxes() DrawFrame(x, y.inc(37), 340, 95, START_PATH); // START_PATH { - path_start_ed.top = y.inc(21); - path_start_ed.left = frx; - DrawEditBox(#path_start_ed); + DrawEditBoxPos(frx, y.inc(21), #path_start_ed); but_x = DrawStandartCaptButton(frx, y.inc(34), 6, SAVE_PATH_AS_DEFAULT); DrawStandartCaptButton(frx+but_x, y.inc(0), 7, SAVE_START_PATH_AS_DEFAULT); // } START_PATH diff --git a/programs/cmm/lib/gui.h b/programs/cmm/lib/gui.h index 6681837551..8a07cf75d5 100644 --- a/programs/cmm/lib/gui.h +++ b/programs/cmm/lib/gui.h @@ -116,19 +116,27 @@ :void DrawEditBox(dword edit_box_pointer) { - dword x,y,w,h,bg; + dword x,y,w,h,bg,t; ESI = edit_box_pointer; x = ESI.edit_box.left; y = ESI.edit_box.top; w = ESI.edit_box.width+1; + h = 22; if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff; edit_box_draw stdcall (edit_box_pointer); - h = 22; DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg); DrawRectangle(x-2, y-2, w+3, h+3, system.color.work_graph); DrawRectangle3D(x-3, y-3, w+5, h+5, system.color.work_dark, system.color.work_light); } +:void DrawEditBoxPos(dword x,y, edit_box_pointer) +{ + ESI = edit_box_pointer; + ESI.edit_box.left = x; + ESI.edit_box.top = y; + DrawEditBox(dword edit_box_pointer); +} + :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) { int progress_w; diff --git a/programs/cmm/lib/obj/libimg.h b/programs/cmm/lib/obj/libimg.h index 435f403b33..a9bd81acf0 100644 --- a/programs/cmm/lib/obj/libimg.h +++ b/programs/cmm/lib/obj/libimg.h @@ -221,7 +221,7 @@ struct _Image notify(#save_success_message); } else { - notify("'Error saving file! Probably not enought space or file system is not writable!' -E"); + notify("'Error saving image file!\nProbably not enought space or file system is not writable!\nPlease, check saving path.' -E"); } } } diff --git a/programs/cmm/lib/obj/proc_lib.h b/programs/cmm/lib/obj/proc_lib.h index 1835ddd374..9225126643 100644 --- a/programs/cmm/lib/obj/proc_lib.h +++ b/programs/cmm/lib/obj/proc_lib.h @@ -21,7 +21,7 @@ char aOpenDialog_start[] = "OpenDialog_start"; struct opendialog { - dword type; + dword type; //0-file, 2-save, 3-select folder dword procinfo; dword com_area_name; dword com_area; @@ -30,15 +30,17 @@ struct opendialog dword start_path; dword draw_window; dword status; - dword openfile_pach; + dword openfile_path; dword filename_area; dword filter_area; - word x_size; - word x_start; - - word y_size; - word y_start; + word w; + word x; + word h; + word y; }; +char communication_area_name[] = "FFFFFFFF_open_dialog"; +char open_dialog_path[] = "/rd/1/File managers/opendial"; + #endif \ No newline at end of file diff --git a/programs/cmm/lib/patterns/simple_open_dialog.h b/programs/cmm/lib/patterns/simple_open_dialog.h index 5ea08714e8..f333386b46 100644 --- a/programs/cmm/lib/patterns/simple_open_dialog.h +++ b/programs/cmm/lib/patterns/simple_open_dialog.h @@ -4,15 +4,11 @@ struct od_filter char ext[16]; }; - proc_info pr_inf; -char communication_area_name[] = "FFFFFFFF_open_dialog"; char opendir_path[3072]; -char open_dialog_path[] = "/rd/1/File managers/opendial"; char openfile_path[4096]; char filename_area[1024]; - opendialog o_dialog = { 0, #pr_inf, diff --git a/programs/cmm/liza/login.c b/programs/cmm/liza/login.c index e2db6705f4..42df804806 100644 --- a/programs/cmm/liza/login.c +++ b/programs/cmm/liza/login.c @@ -181,14 +181,10 @@ void DrawLoginScreen() DrawBar(0,0, Form.cwidth, Form.cheight, system.color.work); WriteText(panel_x,panel_y-3,0x80,system.color.work_text,"Your Email:"); - login_box.left = panel_x+3; - login_box.top = panel_y+12; - DrawEditBox(#login_box); + DrawEditBoxPos(panel_x+3, panel_y+12, #login_box); WriteText(panel_x,panel_y+45,0x80,system.color.work_text,"Password:"); - pass_box.left = panel_x+3; - pass_box.top = panel_y+60; - DrawEditBox(#pass_box); + DrawEditBoxPos(panel_x+3, panel_y+60, #pass_box); if (!aim) {