update EasyShot

git-svn-id: svn://kolibrios.org@7235 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-04-17 17:43:32 +00:00
parent 54a4334108
commit cb04881600
3 changed files with 19 additions and 69 deletions

View File

@ -13,38 +13,28 @@
/* === TRANSLATIONS === */ /* === TRANSLATIONS === */
#define T_WTITLE "EasyShot v0.7" #define T_WTITLE "EasyShot v0.75"
#ifdef LANG_RUS #ifdef LANG_RUS
?define T_TAKE_SCREENSHOT " ‘¤¥« âì áªà¨­è®â" ?define T_TAKE_SCREENSHOT " ‘¤¥« âì áªà¨­è®â"
?define T_SAVE " ‘®åà ­¨âì"
?define T_PREVIEW "<EFBFBD>।¯à®á¬®âà"
#else #else
?define T_TAKE_SCREENSHOT " Take a screenshot" ?define T_TAKE_SCREENSHOT " Take a screenshot"
?define T_SAVE " Save"
?define T_PREVIEW "Preview"
#endif #endif
/* === DATA === */ /* === DATA === */
proc_info Form; proc_info Form;
dword screenshot, dword screenshot;
preview;
int screenshot_length, int screenshot_length;
preview_length;
enum { enum {
BTN_MAKE_SCREENSHOT=10, BTN_MAKE_SCREENSHOT=10,
BTN_SAVE,
BTN_SETTINGS BTN_SETTINGS
}; };
#define PD 18 //padding #define PD 18 //padding
#define TOOLBAR_H 20+PD
block pw;
struct _settings { struct _settings {
bool minimise; bool minimise;
@ -65,11 +55,8 @@ void main()
Libimg_LoadImage(#skin, "/sys/icons16.png"); Libimg_LoadImage(#skin, "/sys/icons16.png");
screenshot_length = screen.width * screen.height * 3; screenshot_length = screen.width * screen.height * 3;
pw.set_size(PD, TOOLBAR_H+PD, screen.width/2, screen.height/2);
preview_length = screenshot_length / 2;
screenshot = malloc(screenshot_length); screenshot = malloc(screenshot_length);
preview = malloc(screenshot_length/2);
loop() switch(WaitEvent()) loop() switch(WaitEvent())
{ {
@ -77,22 +64,20 @@ void main()
id = GetButtonID(); id = GetButtonID();
if (id == CLOSE_BTN) ExitProcess(); if (id == CLOSE_BTN) ExitProcess();
if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot(); if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot();
if (id == BTN_SAVE) EventSaveImageFile();
if (id == BTN_SETTINGS) EventShowSettings(); if (id == BTN_SETTINGS) EventShowSettings();
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
if (SCAN_CODE_KEY_S == key_scancode) EventSaveImageFile();
if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot();
break; break;
case evReDraw: case evReDraw:
DefineAndDrawWindow(screen.width/4, screen.height/4, pw.w + 9 +PD+PD, system.color.get();
pw.h + skin_height + TOOLBAR_H + 4 +PD+PD, 0x74, 0, T_WTITLE,0); DefineAndDrawWindow(screen.width/4, screen.height-100/3, 270,
skin_height + 27+PD+PD, 0x34, system.color.work, T_WTITLE,0);
GetProcessInfo(#Form, SelfInfo); GetProcessInfo(#Form, SelfInfo);
if (Form.status_window>2) break; if (Form.status_window>2) break;
system.color.get();
DrawMainContent(); DrawMainContent();
} }
} }
@ -100,28 +85,17 @@ void main()
void DrawMainContent() void DrawMainContent()
{ {
int take_scr_btn_width; int take_scr_btn_width;
DrawBar(0, 0, Form.cwidth, TOOLBAR_H, system.color.work); take_scr_btn_width = DrawIconButton(PD, PD, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
DrawWideRectangle(0, TOOLBAR_H, pw.w+PD+PD, pw.h+PD+PD, PD-1, system.color.work); DrawIconButton(PD+take_scr_btn_width, PD, BTN_SETTINGS, " ", 10);
DrawRectangle(pw.x-1, pw.y-1, pw.w+1, pw.h+1, system.color.work_graph);
take_scr_btn_width = DrawIconButton(pw.x, pw.y-42, BTN_MAKE_SCREENSHOT, T_TAKE_SCREENSHOT, 44);
if (ESDWORD[preview]==0) {
DrawBar(pw.x, pw.y, pw.w, pw.h, 0xEEEeee);
WriteText(Form.cwidth-calc(strlen(T_PREVIEW)*8)/2, pw.h/2+pw.y, 0x90, 0x777777, T_PREVIEW);
}
else {
_PutImage(pw.x, pw.y, pw.w, pw.h, preview);
DrawIconButton(take_scr_btn_width + pw.x, pw.y-42, BTN_SAVE, T_SAVE, 5);
}
DrawIconButton(Form.cwidth-40-PD, pw.y-42, BTN_SETTINGS, " ", 10);
} }
void EventTakeScreenshot() { void EventTakeScreenshot() {
if (settings.minimise) MinimizeWindow(); if (settings.minimise) MinimizeWindow();
pause(settings.delay*100); pause(settings.delay*100);
CopyScreen(screenshot, 0, 0, screen.width, screen.height); CopyScreen(screenshot, 0, 0, screen.width, screen.height);
ZoomImageTo50percent();
ActivateWindow(GetProcessSlot(Form.ID)); ActivateWindow(GetProcessSlot(Form.ID));
if (!settings.minimise) DrawMainContent(); if (!settings.minimise) DrawMainContent();
EventSaveImageFile();
} }
void EventSaveImageFile() void EventSaveImageFile()
@ -184,39 +158,6 @@ inline byte calc_rgb(dword B, item_h)
+ ESBYTE[B-item_h] + ESBYTE[B+item_h] / 5); + ESBYTE[B-item_h] + ESBYTE[B+item_h] / 5);
} }
void ZoomImageTo50percent() {
dword point_x = 0;
dword item_h = screen.width * 3;
dword small = preview;
dword big = screenshot;
while( (small <= preview + preview_length) && (big <= screenshot + screenshot_length ) ) {
if (big <= screenshot + item_h) || (big >= screenshot + screenshot_length - item_h)
{
ESBYTE[small] = ESBYTE[big];
ESBYTE[small+1] = ESBYTE[big+1];
ESBYTE[small+2] = ESBYTE[big+2];
}
else
{
ESBYTE[small] = calc_rgb(big, item_h);
ESBYTE[small+1] = calc_rgb(big+1, item_h);
ESBYTE[small+2] = calc_rgb(big+2, item_h);
}
small+=3;
big+=6;
point_x+=2;
if (point_x >= screen.width)
{
big += item_h;
point_x = 0;
}
}
}
int DrawIconButton(dword x, y, id, text, icon) int DrawIconButton(dword x, y, id, text, icon)
{ {
int btwidth; int btwidth;

View File

@ -276,6 +276,15 @@ inline fastcall int GetSystemLanguage()
$int 0x40 $int 0x40
} }
#define BUTTON_STYLE_FLAT 0
#define BUTTON_STYLE_GRADIENT 1
inline fastcall SetButtonStyle(ECX) //ECX - button style
{
$mov eax,48
$mov ebx,1
int 64
}
inline fastcall GetSkinHeight() inline fastcall GetSkinHeight()
{ {
$push ebx $push ebx

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB