diff --git a/programs/cmm/iconedit/actions_history.h b/programs/cmm/iconedit/actions_history.h index adfbbff5b..94c309704 100644 --- a/programs/cmm/iconedit/actions_history.h +++ b/programs/cmm/iconedit/actions_history.h @@ -1,6 +1,6 @@ // Actions history -#define MAX_ACTIONS_COUNT 10 +#define MAX_ACTIONS_COUNT 15 struct _ActionsHistory { dword stack[MAX_ACTIONS_COUNT]; diff --git a/programs/cmm/iconedit/iconedit.c b/programs/cmm/iconedit/iconedit.c index 2440fd7b7..1dff31195 100644 --- a/programs/cmm/iconedit/iconedit.c +++ b/programs/cmm/iconedit/iconedit.c @@ -32,10 +32,10 @@ pipet aside color view // // //===================================================// -#define T_TITLE "Icon Editor 0.54 Alpha" +#define T_TITLE "Icon Editor 0.54.1 Alpha" -#define TOOLBAR_H 24+8 -#define PANEL_LEFT_W 16+5+5+3+3 +#define TOPBAR_H 24+8 +#define LEFTBAR_W 16+5+5+3+3 #define PALLETE_SIZE 116 #define PAL_ITEMS_X_COUNT 13 @@ -46,12 +46,12 @@ pipet aside color view #define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value block canvas = { NULL, NULL, NULL, NULL }; -block wrapper = { PANEL_LEFT_W, TOOLBAR_H, NULL, NULL }; -block right_bar = { NULL, 10+TOOLBAR_H, RIGHT_BAR_W+10, NULL }; +block wrapper = { LEFTBAR_W, TOPBAR_H, NULL, NULL }; +block right_bar = { NULL, 10+TOPBAR_H, RIGHT_BAR_W+10, NULL }; -block b_color_gradient = {NULL, 40+TOOLBAR_H, RIGHT_BAR_W, 30}; -block b_last_colors = {NULL, 80+TOOLBAR_H, RIGHT_BAR_W, COLSIZE*2}; -block b_default_palette = {NULL, COLSIZE*2+10+80+TOOLBAR_H, RIGHT_BAR_W, COLSIZE*9}; +block b_color_gradient = {NULL, 40+TOPBAR_H, RIGHT_BAR_W, 30}; +block b_last_colors = {NULL, 80+TOPBAR_H, RIGHT_BAR_W, COLSIZE*2}; +block b_default_palette = {NULL, COLSIZE*2+10+80+TOPBAR_H, RIGHT_BAR_W, COLSIZE*9}; dword color1 = 0x000000; dword color2 = 0xBFCAD2; @@ -305,7 +305,6 @@ void main() if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0) tools[currentTool].onKeyEvent(key_scancode); - if (key_scancode == SCAN_CODE_ESC) setCurrentTool(TOOL_PENCIL); if (key_scancode == SCAN_CODE_KEY_P) setCurrentTool(TOOL_PENCIL); if (key_scancode == SCAN_CODE_KEY_I) setCurrentTool(TOOL_PIPETTE); if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL); @@ -333,6 +332,10 @@ void main() void DrawTopPanelButton(dword _id, _x, _icon_n) { DrawWideRectangle(_x, 4, 22, 22, 3, semi_white); + PutPixel(_x,4,system.color.work); + PutPixel(_x,4+21,system.color.work); + PutPixel(_x+21,4,system.color.work); + PutPixel(_x+21,4+21,system.color.work); DefineHiddenButton(_x, 4, 21, 21, _id); img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16); } @@ -359,7 +362,7 @@ void draw_window() #define BLOCK_SPACE 10 incn tx; system.color.get(); - DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x33, system.color.work, T_TITLE, 0); + DefineAndDrawWindow(115+random(100), 50+random(100), 700, 540, 0x73, NULL, T_TITLE, 0); GetProcessInfo(#Form, SelfInfo); if (Form.status_window>2) return; if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; } @@ -367,7 +370,8 @@ void draw_window() right_bar.x = Form.cwidth - right_bar.w; b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x; - DrawBar(0, TOOLBAR_H-1, Form.cwidth, 1, system.color.work_graph); + DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, system.color.work); + DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph); tx.n = 5-GAP; DrawTopPanelButton(BTN_NEW, tx.inc(GAP), 2); //not implemented @@ -384,15 +388,23 @@ void draw_window() DrawTopPanelButton(BTN_TEST_ICON, tx.inc(GAP+BLOCK_SPACE), 12); // DrawTopPanelButton(BTN_ROTATE_LEFT, tx.inc(GAP), 36); //not implemented // DrawTopPanelButton(BTN_ROTATE_RIGHT, tx.inc(GAP), 37); //not implemented - - DrawLeftPanel(); DrawEditArea(); + //BG under LeftBar + DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, system.color.work); + //BG under RightBar + DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w, + Form.cheight - TOPBAR_H, system.color.work); + //BG under StatusBar + DrawBar(LEFTBAR_W-1, wrapper.y + wrapper.h, wrapper.w+1, + Form.cheight - wrapper.y - wrapper.h, system.color.work); + + DrawLeftPanel(); DrawActiveColor(right_bar.y); DrawColorPallets(); - DrawStatusBar(); + DrawPreview(); } void DrawLeftPanel() @@ -418,7 +430,7 @@ void DrawEditArea() int left_side; wrapper.w = Form.cwidth - right_bar.w - 10 - wrapper.x; - wrapper.h = Form.cheight - TOOLBAR_H - 35; + wrapper.h = Form.cheight - TOPBAR_H - 35; //canvas{ canvas.w = image.columns * zoom.value; @@ -481,6 +493,10 @@ void DrawCurrentColorGradientByLightness() for (i=0; i= image.rows) dy = image.rows-1 - selection_end_y; - selection_start_x += dx; selection_end_x += dx; @@ -156,11 +167,8 @@ void SelectTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) { if (STATE_CHOSING == selection_state) { - if (mouseX>canvas.x+canvas.w-zoom.value) mouseX = canvas.x+canvas.w-zoom.value; - if (mouseY>canvas.y+canvas.h-zoom.value) mouseY = canvas.y+canvas.h-zoom.value; - - if (mouseX= 0) && (selection_start_y >= 0) && (selection_end_x >= 0) && (selection_end_y >= 0)) { - DrawSelection(); - } -} - -void SelectTool_drawBuffer(int insert_x, int insert_y, int target) { - dword color; - dword r, c; - dword insert_to_x, insert_to_y; - - if (STATE_INACTIVE != selection_state) { - insert_to_x = insert_x + selection.columns - 1; - - if (insert_to_x >= image.columns) - insert_to_x = image.columns-1; - - insert_to_y = insert_y + selection.rows - 1; - - if (insert_to_y >= image.rows) - insert_to_y = image.rows-1; - - for (r = insert_y; r <= insert_to_y; r++) { - for (c = insert_x; c <= insert_to_x; c++) { - - color = selection.get_pixel(r - insert_y, c - insert_x); - - if (TOIMAGE == target) - image.set_pixel(r, c, color); - else - DrawCanvasPixel(r, c, color); - } - } - } -} - void SelectTool_onKeyEvent(dword keycode) { dword r, c; - if (keycode == SCAN_CODE_KEY_V) { + if (SCAN_CODE_DEL == keycode) { + selection_start_x = -1; + selection_start_y = -1; + selection_end_x = -1; + selection_end_y = -1; + selection_state = STATE_INACTIVE; + DrawCanvas(); + } + + if (SCAN_CODE_ESC == keycode) { + reset_selection(); + DrawCanvas(); + } + + if (SCAN_CODE_KEY_V == keycode) { if (STATE_SELECTED == selection_state) { - reset_selection(); - - selection_state = STATE_SELECTED; + selection_start_x = 0; - selection_end_x = selection.columns - 1; - selection_start_y = 0; + selection_end_x = selection.columns - 1; selection_end_y = selection.rows - 1; DrawCanvas(); @@ -251,42 +228,36 @@ void SelectTool_onKeyEvent(dword keycode) { } } -void DrawSelection() { +void SelectTool_onCanvasDraw() +{ #define SELECTION_COLOR 0xAAE5EF int p1x, p1y, p2x, p2y, r, c, old_color, new_color; - if (selection_start_x <= selection_end_x) { - p1x = selection_start_x; - p2x = selection_end_x; - } - else { - p1x = selection_end_x; - p2x = selection_start_x; - } + if ((selection_start_x >= 0) && (selection_start_y >= 0) && (selection_end_x >= 0) && (selection_end_y >= 0)) { - if (selection_start_y <= selection_end_y) { - p2y = selection_start_y; - p1y = selection_end_y; - } - else { - p2y = selection_end_y; - p1y = selection_start_y; - } + p1x = math.min(selection_start_x, selection_end_x); + p2x = math.max(selection_start_x, selection_end_x); - for (r = p1y; r >= p2y; r--) { - for (c = p1x; c <= p2x; c++) { - image.pixel_state.set_drawable_state(r, c, false); - - if (STATE_SELECTED == selection_state) && (SelectTool_pointInSelection(c, r)) { - old_color = selection.get_pixel(r - selection_start_y, c - selection_start_x); + p1y = math.min(selection_start_y, selection_end_y); + p2y = math.max(selection_start_y, selection_end_y); + + for (r = p1y; r <= p2y; r++) { + for (c = p1x; c <= p2x; c++) { + image.pixel_state.set_drawable_state(r, c, false); + + if (STATE_SELECTED == selection_state) && (SelectTool_pointInSelection(c, r)) { + old_color = selection.get_pixel(r - selection_start_y, c - selection_start_x); + } + else { + old_color = image.get_pixel(r, c); + } + + new_color = MixColors(old_color, SELECTION_COLOR, 64); + + DrawCanvasPixel(r, c, new_color); } - else { - old_color = image.get_pixel(r, c); - } - - new_color = MixColors(old_color, SELECTION_COLOR, 64); - - DrawCanvasPixel(r, c, new_color); } - } -} \ No newline at end of file + } +} + + diff --git a/programs/cmm/iconedit/tools/simple_figure.h b/programs/cmm/iconedit/tools/simple_figure.h index 567b30845..77bea22a6 100644 --- a/programs/cmm/iconedit/tools/simple_figure.h +++ b/programs/cmm/iconedit/tools/simple_figure.h @@ -53,10 +53,10 @@ void SimpleFigureTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) { if ((figTool.startX >= 0) && (figTool.startY >= 0)) { - x1 = figTool.startX - canvas.x/zoom.value; - y1 = figTool.startY - canvas.y/zoom.value; - x2 = mouseX - canvas.x/zoom.value; - y2 = mouseY - canvas.y/zoom.value; + x1 = TO_CANVAS_X(figTool.startX); + y1 = TO_CANVAS_Y(figTool.startY); + x2 = TO_CANVAS_X(mouseX); + y2 = TO_CANVAS_Y(mouseY); // Draw line from start position to current position if (currentTool == TOOL_LINE) { @@ -88,10 +88,10 @@ void SimpleFigureTool_onCanvasDraw() { if ((figTool.startX >= 0) && (figTool.startY >= 0) && (mouse.key)) { - x1 = figTool.startX - canvas.x/zoom.value; - y1 = figTool.startY - canvas.y/zoom.value; - x2 = mouseX_last - canvas.x/zoom.value; - y2 = mouseY_last - canvas.y/zoom.value; + x1 = TO_CANVAS_X(figTool.startX); + y1 = TO_CANVAS_Y(figTool.startY); + x2 = TO_CANVAS_X(mouseX_last); + y2 = TO_CANVAS_Y(mouseY_last); if (currentTool == TOOL_LINE) DrawLineIcon(x1, y1, x2, y2, tool_color, TOCANVAS);