From d79ae6398fcbc762112d8328b5ab6fd1a0c15476 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 13 Apr 2020 21:08:28 +0000 Subject: [PATCH] easyshot v1.3, console: new scrollbar git-svn-id: svn://kolibrios.org@7783 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/dicty/dicty.c | 16 +- programs/cmm/easyshot/easyshot.c | 227 ++++++++---------- programs/cmm/lib/gui/more_less_box.h | 6 +- programs/cmm/lib/obj/libimg.h | 6 +- programs/cmm/lib/strings.h | 1 - programs/cmm/menu/menu.c | 2 +- programs/develop/libraries/console/build.bat | 2 +- .../libraries/console_coff/conscrlv.bmp | Bin 6006 -> 6006 bytes 8 files changed, 112 insertions(+), 148 deletions(-) diff --git a/programs/cmm/dicty/dicty.c b/programs/cmm/dicty/dicty.c index a421eb407f..34a83372d3 100644 --- a/programs/cmm/dicty/dicty.c +++ b/programs/cmm/dicty/dicty.c @@ -82,9 +82,9 @@ void main() if (Form.status_window>2) break; if (Form.height<140) { MoveSize(OLD,OLD,OLD,140); break; } if (Form.width<400) { MoveSize(OLD,OLD,400,OLD); break; } - DrawBar(0, 0, Form.width-9, TOPH, system.color.work); //top bg - DrawBar(0, TOPH, Form.width-9, 1, system.color.work_graph); - edit1.width=Form.width-edit1.left-edit1.left-9 - 116; + DrawBar(0, 0, Form.cwidth, TOPH, system.color.work); //top bg + DrawBar(0, TOPH, Form.cwidth, 1, system.color.work_graph); + edit1.width=Form.cwidth-edit1.left-edit1.left - 116; edit_box_draw stdcall(#edit1); DrawWideRectangle(edit1.left-2, edit1.top-2, edit1.width+3, 25, 2, 0xffffff); DrawRectangle(edit1.left-3, edit1.top-3, edit1.width+4, 26, system.color.work_graph); @@ -98,11 +98,11 @@ void main() void DrawLangButtons() { dword direction; - DrawBar(Form.width-120, edit1.top+3, 100, 25, system.color.work); - DefineButton(Form.width-88, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button); - WriteText(Form.width-82, edit1.top-1+3, 10000001b, system.color.work_button_text, "\26"); + DrawBar(Form.cwidth-111, edit1.top+3, 100, 25, system.color.work); + DefineButton(Form.cwidth-79, edit1.top-4+3, 20, 20, BUTTON_CHANGE_LANGUAGE, system.color.work_button); + WriteText(Form.cwidth-73, edit1.top-1+3, 10000001b, system.color.work_button_text, "\26"); if (active_dict == ENG_RUS) direction = TEXT_VOC_R_E; else direction = TEXT_VOC_E_R; - WriteText(Form.width-120, edit1.top+3, 0x90, system.color.work_text, direction); + WriteText(Form.cwidth-111, edit1.top+3, 0x90, system.color.work_text, direction); } void Translate() @@ -156,7 +156,7 @@ void DrawTranslation() char draw_buf[4096]; strlcpy(#draw_buf, #translate_result, sizeof(draw_buf)-1); - DrawBar(0, y_pos, Form.width-9, Form.cheight - y_pos, 0xFFFFFF); + DrawBar(0, y_pos, Form.cwidth, Form.cheight - y_pos, 0xFFFFFF); strttl(#draw_buf); WriteTextB(10+1, y_pos+8, 10000001b, 0x800080, #search_word); diff --git a/programs/cmm/easyshot/easyshot.c b/programs/cmm/easyshot/easyshot.c index eedcc50e75..19270f7ed4 100644 --- a/programs/cmm/easyshot/easyshot.c +++ b/programs/cmm/easyshot/easyshot.c @@ -14,62 +14,52 @@ /* === TRANSLATIONS === */ -#define T_WTITLE "EasyShot v1.1" - #ifdef LANG_RUS - ?define T_TAKE_SCREENSHOT " Сделать скриншот" + ?define T_TAKE_SCREENSHOT "Сделать скриншот" ?define T_SETTINGS "Настройки" - ?define T_EDITBOX_FRAME " Путь сохранения скриншота " - ?define T_CONTINUOUS_SHOOTING "Continuous shooting" + ?define T_EDITBOX_FRAME "Путь сохранения скриншота" ?define T_DELAY "Задержка в секундах" ?define T_NO_DIR "'Папка не существует!' -E" - ?define T_SET_PATH "Задать" #else - ?define T_TAKE_SCREENSHOT " Take a screenshot" + ?define T_TAKE_SCREENSHOT "Take a screenshot" ?define T_SETTINGS "Settings" - ?define T_EDITBOX_FRAME " Save path " - ?define T_CONTINUOUS_SHOOTING "Continuous shooting" + ?define T_EDITBOX_FRAME "Save path" ?define T_DELAY "Delay in seconds" ?define T_NO_DIR "'Directory does not exists!' -E" - ?define T_SET_PATH "Set" #endif /* === DATA === */ proc_info Form; -proc_info Settings; - -dword screenshot; -int screenshot_length; enum { BTN_MAKE_SCREENSHOT=10, - BTN_SETTINGS + BTN_SETTINGS, + BTN_CHOOSE_SAVING_PATH }; #define PD 18 //padding +#define SETTINGS_Y PD+PD+30+10 char save_path[4096]; -char save_path_stable[4096]; char open_dir[4096]; -edit_box edit_save = {250,25,100,0xffffff,0x94AECE,0xFFFfff,0xffffff, +more_less_box delay = { 1, 0, SETTINGS_Y, T_DELAY }; +edit_box edit_save = {260,PD,SETTINGS_Y+50,0xffffff,0x94AECE,0xFFFfff,0xffffff, 0x10000000,sizeof(save_path)-2,#save_path,0, 0b}; -more_less_box delay = { 1, 0, 64, T_DELAY }; -checkbox continuous_shooting = { T_CONTINUOUS_SHOOTING, true }; - +bool show_settings = false; opendialog open_folder_dialog = { 2, //0-file, 2-save, 3-select folder - #Settings, + #Form, #communication_area_name, 0, 0, //dword opendir_path, #open_dir, //dword dir_default_path, #open_dialog_path, - #DrawSettingsWindow, + #DrawWindow, 0, #open_dir, //dword openfile_path, 0, //dword filename_area, @@ -82,85 +72,24 @@ opendialog open_folder_dialog = /* === CODE === */ -void main() -{ - int id; - +void init_libraries() +{ 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: - id = GetButtonID(); - if (id == CLOSE_BTN) ExitProcess(); - if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot(); - if (id == BTN_SETTINGS) CreateThread(#SettingsWindow,#settings_stak+4092); - break; - - case evKey: - GetKeys(); - if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); - break; - - case evReDraw: - DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270, - skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0); - GetProcessInfo(#Form, SelfInfo); - DrawMainContent(); - } + OpenDialog_init stdcall (#open_folder_dialog); } -void DrawMainContent() -{ - int take_scr_btn_width; - take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 45); - DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10); -} +void main() +{ + int id; -void EventTakeScreenshot() { - MinimizeWindow(); - pause(delay.value*100); - CopyScreen(screenshot, 0, 0, screen.width, screen.height); - ActivateWindow(GetProcessSlot(Form.ID)); - EventSaveImageFile(); -} + init_libraries(); -void EventSaveImageFile() -{ - int i=0; - char save_file_name[4096]; - do { - i++; - //sprintf(, "%s/screen_%i.png", #save_path_stable, i); - strcpy(#save_file_name, #save_path_stable); - strcat(#save_file_name, "/screen_"); - strcat(#save_file_name, itoa(i)); - strcat(#save_file_name, ".png"); - } while (file_exists(#save_file_name)); - save_image(screenshot, screen.width, screen.height, #save_file_name); -} + strcpy(#save_path, "/tmp0/1"); + EditBox_UpdateText(#edit_save, 0); - -void SettingsWindow() -{ - #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()) { @@ -168,61 +97,93 @@ void SettingsWindow() edit_box_mouse stdcall (#edit_save); break; + case evButton: + id = GetButtonID(); + switch(id){ + case CLOSE_BTN: ExitProcess(); + case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break; + case BTN_SETTINGS: EventClickSettings(); break; + case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break; + default: delay.click(id); + } + break; + case evKey: GetKeys(); + if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); if (SCAN_CODE_ESC == key_scancode) ExitProcess(); EAX = key_editbox; 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); - break; - + case evReDraw: - DrawSettingsWindow(); + DrawWindow(); } } -void DrawSettingsWindow() + +void DrawWindow() { - DefineAndDrawWindow(Form.left+100, Form.top-40, 400, 230, 0x34, system.color.work, T_SETTINGS, 0); - GetProcessInfo(#Settings, SelfInfo); - delay.draw(15, 30); - 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 i; + + system.color.get(); + DefineAndDrawWindow(screen.width-400, screen.height/3, 270, + skin_height + 30+PD+PD, 0x34, system.color.work, "EasyShot",0); + GetProcessInfo(#Form, SelfInfo); + + DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT); + DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, system.color.work_button); + for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, system.color.work_button_text); + delay.draw(PD, SETTINGS_Y); + DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH); } -int DrawIconButton(dword x, y, id, text, icon) + +void EventChooseSavePath() { - int btwidth; - btwidth = DrawStandartCaptButton(x, y, id, text); - img_draw stdcall(skin.image, x+12, y+5, 16, 16, 0, icon*16); - return btwidth; + OpenDialog_start stdcall (#open_folder_dialog); + if (open_folder_dialog.status) { + strcpy(#save_path, open_folder_dialog.opendir_path); + EditBox_UpdateText(#edit_save, 0); + } } -stop: -char settings_stak[4096]; \ No newline at end of file +void EventClickSettings() +{ + show_settings ^= 1; + MoveSize(OLD, OLD, show_settings*75 + 270, + show_settings*110 + skin_height + PD+PD+30); +} + + +void EventTakeScreenshot() +{ + int i=0; + char save_file_name[4096]; + static dword screenshot; + + if (!screenshot) screenshot = malloc(screen.width * screen.height * 3); + + do { + i++; + //sprintf(, "%s/screen_%i.png", #save_path, i); + strcpy(#save_file_name, #save_path); + if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/'); + strcat(#save_file_name, "screen_"); + strcat(#save_file_name, itoa(i)); + strcat(#save_file_name, ".png"); + } while (file_exists(#save_file_name)); + + if (!dir_exists(#save_path)) { + notify(T_NO_DIR); + return; + } + + MinimizeWindow(); + pause(delay.value*100); + CopyScreen(screenshot, 0, 0, screen.width, screen.height); + save_image(screenshot, screen.width, screen.height, #save_file_name); + ActivateWindow(GetProcessSlot(Form.ID)); +} + diff --git a/programs/cmm/lib/gui/more_less_box.h b/programs/cmm/lib/gui/more_less_box.h index 9912f57a1a..0a4db8ad59 100644 --- a/programs/cmm/lib/gui/more_less_box.h +++ b/programs/cmm/lib/gui/more_less_box.h @@ -23,6 +23,7 @@ :bool more_less_box::click(unsigned id) { + if (disabled) return 0; if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; } if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; } return 0; @@ -42,7 +43,7 @@ { #define VALUE_FIELD_W 34 #define SIZE 18 - dword text_col = system.color.work_text; + dword text_col; dword value_text = itoa(value); check_values(); @@ -55,11 +56,12 @@ { DrawRectangle(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xffffff); DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xCCCccc); - text_col = MixColors(system.color.work, system.color.work_text, 128); + text_col = system.color.work_graph; } else { DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); + text_col = system.color.work_text; } WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); diff --git a/programs/cmm/lib/obj/libimg.h b/programs/cmm/lib/obj/libimg.h index 0078e6a459..b01b456e1a 100644 --- a/programs/cmm/lib/obj/libimg.h +++ b/programs/cmm/lib/obj/libimg.h @@ -219,11 +219,13 @@ struct _Image } else { if (CreateFile(encoded_size, encoded_data, _path) == 0) { - sprintf(#save_success_message, "'File saved as %s' -O", _path); + strcpy(#save_success_message, "'File saved as "); + strcat(#save_success_message, _path); + strcat(#save_success_message, "' -O"); notify(#save_success_message); } else { - notify("'Error saving image file!\nProbably not enought space or file system is not writable!\nPlease, check saving path.' -E"); + notify("'Error saving image file!\nNot enough space? Path wrong?\nFile system is not writable?..' -E"); } } } diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index 301edeca59..833417d86c 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -867,7 +867,6 @@ inline cdecl int sprintf(dword buf, format,...) strlcpy(buf,"0x00000000",10); buf+=10; l=buf; - debugval("tmp", tmp); while(tmp) { $dec buf diff --git a/programs/cmm/menu/menu.c b/programs/cmm/menu/menu.c index fe1468846c..29b98f97ea 100644 --- a/programs/cmm/menu/menu.c +++ b/programs/cmm/menu/menu.c @@ -103,7 +103,7 @@ void main() break; case evReDraw: - DefineAndDrawWindow(win_x, win_y, menu1.w+4, menu1.h+3, 0x01, 0, 0, 0x01fffFFF); + DefineAndDrawWindow(win_x, win_y, menu1.w+4, menu1.h+4, 0x01, 0, 0, 0x01fffFFF); system.color.get(); Draw3DPopup(0,0,menu1.w+2,menu1.h+2); draw_list(); diff --git a/programs/develop/libraries/console/build.bat b/programs/develop/libraries/console/build.bat index b968338fb1..b1cd150b1f 100644 --- a/programs/develop/libraries/console/build.bat +++ b/programs/develop/libraries/console/build.bat @@ -1,3 +1,3 @@ -fasm console.asm console.obj +fasm console.asm console.dll kpack console.obj pause \ No newline at end of file diff --git a/programs/develop/libraries/console_coff/conscrlv.bmp b/programs/develop/libraries/console_coff/conscrlv.bmp index 1ccc67f00c9f841bc15b321a39a0f93b95c73896..5c6b25b64c970ae2f73b9554e64843be8dc05727 100644 GIT binary patch literal 6006 zcmeH{L2iUF3`ISMs5;!B7igE&s9RJCY1X|%S6y=iuF&ft4lzGu#*GMeQin~Xd?}F$ zJYznIKR$n+Y1JF%7mO#2FN_nNF%wefeCk2gP`wv=}P0l}z61D!P_CIOo`gItu`B(e- wx7W{P7{p#`{)Hss7{-dm<2I+*h10xGA;DR^0yjSO|8(>I{IfMrP;UR+07qedS^xk5 literal 6006 zcmeH}OHRWu5Qg1DAUFaiU|n_35x55H+zhef7N}D15q@XNpTTxK&IGASno(knV}JAV zqdmR8KZZeG&_3gR!25>x5T4M6aJ-HWoquY&uIu~$^W)3$#1Mo(e_!T4@Hg@Z!68>3 zA^2qU4<7y6z&Dy?Wz^t<5mwE3kef6mU8omc0_@#8ht4_A;+xVsl9@Qg@& z65WE|@cqfcI`{v2c}A`kT?K5JI8<4GO+wc&beqQ{nn>VQUQFch4892OeB1g>6)&yd z+V4+C{6OOF#`(cXsMKj{=q~vD+F&{C{419StQb6DQRtRRjZfgBi5f3XXoWttvVC4> zo9lM|IitU9ieL2q4Ofs)xIq^v@QmQG7>*~p6<#lFqrR#2FXqfuDURCtua{@!T1l#4 h46V+Kv+a1$>kif}7G1@HXd^}F5u`2!U3IkW%(