From a689de57c56c0c314f647a3a19ad83b6bafda780 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Sat, 8 Jan 2022 19:52:20 +0000 Subject: [PATCH] ImageEdit: work in progress git-svn-id: svn://kolibrios.org@9597 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/app_plus/app_plus.c | 2 +- programs/cmm/appearance/appearance.c | 2 +- programs/cmm/barscfg/barscfg.c | 2 +- programs/cmm/downloader/dl.c | 2 +- programs/cmm/eolite/Eolite.c | 2 +- programs/cmm/eolite/include/about.h | 2 +- programs/cmm/eolite/include/progress_dialog.h | 6 +- programs/cmm/eolite/include/properties.h | 2 +- programs/cmm/eolite/include/settings.h | 2 +- programs/cmm/examples/info.c | 2 +- programs/cmm/examples/rgb.c | 2 +- programs/cmm/iconedit/canvas_resize.h | 2 +- programs/cmm/iconedit/iconedit.c | 4 +- programs/cmm/iconedit/tools/screen_copy.h | 6 +- programs/cmm/imgedit/imgedit.c | 208 +++++++++++------- programs/cmm/kf_font_viewer/font_viewer.c | 2 +- programs/cmm/lib/gui/menu.h | 2 +- programs/cmm/lib/kolibri.h | 16 +- programs/cmm/lib/mouse.h | 2 +- programs/cmm/misc/easyshot.c | 12 +- programs/cmm/misc/install.c | 4 +- programs/cmm/misc/osupdate.c | 4 +- programs/cmm/misc/software_widget.c | 10 +- programs/cmm/mousecfg/mousecfg.c | 2 +- programs/cmm/pixie2/pixie.c | 2 +- programs/cmm/quark/prepare_page.h | 2 +- programs/cmm/search/search.c | 2 +- programs/cmm/sysmon/sysmon.c | 2 +- programs/cmm/taskbar2/taskbar2.c | 16 +- 29 files changed, 191 insertions(+), 133 deletions(-) diff --git a/programs/cmm/app_plus/app_plus.c b/programs/cmm/app_plus/app_plus.c index 5238805ccc..d97f24416c 100644 --- a/programs/cmm/app_plus/app_plus.c +++ b/programs/cmm/app_plus/app_plus.c @@ -103,7 +103,7 @@ void main() void draw_window() { sc.get(); - DefineAndDrawWindow(screen.width-WINW/2, 100, WINW, WINH+skin_height, 0x34, sc.work, WINDOW_TITLE_TEXT,0); + DefineAndDrawWindow(screen.w-WINW/2, 100, WINW, WINH+skin_height, 0x34, sc.work, WINDOW_TITLE_TEXT,0); WriteTextB(CONX+2,SCRY+2,0x81,MixColors(sc.work, 0xB92234,220),CONTENT_HEADER_TEXT); WriteTextB(CONX,SCRY,0x81,0xB92234,CONTENT_HEADER_TEXT); draw_screen(); diff --git a/programs/cmm/appearance/appearance.c b/programs/cmm/appearance/appearance.c index 6eac8e778d..e1266c6b49 100644 --- a/programs/cmm/appearance/appearance.c +++ b/programs/cmm/appearance/appearance.c @@ -124,7 +124,7 @@ void main() void draw_window() { sc.get(); - DefineAndDrawWindow(screen.width-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x74,sc.work,WINDOW_HEADER,0); + DefineAndDrawWindow(screen.w-WIN_W-9/2,80,WIN_W+9,WIN_H+4+skin_height,0x74,sc.work,WINDOW_HEADER,0); DrawBar(0, 0, WIN_W, PANEL_H-2, sc.work); //top DrawBar(0, PANEL_H-2, LP-2, WIN_H-PANEL_H-LP+4, EDX); //left diff --git a/programs/cmm/barscfg/barscfg.c b/programs/cmm/barscfg/barscfg.c index f38c95d14c..f2246d772d 100644 --- a/programs/cmm/barscfg/barscfg.c +++ b/programs/cmm/barscfg/barscfg.c @@ -128,7 +128,7 @@ void main() case evReDraw: sc.get(); - DefineAndDrawWindow(130, 150, 465, 398 + skin_height, 0x34, sc.work, WINDOW_TITLE, 0); + DefineAndDrawWindow(130, 150, 465, 398 + skin_h, 0x34, sc.work, WINDOW_TITLE, 0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window&ROLLED_UP) break; DrawWindowContent(); diff --git a/programs/cmm/downloader/dl.c b/programs/cmm/downloader/dl.c index 86fa2e120b..27613a0515 100644 --- a/programs/cmm/downloader/dl.c +++ b/programs/cmm/downloader/dl.c @@ -94,7 +94,7 @@ void DrawWindow() sc.get(); pb.frame_color = sc.work_dark; DefineAndDrawWindow(110 + random(300), 100 + random(300), WIN_W+9, - WIN_H + 5 + skin_height, 0x34, sc.work, DL_WINDOW_HEADER, 0); + WIN_H + 5 + skin_h, 0x34, sc.work, DL_WINDOW_HEADER, 0); #define BUT_Y 58; //autoclose.draw(WIN_W-135, BUT_Y+6); diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index f046cc3fb8..38c01d61a9 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -547,7 +547,7 @@ void draw_window() GetProcessInfo(#Form, SelfInfo); SetAppColors(); if (efm) { - if (screen.width > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; } + if (screen.w > 693) && (Form.width < 693) { MoveSize(OLD,OLD,693,OLD); return; } DrawBar(0, 4, Form.cwidth, SELECTY-5, sc.work); DrawBar(0, SELECTY+KFM2_DEVH+1, Form.cwidth, 3, sc.work); DrawBar(0, SELECTY-1, 1, KFM2_DEVH+2, sc.work); diff --git a/programs/cmm/eolite/include/about.h b/programs/cmm/eolite/include/about.h index 534861d5e1..653081b4c1 100644 --- a/programs/cmm/eolite/include/about.h +++ b/programs/cmm/eolite/include/about.h @@ -33,7 +33,7 @@ void about_dialog() break; case evReDraw: - DefineAndDrawWindow(Form.left+Form.width/2,Form.top+Form.height/2-114,300,300+skin_height,0x34,sc.work,T_ABOUT,0); + DefineAndDrawWindow(Form.left+Form.width/2,Form.top+Form.height/2-114,300,300+skin_h,0x34,sc.work,T_ABOUT,0); GetProcessInfo(#about_form, SelfInfo); if (about_form.status_window>2) break; logo_pal[0] = sc.work; diff --git a/programs/cmm/eolite/include/progress_dialog.h b/programs/cmm/eolite/include/progress_dialog.h index e3c7a9a5d6..ba2dc8ef77 100644 --- a/programs/cmm/eolite/include/progress_dialog.h +++ b/programs/cmm/eolite/include/progress_dialog.h @@ -82,7 +82,7 @@ void DisplayOperationForm(int operation_flag) break; case evReDraw: DefineAndDrawWindow(Form.left+Form.width-200, Form.top+90, COPYFORM_W+9, - skin_height+COPYFORM_H, 0x34, sc.work, title, 0); + skin_h+COPYFORM_H, 0x34, sc.work, title, 0); GetProcessInfo(#Dialog_Form, SelfInfo); DrawCaptButton(COPYFORM_W-PR_LEFT-101, PR_TOP+PR_H+6, 100,26, BTN_ABORT, sc.button, sc.button_text, T_COPY_ABORT); @@ -115,8 +115,8 @@ void Operation_Draw_Progress(dword filename) { if (old_state != copy_state) { old_state = copy_state; - if (copy_state == FILE_EXISTS) MoveSize(OLD,OLD,OLD,skin_height+COPYFORM_H+70); - if (copy_state == FILE_DEFAULT) MoveSize(OLD,OLD,OLD,skin_height+COPYFORM_H); + if (copy_state == FILE_EXISTS) MoveSize(OLD,OLD,OLD,skin_h+COPYFORM_H+70); + if (copy_state == FILE_DEFAULT) MoveSize(OLD,OLD,OLD,skin_h+COPYFORM_H); } DisplayOperationForm(REDRAW_FLAG); diff --git a/programs/cmm/eolite/include/properties.h b/programs/cmm/eolite/include/properties.h index 5c81b9725c..203ee2ad7a 100644 --- a/programs/cmm/eolite/include/properties.h +++ b/programs/cmm/eolite/include/properties.h @@ -230,7 +230,7 @@ void DrawPropertiesWindow() if (chrnum(path, '/')>1) || (streq(path, "/kolibrios")) || (streq(path, "/sys")) show_date = true; if (getSelectedCount()) show_date = false; - DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+300+skin_height,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0); + DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+300+skin_h,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0); GetProcessInfo(#pform, SelfInfo); DrawStandartCaptButton(pform.cwidth - 96, pform.cheight-34, B_CLOSE, T_CLOSE); diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index fff423e9a4..5a3fffc7e9 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -73,7 +73,7 @@ void settings_dialog() case evReDraw: DefineAndDrawWindow(Form.cwidth-300/2+Form.left, Form.cheight-292/2+Form.top, 400, - -efm*42+345+skin_height,0x34,sc.work,TITLE_SETT,0); + -efm*42+345+skin_h,0x34,sc.work,TITLE_SETT,0); GetProcessInfo(#Settings, SelfInfo); DrawSettingsCheckBoxes(); } diff --git a/programs/cmm/examples/info.c b/programs/cmm/examples/info.c index 09bc424403..2c80f3dec8 100644 --- a/programs/cmm/examples/info.c +++ b/programs/cmm/examples/info.c @@ -44,7 +44,7 @@ inline GetRevisionNumber() void draw_window() { sc.get(); - DefineUnDragableWindow(screen.width-WIN_W-15, GetClientHeight()-WIN_H-15, WIN_W-1, WIN_H-1); + DefineUnDragableWindow(screen.w-WIN_W-15, GetClientHeight()-WIN_H-15, WIN_W-1, WIN_H-1); DrawBar(0,0,WIN_W,WIN_H,0x414155); DrawWideRectangle(0,0,WIN_W,WIN_H, 3, 0x5555FF); WriteText(15, 20, 0x81, 0xFFFF55, " REV 7321 "); diff --git a/programs/cmm/examples/rgb.c b/programs/cmm/examples/rgb.c index 2624df3148..10fdf60f77 100644 --- a/programs/cmm/examples/rgb.c +++ b/programs/cmm/examples/rgb.c @@ -45,7 +45,7 @@ int id; break; case evReDraw: sc.get(); - DefineAndDrawWindow(screen.width-fw/2,screen.height-fh/2,fw,fh+skin_height,0x33,0xE0DFE3,"Rainbow (rgb test)",0); + DefineAndDrawWindow(screen.w-fw/2,screen.h-fh/2,fw,fh+skin_h,0x33,0xE0DFE3,"Rainbow (rgb test)",0); _PutImage(0,0,256,256,#image); DrawCaptButton(280,20, 110,30,DRAW1_BTN,sc.button,sc.button_text,"Draw 1"); DrawCaptButton(280,60, 110,30,DRAW2_BTN,sc.button,sc.button_text,"Draw 2"); diff --git a/programs/cmm/iconedit/canvas_resize.h b/programs/cmm/iconedit/canvas_resize.h index 86144e554f..6024bb13b6 100644 --- a/programs/cmm/iconedit/canvas_resize.h +++ b/programs/cmm/iconedit/canvas_resize.h @@ -53,7 +53,7 @@ void CanvasReSize_Thread() break; case evReDraw: - DefineAndDrawWindow(Form.left+canvas.x + 100, Form.top+skin_height+canvas.y+40, + DefineAndDrawWindow(Form.left+canvas.x + 100, Form.top+skin_h+canvas.y+40, 200, 170, 0x34, sc.work, "Canvas", 0); WriteText(20, 20, 0x90, sc.work_text, "Width"); WriteText(20, 60, 0x90, sc.work_text, "Height"); diff --git a/programs/cmm/iconedit/iconedit.c b/programs/cmm/iconedit/iconedit.c index 13884389a0..8db9d6d700 100644 --- a/programs/cmm/iconedit/iconedit.c +++ b/programs/cmm/iconedit/iconedit.c @@ -597,7 +597,7 @@ void DrawPreview() dword GetPixelUnderMouse() { - return GetPixelColorFromScreen(mouse.x + Form.left + 5, mouse.y + Form.top + skin_height); + return GetPixelColorFromScreen(mouse.x + Form.left + 5, mouse.y + Form.top + skin_h); } int preview_size = 128; @@ -629,7 +629,7 @@ void ShowWindow_TestIcon() case evReDraw: DefineAndDrawWindow(Form.left+100, Form.top+100, preview_size*2+9, - preview_size*2+skin_height+4, 0x74, NULL, T_TEST_ICON, 0); + preview_size*2+skin_h+4, 0x74, NULL, T_TEST_ICON, 0); DrawImageWithBg(0, 0, 0x000000); DrawImageWithBg(1, 0, 0xFFFfff); DrawImageWithBg(0, 1, GetPixelColorFromScreen(0, 0)); diff --git a/programs/cmm/iconedit/tools/screen_copy.h b/programs/cmm/iconedit/tools/screen_copy.h index bbafbcd5cb..575a1d9ca5 100644 --- a/programs/cmm/iconedit/tools/screen_copy.h +++ b/programs/cmm/iconedit/tools/screen_copy.h @@ -10,12 +10,12 @@ void ScreenCopy_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) { int x, y; x = mouse.x + Form.left + 5 - calc(image.columns/2); - y = mouse.y + Form.top + skin_height - calc(image.rows/2); + y = mouse.y + Form.top + skin_h - calc(image.rows/2); CopyScreen( screen_copy, - math.in(x, 0, screen.width - image.columns), - math.in(y, 0, screen.height - image.rows), + math.in(x, 0, screen.w - image.columns), + math.in(y, 0, screen.h - image.rows), image.columns, image.rows ); diff --git a/programs/cmm/imgedit/imgedit.c b/programs/cmm/imgedit/imgedit.c index 0d308e0ee2..57a34427e9 100644 --- a/programs/cmm/imgedit/imgedit.c +++ b/programs/cmm/imgedit/imgedit.c @@ -21,9 +21,10 @@ // // //===================================================// -#define PAD 12 +#define PAD 13 #define TOOLBAR_ITEM_H PAD+PAD -#define TOOLBAR_W 110 +#define TOOLBAR_W 132 +#define STATUSBAR_H 20 #define ISIZE 18 block canvas = { TOOLBAR_W + PAD + PAD, 0, NULL, NULL }; @@ -33,7 +34,6 @@ EVENTS key; proc_info Form; dword semi_white; -bool bg_dark=false; char default_dir[4096] = "/sys"; od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" }; @@ -43,19 +43,22 @@ libimg_image main_image; char win_title[256] = "ImageEdit"; -scroll_bar scroll_v = { 15,NULL,NULL,NULL,15,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; -scroll_bar scroll_h = { NULL,NULL,15,NULL,15,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; +scroll_bar scroll_v = { 15,NULL,NULL,NULL,15,2,NULL,0,0,0xeeeeee,0xBBDDFF,0xeeeeee}; +scroll_bar scroll_h = { NULL,NULL,15,NULL,15,2,NULL,0,0,0xeeeeee,0xBBDDFF,0xeeeeee}; -/* -struct scroll_bar -{ - word size_x, start_x, size_y, start_y; - dword btn_height, type, max_area, cur_area, position, - bckg_col, frnt_col, line_col, redraw; - word delta, delta2, r_size_x, r_start_x, r_size_y, r_start_y; - dword m_pos, m_pos_2, m_keys, run_size, position2, work_size, all_redraw, ar_offset; +enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4 }; +int saving_type=SAVE_AS_PNG; + +char* libimg_bpp[] = { "8pal", "24", "32", "15", "16", +"mono", "8gray", "2pal", "4pal", "8pal" }; + +enum { + TOOL_CROP=1, + TOOL_RESIZE=2, + TOOL_COLOR_DEPTH=4, + TOOL_FLIP_ROTATE=8 }; -*/ +int active_tool = NULL; //===================================================// // // @@ -66,8 +69,7 @@ struct scroll_bar void init_ui() { sc.get(); - semi_white = MixColors(sc.work, 0xFFFfff, bg_dark*90 + 96); - bg_dark = skin_is_dark(); + semi_white = MixColors(sc.work, 0xFFFfff, skin_is_dark()*90 + 96); icons18.load("/sys/icons16.png"); icons18.replace_color(0xffFFFfff, semi_white); icons18.replace_color(0xffCACBD6, MixColors(sc.work, 0, 200)); @@ -92,6 +94,14 @@ void main() scrollbar_v_mouse stdcall(#scroll_v); scrollbar_h_mouse stdcall(#scroll_h); if (scroll_v.delta) || (scroll_h.delta) draw_canvas(); + if (EAX = mouse.vert) { + if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN); + else event_scroll_canvas(SCAN_CODE_UP); + } if (EAX = mouse.hor) { + debugval("mouse.hor", mouse.hor); + if (EAX<10) event_scroll_canvas(SCAN_CODE_RIGHT); + else event_scroll_canvas(SCAN_CODE_LEFT); + } break; case evButton: @@ -102,14 +112,11 @@ void main() case evKey: GetKeys(); - if (key_scancode == SCAN_CODE_DOWN) { - scroll_v.position = math.min(scroll_v.position+25, scroll_v.max_area - scroll_v.cur_area); - draw_canvas(); - } - if (key_scancode == SCAN_CODE_UP) { - scroll_v.position = math.max(scroll_v.position-25, 0); - draw_canvas(); - } + if (key_scancode == SCAN_CODE_DOWN) event_scroll_canvas(SCAN_CODE_DOWN); + if (key_scancode == SCAN_CODE_UP) event_scroll_canvas(SCAN_CODE_UP); + if (key_scancode == SCAN_CODE_LEFT) event_scroll_canvas(SCAN_CODE_LEFT); + if (key_scancode == SCAN_CODE_RIGHT) event_scroll_canvas(SCAN_CODE_RIGHT); + key.press(key_scancode); break; case evReDraw: @@ -121,7 +128,11 @@ void main() void draw_window() { incn tx; - DefineAndDrawWindow(random(100)+40, 40+random(100), screen.width/3*2, screen.height/3*2, 0x73, NULL, #win_title, 0); + char save_as_type[32]; + sc.get(); + Form.width = screen.w/6*5; + Form.height = screen.h/6*5; + DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x73, NULL, #win_title, 0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window&ROLLED_UP) return; if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; } @@ -132,75 +143,83 @@ void draw_window() DrawBar(0, 0, canvas.x, Form.cheight, sc.work); canvas.w = Form.cwidth - canvas.x; - canvas.h = Form.cheight; + canvas.h = Form.cheight - STATUSBAR_H; if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1; if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1; - DrawBar(canvas.x, 0, 1, canvas.h, sc.work_graph); + DrawBar(canvas.x, 0, 1, canvas.h, sc.work_text); if (main_image.h > canvas.h) && (main_image.w > canvas.w) { DrawBar(canvas.x+canvas.w, canvas.y+canvas.h, scroll_v.size_x+1, scroll_h.size_y+1, sc.work); } scroll_v.all_redraw = scroll_h.all_redraw = 1; - scroll_v.bckg_col = scroll_h.bckg_col = MixColors(sc.work, 0xBBBbbb, 80); - scroll_v.frnt_col = scroll_h.frnt_col = MixColors(sc.work,0xFFFfff,120); - scroll_v.line_col = scroll_h.line_col = sc.work_graph; + if (skin_is_dark()) + { + scroll_v.bckg_col = scroll_h.bckg_col = sc.work_light; + scroll_v.frnt_col = scroll_h.frnt_col = sc.button; + scroll_v.line_col = scroll_h.line_col = sc.button_text; + } + scroll_v.line_col = scroll_h.line_col = sc.work_text; - #define GAP_S 24+7 - #define GAP_B 24+23 + #define GAP_S TOOLBAR_ITEM_H+8 + #define GAP_B TOOLBAR_ITEM_H+23 tx.set(PAD-GAP_S); - //draw_icon(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image"); - draw_icon(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image"); - //draw_icon(13, ECTRL + SCAN_CODE_LEFT, PAD, tx.inc(GAP_B), 30); - //draw_icon(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31); - //draw_icon(15, ECTRL + SCAN_CODE_UP, PAD, tx.inc(GAP_S), 32); - //draw_icon(16, ECTRL + SCAN_CODE_DOWN, PAD, tx.inc(GAP_S), 33); + //draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false); + draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image", false); + //draw_tool_btn(13, ECTRL + SCAN_CODE_LEFT, PAD, tx.inc(GAP_B), 30, false); + //draw_tool_btn(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false); + //draw_tool_btn(15, ECTRL + SCAN_CODE_UP, PAD, tx.inc(GAP_S), 32, false); + //draw_tool_btn(16, ECTRL + SCAN_CODE_DOWN, PAD, tx.inc(GAP_S), 33, false); - //draw_icon(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save file"); - //draw_icon(12, 0, PAD, tx.inc(GAP_B), 05, "PNG"); - //draw_icon(12, 0, PAD, tx.inc(GAP_S), 05, "BMP"); - //draw_icon(12, 0, PAD, tx.inc(GAP_S), 05, "RAW"); - draw_icon(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_S), 05, "Save as PNG"); + draw_tool_btn(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save file", false); + draw_tool_btn(#event_save_png, 0, PAD, tx.inc(GAP_S), -1, "PNG", saving_type & SAVE_AS_PNG); + draw_tool_btn(#event_save_bmp, 0, PAD*2+34, tx.n, -1, "BMP", saving_type & SAVE_AS_BMP); + draw_tool_btn(#event_save_raw, 0, PAD*3+68, tx.n, -1, "RAW", saving_type & SAVE_AS_RAW); - draw_icon(0, 0, PAD, tx.inc(GAP_B), 46, "Crop"); - draw_icon(0, 0, PAD, tx.inc(GAP_S), 06, "Resize"); - draw_icon(0, 0, PAD, tx.inc(GAP_S), 52, "Color depth"); - draw_icon(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, PAD, tx.inc(GAP_S), 34, NULL); - draw_icon(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, PAD*4+3, tx.n, 35, NULL); - draw_icon(#event_rotate, ECTRL + SCAN_CODE_KEY_R, PAD*7+6, tx.n, 36, NULL); + draw_tool_btn(#event_activate_crop, 0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP); + draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_S), 06, "Resize", active_tool & TOOL_RESIZE); + draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_S), 52, "Color depth", active_tool & TOOL_COLOR_DEPTH); + draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate", active_tool & TOOL_FLIP_ROTATE); + //draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, PAD, tx.inc(GAP_S), 34, NULL, false); + //draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, PAD*2+34, tx.n, 35, NULL, false); + //draw_tool_btn(#event_rotate, ECTRL + SCAN_CODE_KEY_R, PAD*3+68, tx.n, 36, NULL, false); - draw_image_info(tx.inc(GAP_B)); + draw_status_bar(); draw_canvas(); } -char* libimg_bpp[] = { "8 pal", "24", "32", "15", "16", -"1 mono", "8 gray", "2 pal", "4 pal", "8 pal" }; - -void draw_image_info(int _y) +void draw_status_bar() { - WriteText(PAD, _y, 0x90, sc.work_text, "Properties"); - DrawBar(PAD, _y+14, TOOLBAR_W, 1, sc.work_graph); - WriteText(PAD, _y+22, 0x90, sc.work_text, "Width:"); - WriteText(PAD, _y+42, 0x90, sc.work_text, "Heigh:"); - WriteText(PAD, _y+62, 0x90, sc.work_text, "Depth:"); - - WriteText(PAD+60, _y+22, 0x90, sc.work_text, itoa(main_image.w)); - WriteText(PAD+60, _y+42, 0x90, sc.work_text, itoa(main_image.h)); - WriteText(PAD+60, _y+62, 0x90, sc.work_text, libimg_bpp[main_image.type-1]); + char img_info[24]; + //draw_image_info + sprintf(#img_info, "%ix%i@%s", main_image.w, main_image.h, libimg_bpp[main_image.type-1]); + DrawBar(canvas.x, Form.cheight - STATUSBAR_H, Form.cwidth - canvas.x, STATUSBAR_H, sc.work); + WriteText(canvas.x, Form.cheight - STATUSBAR_H + 2, 0x90, sc.work_text, #img_info); } -void draw_icon(dword _event, _key, _x, _y, _icon_n, _text) +void draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active) { - int w; - if (_text) w = TOOLBAR_W; else w = PAD + PAD + 8; - DrawBar(_x, _y, w, TOOLBAR_ITEM_H+1, semi_white); + int w = TOOLBAR_W; + if (!_text) w = PAD + PAD + 12; + if (_icon_n==-1) w = strlen(_text) * 8 + 14; + if (_active) EDX = sc.button; else EDX = semi_white; + DrawBar(_x, _y, w, TOOLBAR_ITEM_H+1, EDX); PutPixel(_x,_y,sc.work); PutPixel(_x,_y+TOOLBAR_ITEM_H,sc.work); PutPixel(_x+w-1,_y,sc.work); PutPixel(_x+w-1,_y+TOOLBAR_ITEM_H,sc.work); if (_event) DefineHiddenButton(_x, _y, w, TOOLBAR_ITEM_H, button.add(_event)); - if (_text) WriteText(_x+PAD+ISIZE+2, _y+9, 0x80, sc.work_text, _text); - img_draw stdcall(icons18.image, _x+7, _y+3, ISIZE, ISIZE, 0, _icon_n*ISIZE); + if (_hotkey) key.add_n(_hotkey, _event); + if (_icon_n!=-1) { + img_draw stdcall(icons18.image, _x+7, _y+4, ISIZE, ISIZE, 0, _icon_n*ISIZE); + _x += PAD+ISIZE+2; + } else { + _x += 7; + } + if (_text) { + if (_active) EDX = sc.button_text; else EDX = sc.work_text; + WriteText(_x, _y+6, 0x90, EDX, _text); + } } void draw_scroll_v() @@ -289,17 +308,56 @@ void event_rotate() draw_window(); } +void event_save_png() { saving_type = SAVE_AS_PNG; draw_window(); } +void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_window(); } +void event_save_raw() { saving_type = SAVE_AS_RAW; draw_window(); } + +void event_activate_crop() { active_tool = TOOL_CROP; draw_window(); } +void event_activate_resize() { active_tool = TOOL_RESIZE; draw_window(); } +void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_window(); } +void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_window(); } + void event_save() { o_dialog.type = 1; //save file - strcpy(#filename_area, "image.png"); - OpenDialog_start stdcall (#o_dialog); - if (o_dialog.status) { - update_title(#openfile_path); - img_to_rgb stdcall (main_image.image); - save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path); + switch (saving_type) { + case SAVE_AS_PNG: + strcpy(#filename_area, "image.png"); + OpenDialog_start stdcall (#o_dialog); + if (o_dialog.status) { + update_title(#openfile_path); + img_to_rgb stdcall (main_image.image); + save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path); + } + break; + case SAVE_AS_BMP: + notify("Not implemented yet."); + break; + case SAVE_AS_RAW: + notify("Not implemented yet."); + break; } } +void event_scroll_canvas(int _direction) +{ + switch(_direction) { + case SCAN_CODE_DOWN: + scroll_v.position = math.min(scroll_v.position+25, + scroll_v.max_area - scroll_v.cur_area); + break; + case SCAN_CODE_UP: + scroll_v.position = math.max(scroll_v.position-25, 0); + break; + case SCAN_CODE_RIGHT: + scroll_h.position = math.min(scroll_h.position+25, + scroll_h.max_area - scroll_h.cur_area); + break; + case SCAN_CODE_LEFT: + scroll_h.position = math.max(scroll_h.position-25, 0); + } + draw_canvas(); +} + stop: diff --git a/programs/cmm/kf_font_viewer/font_viewer.c b/programs/cmm/kf_font_viewer/font_viewer.c index b10f5125d8..a71c7c6376 100644 --- a/programs/cmm/kf_font_viewer/font_viewer.c +++ b/programs/cmm/kf_font_viewer/font_viewer.c @@ -42,7 +42,7 @@ void main() case evReDraw: sc.get(); - DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0); + DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_h+5,0x74,0xFFFFFF,#title,0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window&ROLLED_UP) break; _DRAW_WINDOW_CONTENT: diff --git a/programs/cmm/lib/gui/menu.h b/programs/cmm/lib/gui/menu.h index 609dbfcffd..1a12b313a0 100644 --- a/programs/cmm/lib/gui/menu.h +++ b/programs/cmm/lib/gui/menu.h @@ -18,7 +18,7 @@ } ESDWORD[shared_mem ] = _selected; ESDWORD[shared_mem + 4] = _x + Form.left + 5; - ESDWORD[shared_mem + 8] = _y + Form.top + skin_height; + ESDWORD[shared_mem + 8] = _y + Form.top + skin_h; ESDWORD[shared_mem + 12] = _position; menu_process_id = RunProgram("/sys/develop/menu", _text1); } diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 227d77923f..fcfc133975 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -492,7 +492,7 @@ inline fastcall dword SetWindowLayerBehaviour(EDX, ESI) :dword GetPixelColorFromScreen(dword _x, _y) { EAX = 35; - EBX = _y * screen.width + _x; + EBX = _y * screen.w + _x; $int 64 } @@ -606,8 +606,8 @@ inline fastcall void PutPixel( EBX,ECX,EDX) { z1 = Form1.left + mouse.x - tmp_x; z2 = Form1.top + mouse.y - tmp_y; - if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.width-Form1.width-10)z1=screen.width-Form1.width; - if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.height-Form1.height-10)z2=screen.height-Form1.height; + if(z1<=10) || (z1>20000) z1=0; else if(z1>screen.w-Form1.width-10)z1=screen.w-Form1.width; + if(z2<=10) || (z2>20000) z2=0; else if(z2>screen.h-Form1.height-10)z2=screen.h-Form1.height; MoveSize(z1 , z2, OLD, OLD); draw_window(); } @@ -651,19 +651,19 @@ inline fastcall dword GetStartTime() :struct _screen { - dword width,height; + dword w,h; } screen; -:byte skin_height; +:byte skin_h; dword __generator; // random number generator init //The initialization of the initial data before running :void ______INIT______() { - skin_height = @GetSkinHeight(); - screen.width = @GetScreenWidth()+1; - screen.height = @GetScreenHeight()+1; + skin_h = @GetSkinHeight(); + screen.w = @GetScreenWidth()+1; + screen.h = @GetScreenHeight()+1; __generator = @GetStartTime(); mem_init(); main(); diff --git a/programs/cmm/lib/mouse.h b/programs/cmm/lib/mouse.h index e13e85bcbe..6a40b1bd09 100644 --- a/programs/cmm/lib/mouse.h +++ b/programs/cmm/lib/mouse.h @@ -184,7 +184,7 @@ $mov ebx, eax $shr eax, 16 $and ebx,0x0000FFFF - //hor = EAX; + hor = EAX; vert = EBX; } diff --git a/programs/cmm/misc/easyshot.c b/programs/cmm/misc/easyshot.c index b9bdde0fa7..0e8ddc41db 100644 --- a/programs/cmm/misc/easyshot.c +++ b/programs/cmm/misc/easyshot.c @@ -134,8 +134,8 @@ void DrawWindow() unsigned i; sc.get(); - DefineAndDrawWindow(screen.width-400, screen.height/3, 280, - skin_height + 50+PD+PD, 0x34, sc.work, "EasyShot",0); + DefineAndDrawWindow(screen.w-400, screen.h/3, 280, + skin_h + 50+PD+PD, 0x34, sc.work, "EasyShot",0); GetProcessInfo(#Form, SelfInfo); if (!recording) { @@ -165,7 +165,7 @@ void DrawStatusBar(char *s) dword ScreenshotBuf() { static dword screenshot; - if (!screenshot) screenshot = malloc(screen.width * screen.height * 3); + if (!screenshot) screenshot = malloc(screen.w * screen.h * 3); return screenshot; } @@ -193,8 +193,8 @@ bool GetSavingPath() void MakeScreenshot() { if (I_Path = GetSavingPath()) { - CopyScreen(ScreenshotBuf(), 0, 0, screen.width, screen.height); - I_Param = save_image(ScreenshotBuf(), screen.width, screen.height, I_Path); + CopyScreen(ScreenshotBuf(), 0, 0, screen.w, screen.h); + I_Param = save_image(ScreenshotBuf(), screen.w, screen.h, I_Path); if (!I_Param) I_Param = I_Path; DrawStatusBar(I_Param); } else { @@ -227,7 +227,7 @@ void EventSettingsClick() { show_settings ^= 1; @MoveSize(OLD, OLD, show_settings*65 + 280, - show_settings*110 + skin_height + PD+PD+50); + show_settings*110 + skin_h + PD+PD+50); } void EventChooseSavePathClick() diff --git a/programs/cmm/misc/install.c b/programs/cmm/misc/install.c index 80a13453d9..e33992c633 100644 --- a/programs/cmm/misc/install.c +++ b/programs/cmm/misc/install.c @@ -67,8 +67,8 @@ void main() void draw_window() { sc.get(); - DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2, - WINW+9,WINH+skin_height,0x34,sc.work,"KolibriN10",0); + DefineAndDrawWindow(screen.w-WINW/2,screen.h-WINH/2, + WINW+9,WINH+skin_h,0x34,sc.work,"KolibriN10",0); DrawLogo(); if (install_complete) DrawInstallComplete(); else DrawIntro(); } diff --git a/programs/cmm/misc/osupdate.c b/programs/cmm/misc/osupdate.c index 513b18ca56..f468299018 100644 --- a/programs/cmm/misc/osupdate.c +++ b/programs/cmm/misc/osupdate.c @@ -101,8 +101,8 @@ void main() void draw_window() { sc.get(); - DefineAndDrawWindow(screen.width-WINW/2,screen.height-WINH/2, - WINW+9,WINH+skin_height,0x34,sc.work,T_WINDOW_TITLE,0); + DefineAndDrawWindow(screen.w-WINW/2,screen.h-WINH/2, + WINW+9,WINH+skin_h,0x34,sc.work,T_WINDOW_TITLE,0); WriteText(30, 20, 0x91, 0xEC008C, T_TITLE_H1); if (!install_complete) { if (GetProcessSlot(unimg_id)) { diff --git a/programs/cmm/misc/software_widget.c b/programs/cmm/misc/software_widget.c index 119f42853b..a413a93893 100644 --- a/programs/cmm/misc/software_widget.c +++ b/programs/cmm/misc/software_widget.c @@ -74,11 +74,11 @@ void main() list.y = 32; DrawList(); - window_height = row+1*list.item_h + list_pos + skin_height + 15; - if (window_height>screen.height) { - window_width = screen.width; + window_height = row+1*list.item_h + list_pos + skin_h + 15; + if (window_height>screen.h) { + window_width = screen.w; list.item_h -= 5; - window_height = row+1*list.item_h + list_pos + skin_height + 15; + window_height = row+1*list.item_h + list_pos + skin_h + 15; small_screen = true; } @@ -100,7 +100,7 @@ void main() case evReDraw: SetAppColors(); - DefineAndDrawWindow(screen.width-window_width/2,screen.height-window_height/2,window_width,window_height,0x74,sc.work,"",0); + DefineAndDrawWindow(screen.w-window_width/2,screen.h-window_height/2,window_width,window_height,0x74,sc.work,"",0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window&ROLLED_UP) { DrawTitle(#window_title); diff --git a/programs/cmm/mousecfg/mousecfg.c b/programs/cmm/mousecfg/mousecfg.c index 767176b3cc..a920c47b27 100644 --- a/programs/cmm/mousecfg/mousecfg.c +++ b/programs/cmm/mousecfg/mousecfg.c @@ -99,7 +99,7 @@ void main() { case evReDraw: sc.get(); - DefineAndDrawWindow(430, 150, 460, 343+skin_height,0x34,sc.work,WINDOW_TITLE,0); + DefineAndDrawWindow(430, 150, 460, 343+skin_h,0x34,sc.work,WINDOW_TITLE,0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window&ROLLED_UP) break; mouse_frame.w = - FRAME_X * 2 + Form.cwidth; diff --git a/programs/cmm/pixie2/pixie.c b/programs/cmm/pixie2/pixie.c index e6f8287c2e..4f9631df12 100644 --- a/programs/cmm/pixie2/pixie.c +++ b/programs/cmm/pixie2/pixie.c @@ -148,7 +148,7 @@ void main() } if(mouse.key&MOUSE_LEFT) && (mouse.x<14) && (window_mode == WINDOW_MODE_SMALL) EventDragWindow(); - if (mouse.down) && (mouse.y>skin_height) && (mouse.key&MOUSE_RIGHT) EventShowAbout(); + if (mouse.down) && (mouse.y>skin_h) && (mouse.key&MOUSE_RIGHT) EventShowAbout(); break; case evButton: switch(@GetButtonID()) { diff --git a/programs/cmm/quark/prepare_page.h b/programs/cmm/quark/prepare_page.h index 5f775a8de8..f4017e8b67 100644 --- a/programs/cmm/quark/prepare_page.h +++ b/programs/cmm/quark/prepare_page.h @@ -12,7 +12,7 @@ int line_end; list.count=0; selection.cancel(); - if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.height); + if (list.w != canvas.bufw) canvas.Init(list.x, list.y, list.w, screen.h); lines.drop(); lines.add(textbuf.p); diff --git a/programs/cmm/search/search.c b/programs/cmm/search/search.c index 9fba56a0b3..3f4264c274 100644 --- a/programs/cmm/search/search.c +++ b/programs/cmm/search/search.c @@ -160,7 +160,7 @@ void main() void draw_window() { sc.get(); - DefineAndDrawWindow(screen.width-600/2,100,640,600,0x73,sc.work,T_WINDOW_HEADER,0); + DefineAndDrawWindow(screen.w-600/2,100,640,600,0x73,sc.work,T_WINDOW_HEADER,0); GetProcessInfo(#Form, SelfInfo); IF (Form.status_window&ROLLED_UP) return; if (Form.width < 270) { MoveSize(OLD,OLD,270,OLD); return; } diff --git a/programs/cmm/sysmon/sysmon.c b/programs/cmm/sysmon/sysmon.c index 6021d1a2be..60e694159c 100644 --- a/programs/cmm/sysmon/sysmon.c +++ b/programs/cmm/sysmon/sysmon.c @@ -400,7 +400,7 @@ void EventShowTinfo() void ReadIni() { - Form.left = ini.GetInt("x", screen.width/2 - 350); + Form.left = ini.GetInt("x", screen.w/2 - 350); Form.top = ini.GetInt("y", 100); Form.width = ini.GetInt("w", 700); Form.height = ini.GetInt("h", 490); diff --git a/programs/cmm/taskbar2/taskbar2.c b/programs/cmm/taskbar2/taskbar2.c index 0ed0b3e7f8..1d4528d628 100644 --- a/programs/cmm/taskbar2/taskbar2.c +++ b/programs/cmm/taskbar2/taskbar2.c @@ -188,20 +188,20 @@ void DrawProcessList() void SetAttachement() { if (attachement==ATTACHEMENT_LEFT) { - DefineUnDragableWindow(0, 0, CELLW-1, screen.height); - SetClientScreenArea(CELLW, screen.width-CELLW, 0, screen.height); + DefineUnDragableWindow(0, 0, CELLW-1, screen.h); + SetClientScreenArea(CELLW, screen.w-CELLW, 0, screen.h); } if (attachement==ATTACHEMENT_RIGHT) { - DefineUnDragableWindow(screen.width - CELLW, 0, CELLW, screen.height); - SetClientScreenArea(0, screen.width-CELLW, 0, screen.height); + DefineUnDragableWindow(screen.w - CELLW, 0, CELLW, screen.h); + SetClientScreenArea(0, screen.w-CELLW, 0, screen.h); } if (attachement==ATTACHEMENT_TOP) { - DefineUnDragableWindow(0, 0, screen.width, CELLH-1); - SetClientScreenArea(0, 0, CELLH, screen.height); + DefineUnDragableWindow(0, 0, screen.w, CELLH-1); + SetClientScreenArea(0, 0, CELLH, screen.h); } if (attachement==ATTACHEMENT_BOTTOM) { - DefineUnDragableWindow(0, screen.height, screen.width, CELLH); - SetClientScreenArea(0, 0, 0, screen.height - CELLH); + DefineUnDragableWindow(0, screen.h, screen.w, CELLH); + SetClientScreenArea(0, 0, 0, screen.h - CELLH); } }