From ab25bf2d8de815f3b20f457ff07ad56575a80783 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 5 Feb 2018 19:13:37 +0000 Subject: [PATCH] backgen become iconedit v0.01 git-svn-id: svn://kolibrios.org@7148 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../cmm/{backgen => iconedit}/Tupfile.lua | 2 +- .../cmm/{backgen => iconedit}/colors_mas.h | 18 +-- .../cmm/{backgen => iconedit}/compile_en.bat | 2 +- .../backgen.c => iconedit/iconedit.c} | 110 ++++++++---------- 4 files changed, 60 insertions(+), 72 deletions(-) rename programs/cmm/{backgen => iconedit}/Tupfile.lua (61%) rename programs/cmm/{backgen => iconedit}/colors_mas.h (84%) rename programs/cmm/{backgen => iconedit}/compile_en.bat (61%) rename programs/cmm/{backgen/backgen.c => iconedit/iconedit.c} (67%) diff --git a/programs/cmm/backgen/Tupfile.lua b/programs/cmm/iconedit/Tupfile.lua similarity index 61% rename from programs/cmm/backgen/Tupfile.lua rename to programs/cmm/iconedit/Tupfile.lua index 8317ee90f..111811bd8 100644 --- a/programs/cmm/backgen/Tupfile.lua +++ b/programs/cmm/iconedit/Tupfile.lua @@ -3,4 +3,4 @@ if tup.getconfig("LANG") == "ru" then C_LANG = "LANG_RUS" else C_LANG = "LANG_ENG" -- this includes default case without config end -tup.rule("backgen.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "backgen.com") +tup.rule("iconedit.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "iconedit.com") diff --git a/programs/cmm/backgen/colors_mas.h b/programs/cmm/iconedit/colors_mas.h similarity index 84% rename from programs/cmm/backgen/colors_mas.h rename to programs/cmm/iconedit/colors_mas.h index 89502338d..a064e1842 100644 --- a/programs/cmm/backgen/colors_mas.h +++ b/programs/cmm/iconedit/colors_mas.h @@ -1,6 +1,6 @@ struct _colors { - int x,y; + int x,y,w,h; unsigned rows, columns; unsigned cell_size; dword mas[MAX_COLORS*MAX_COLORS]; @@ -16,15 +16,15 @@ struct _colors void _colors::set_default_values() { - columns = 2; - rows = 2; - cell_size = 20; + int i; - set_color(0,0, 0x66b2ff); - set_color(0,1, 0x000066); + columns = MAX_COLORS; + rows = MAX_COLORS; + cell_size = 5; + w = columns * cell_size; + h = rows * cell_size; - set_color(1,0, 0x000066); - set_color(1,1, 0x66b2ff); + for (i = 0; i < columns*rows; i++) mas[i]=0xBFCAD2; } void _colors::set_color(int _r, _c, _color) @@ -75,7 +75,7 @@ void _colors::draw_all_cells() for (c = 0; c < columns; c++) { draw_cell(c*cell_size + x, r*cell_size + y, get_color(r, c)); - DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME); + //DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME); } } } diff --git a/programs/cmm/backgen/compile_en.bat b/programs/cmm/iconedit/compile_en.bat similarity index 61% rename from programs/cmm/backgen/compile_en.bat rename to programs/cmm/iconedit/compile_en.bat index eca671967..0a5e78f95 100644 --- a/programs/cmm/backgen/compile_en.bat +++ b/programs/cmm/iconedit/compile_en.bat @@ -1,5 +1,5 @@ @del *. -@c-- backgen.c +@c-- iconedit.c @rename *.com *. @del warning.txt @pause \ No newline at end of file diff --git a/programs/cmm/backgen/backgen.c b/programs/cmm/iconedit/iconedit.c similarity index 67% rename from programs/cmm/backgen/backgen.c rename to programs/cmm/iconedit/iconedit.c index 9a9a2c428..272624849 100644 --- a/programs/cmm/backgen/backgen.c +++ b/programs/cmm/iconedit/iconedit.c @@ -17,24 +17,18 @@ // // //===================================================// -#define T_TITLE "Background generator 0.62" +#define T_TITLE "Icon Editor 0.01" -#define MAX_COLORS 10 -#define TOOLBAR_H 24+8 +#define MAX_COLORS 32 +#define TOOLBAR_H 24+8 #define PALLETE_SIZE 116 -more_less_box x_count = { 10, TOOLBAR_H+220, NULL, 1, MAX_COLORS, 22, 23, "X count" }; -more_less_box y_count = { 10, TOOLBAR_H+250, NULL, 1, MAX_COLORS, 24, 25, "Y count" }; - rect preview = { 10, TOOLBAR_H+10, 200, 200 }; rect right_bar = { 230, TOOLBAR_H+10, 280, 320 }; dword active_color = 0xFFFfff; -char active_color_string[11]="0x00111222\0"; enum { - BTN_APPLY_BACKGROUND = 10, - BTN_NEW = 40, BTN_OPEN, BTN_SAVE, @@ -69,6 +63,7 @@ dword default_colors[] = { 0xFFCCCC,0xFFE5CC,0xFFFFCC,0xE5FFCC,0xCCFFCC,0xCCFFE5,0xCCFFFF,0xCCE5FF,0xCCCCFF,0xE5CCFF,0xFFCCFF,0xFFCCE5,0xFFFFFF }; + //===================================================// // // // CODE // @@ -86,8 +81,6 @@ void main() Libimg_LoadImage(#skin, "/sys/icons16.png"); colors.set_default_values(); - x_count.value = colors.columns; - y_count.value = colors.rows; SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); @@ -96,11 +89,20 @@ void main() case evMouse: mouse.get(); if (pick_active) EventPickColor(); + else { + if (mouse.lkm) + && (mouse.x>colors.x) && (mouse.y>colors.y) + && (mouse.y= 300) && (btn < 401) + if (btn >= 300) { btn-=300; debugval("\n\nid",btn); @@ -141,7 +140,6 @@ void main() case evKey: GetKeys(); if (key_scancode == SCAN_CODE_ESC) ExitProcess(); - if (key_scancode == SCAN_CODE_ENTER) EventApplyBackground(); if (key_scancode == SCAN_CODE_KEY_I) EventPickActivate(); break; @@ -158,6 +156,12 @@ void DrawToolbarButton(dword _id, _x, _icon_n) img_draw stdcall(skin.image, _x+4, 8, 16, 16, 0, _icon_n*16); } +void DrawStatusBar() +{ + sprintf(#param,"Canvas: %ix%i", colors.rows, colors.columns); + WriteText(10, Form.cheight-40, 0x90, system.color.work_text, #param); +} + void draw_window() { #define TB_ICON_PADDING 26 @@ -170,82 +174,78 @@ void draw_window() GetProcessInfo(#Form, SelfInfo); tx.n = preview.x - TB_ICON_PADDING; - // DrawToolbarButton(BTN_NEW, tx.inc(TB_ICON_PADDING), 2); - // DrawToolbarButton(BTN_OPEN, tx.inc(TB_ICON_PADDING), 0); - // DrawToolbarButton(BTN_SAVE, tx.inc(TB_ICON_PADDING), 5); - DrawToolbarButton(BTN_MOVE_LEFT, tx.inc(TB_ICON_PADDING), 30); + DrawToolbarButton(BTN_NEW, tx.inc(TB_ICON_PADDING), 2); //not implemented + DrawToolbarButton(BTN_OPEN, tx.inc(TB_ICON_PADDING), 0); //not implemented + DrawToolbarButton(BTN_SAVE, tx.inc(TB_ICON_PADDING), 5); //not implemented + DrawToolbarButton(BTN_MOVE_LEFT, tx.inc(TB_ICON_PADDING+8), 30); DrawToolbarButton(BTN_MOVE_RIGHT, tx.inc(TB_ICON_PADDING), 31); DrawToolbarButton(BTN_MOVE_UP, tx.inc(TB_ICON_PADDING), 32); DrawToolbarButton(BTN_MOVE_DOWN, tx.inc(TB_ICON_PADDING), 33); + DrawToolbarButton(BTN_FLIP_HOR, tx.inc(TB_ICON_PADDING+8), 34); //not implemented + DrawToolbarButton(BTN_FLIP_VER, tx.inc(TB_ICON_PADDING), 35); //not implemented + DrawToolbarButton(BTN_ROTATE_LEFT, tx.inc(TB_ICON_PADDING), 36); //not implemented + DrawToolbarButton(BTN_ROTATE_RIGHT, tx.inc(TB_ICON_PADDING), 37); //not implemented + DrawToolbarButton(BTN_PICK, tx.inc(TB_ICON_PADDING+8), 38); - - // DrawToolbarButton(BTN_FLIP_HOR, tx.inc(TB_ICON_PADDING+8), 34); - // DrawToolbarButton(BTN_FLIP_VER, tx.inc(TB_ICON_PADDING), 35); - // DrawToolbarButton(BTN_ROTATE_LEFT, tx.inc(TB_ICON_PADDING), 36); - // DrawToolbarButton(BTN_ROTATE_RIGHT, tx.inc(TB_ICON_PADDING), 37); DrawBar(0, TOOLBAR_H-1, Form.cwidth, 1, system.color.work_dark); DrawBar(0, TOOLBAR_H, Form.cwidth, 1, system.color.work_light); - x_count.draw(); - y_count.draw(); - DrawColorsField(); - DrawStandartCaptButton(preview.x, 320, BTN_APPLY_BACKGROUND, "Fill background"); - DrawRightBar(); + DrawStatusBar(); } void DrawColorsField() { - DrawRectangle(preview.x, preview.y, preview.w, preview.h, system.color.work_graph); //0x808080); - DrawBar(preview.x+1, preview.y+1, preview.w-1, preview.h-1, 0xBFCAD2); //F3F3F3 colors.x = -colors.cell_size*colors.columns+preview.w/2 + preview.x; colors.y = -colors.cell_size*colors.rows+preview.h/2 + preview.y; colors.draw_all_cells(); + + DrawRectangle(preview.x, preview.y, preview.w, preview.h, system.color.work_graph); + DrawWideRectangle(preview.x+1, preview.y+1, preview.w-1, preview.h-1, + colors.x-preview.x, 0xC0C0C0); } void DrawRightBar() { int i; incn y; - y.n = right_bar.y; - EDI = system.color.work; - WriteTextB(right_bar.x, y.inc(3), 0x90, system.color.work_text, "Active color"); - DrawActiveColor(y.inc(22)); - WriteTextB(right_bar.x, y.inc(34), 0x90, system.color.work_text, "Palette"); - DrawDefaultColors(right_bar.x, y.inc(22)); + DrawDefaultColors(right_bar.x, right_bar.y); + + DrawActiveColor(Form.cheight-40); } void DrawActiveColor(dword iny) { static dword outy; if (iny != NULL) outy = iny; - colors.draw_cell(right_bar.x, outy, active_color); - sprintf(#active_color_string, "%A", active_color); + DrawBar(right_bar.x, outy, 20, 20, active_color); + sprintf(#param, "%A", active_color); EDI = system.color.work; - WriteText(right_bar.x + 30, outy + 3, 0xD0, system.color.work_text, #active_color_string+4); + WriteText(right_bar.x + 30, outy + 3, 0xD0, system.color.work_text, #param+4); } void DrawDefaultColors(dword _x, _y) { int r, c, i; + int cellw = 20; + i = 0; for (r = 0; r < 9; r++) { for (c = 0; c < 13; c++) { - colors.draw_cell(c*colors.cell_size + _x, r*colors.cell_size + _y, default_colors[PALLETE_SIZE-i]); - DefineHiddenButton(c*colors.cell_size + _x, r*colors.cell_size + _y, - colors.cell_size-1, colors.cell_size-1, BTN_PALETTE_COLOR_MAS+PALLETE_SIZE-i); + DrawBar(c*cellw + _x, r*cellw + _y, cellw, cellw, default_colors[PALLETE_SIZE-i]); + DefineHiddenButton(c*cellw + _x, r*cellw + _y, cellw-1, cellw-1, BTN_PALETTE_COLOR_MAS+PALLETE_SIZE-i); i++; } } - DrawRectangle(_x-1, _y-1, c*colors.cell_size+1, r*colors.cell_size+1, system.color.work_light); - DrawRectangle(_x-2, _y-2, c*colors.cell_size+3, r*colors.cell_size+3, system.color.work_dark); + DrawRectangle(_x-1, _y-1, c*cellw+1, r*cellw+1, system.color.work_light); + DrawRectangle(_x-2, _y-2, c*cellw+3, r*cellw+3, system.color.work_dark); } @@ -255,13 +255,6 @@ void DrawDefaultColors(dword _x, _y) // // //===================================================// -void EventChangeFieldSize() -{ - colors.columns = x_count.value; - colors.rows = y_count.value; - DrawColorsField(); -} - void EventPickActivate() { SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE); @@ -277,8 +270,3 @@ void EventPickColor() SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); } } - -void EventApplyBackground() -{ - SetBackgroundImage(colors.columns, colors.rows, colors.get_image(), DRAW_DESKTOP_BG_STRETCH); -} \ No newline at end of file