Rev 7243 | Rev 7254 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7243 | Rev 7253 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | #include "../lib/gui.h" |
16 | #include "../lib/gui.h" |
17 | #include "../lib/random.h" |
17 | #include "../lib/random.h" |
18 | #include "../lib/mem.h" |
18 | #include "../lib/mem.h" |
19 | #include "../lib/obj/libimg.h" |
19 | #include "../lib/obj/libimg.h" |
20 | #include "../lib/patterns/rgb.h" |
20 | #include "../lib/patterns/rgb.h" |
- | 21 | #include "../lib/patterns/libimg_load_skin.h" |
|
Line 21... | Line 22... | ||
21 | 22 | ||
Line 22... | Line 23... | ||
22 | #include "colors_mas.h" |
23 | #include "colors_mas.h" |
23 | 24 | ||
24 | //===================================================// |
25 | //===================================================// |
25 | // // |
26 | // // |
26 | // DATA // |
27 | // DATA // |
Line 27... | Line 28... | ||
27 | // // |
28 | // // |
Line 28... | Line 29... | ||
28 | //===================================================// |
29 | //===================================================// |
29 | 30 | ||
30 | #define T_TITLE "Icon Editor 0.39" |
31 | #define T_TITLE "Icon Editor 0.45" |
31 | 32 | ||
Line 32... | Line 33... | ||
32 | #define TOOLBAR_H 24+8 |
33 | #define TOOLBAR_H 24+8 |
33 | #define PANEL_LEFT_W 16+5+5+3+3 |
34 | #define PANEL_LEFT_W 16+5+5+3+3 |
34 | #define PALLETE_SIZE 116 |
35 | #define PALLETE_SIZE 116 |
Line -... | Line 36... | ||
- | 36 | #define TB_ICON_PADDING 26 |
|
- | 37 | ||
- | 38 | #define PAL_ITEMS_X_COUNT 13 |
|
35 | #define TB_ICON_PADDING 26 |
39 | #define COLSIZE 18 |
36 | 40 | #define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE |
|
37 | #define PAL_ITEMS_X_COUNT 13 |
41 | |
Line 38... | Line 42... | ||
38 | #define COLSIZE 18 |
42 | #define TO_CANVAS_X(xval) xval - canvas.x/zoom.value |
Line 65... | Line 69... | ||
65 | BTN_PENCIL, |
69 | BTN_PENCIL, |
66 | BTN_PICK, |
70 | BTN_PICK, |
67 | BTN_FILL, |
71 | BTN_FILL, |
68 | BTN_LINE, |
72 | BTN_LINE, |
69 | BTN_RECT, |
73 | BTN_RECT, |
- | 74 | BTN_SELECT, |
|
- | 75 | BTN_ZOOM_IN, |
|
- | 76 | BTN_ZOOM_OUT, |
|
70 | BTNS_PALETTE_COLOR_MAS = 100, |
77 | BTNS_PALETTE_COLOR_MAS = 100, |
71 | BTNS_LAST_USED_COLORS = 400 |
78 | BTNS_LAST_USED_COLORS = 400 |
72 | }; |
79 | }; |
Line 73... | Line 80... | ||
73 | 80 | ||
Line 107... | Line 114... | ||
107 | TOOL_PENCIL, |
114 | TOOL_PENCIL, |
108 | TOOL_PIPETTE, |
115 | TOOL_PIPETTE, |
109 | TOOL_FILL, |
116 | TOOL_FILL, |
110 | TOOL_LINE, |
117 | TOOL_LINE, |
111 | TOOL_RECT, |
118 | TOOL_RECT, |
- | 119 | TOOL_SELECT |
|
112 | }; |
120 | }; |
Line 113... | Line 121... | ||
113 | 121 | ||
114 | struct Tool { |
122 | struct Tool { |
Line 115... | Line 123... | ||
115 | int id; |
123 | int id; |
116 | 124 | ||
117 | void (*activate)(); |
125 | void (*activate)(); |
- | 126 | void (*deactivate)(); |
|
118 | void (*deactivate)(); |
127 | void (*onMouseEvent)(int x, int y, int lkm, int pkm); |
119 | void (*onMouseEvent)(int x, int y, int lkm, int pkm); |
128 | void (*onKeyEvent)(dword keycode); |
Line 120... | Line 129... | ||
120 | void (*onCanvasDraw)(); |
129 | void (*onCanvasDraw)(); |
121 | }; |
130 | }; |
Line 122... | Line 131... | ||
122 | 131 | ||
123 | Tool tools[5]; |
132 | Tool tools[6]; |
124 | int currentTool = -1; |
133 | int currentTool = -1; |
Line 138... | Line 147... | ||
138 | 147 | ||
139 | if ((index != TOOL_NONE) && (tools[index].activate != 0)) |
148 | if ((index != TOOL_NONE) && (tools[index].activate != 0)) |
Line 140... | Line 149... | ||
140 | tools[index].activate(); |
149 | tools[index].activate(); |
- | 150 | ||
141 | 151 | DrawLeftPanel(); |
|
Line 142... | Line 152... | ||
142 | DrawLeftPanel(); |
152 | DrawCanvas(); |
143 | } |
153 | } |
144 | 154 | ||
Line 306... | Line 316... | ||
306 | figTool_States[currentFigToolState].lastTempPosX = mouseX_last - canvas.x/zoom.value; |
316 | figTool_States[currentFigToolState].lastTempPosX = mouseX_last - canvas.x/zoom.value; |
307 | figTool_States[currentFigToolState].lastTempPosY = mouseY_last - canvas.y/zoom.value; |
317 | figTool_States[currentFigToolState].lastTempPosY = mouseY_last - canvas.y/zoom.value; |
308 | } |
318 | } |
309 | } |
319 | } |
Line -... | Line 320... | ||
- | 320 | ||
- | 321 | // Selection |
|
- | 322 | int selection_start_x = -1; |
|
- | 323 | int selection_start_y = -1; |
|
- | 324 | int selection_end_x = -1; |
|
- | 325 | int selection_end_y = -1; |
|
- | 326 | bool selection_active = false; |
|
- | 327 | ||
- | 328 | dword SelectionTool_buffer = 0; |
|
- | 329 | dword SelectionTool_buffer_r = 0; |
|
- | 330 | dword SelectionTool_buffer_c = 0; |
|
- | 331 | ||
- | 332 | bool selection_moving_started = false; |
|
- | 333 | int selection_pivot_x = -1; |
|
- | 334 | int selection_pivot_y = -1; |
|
- | 335 | ||
- | 336 | void SelectTool_normalizeSelection() { |
|
- | 337 | int t; |
|
- | 338 | ||
- | 339 | // Restructuring of the selection coordinates |
|
- | 340 | if (selection_end_x < selection_start_x) { |
|
- | 341 | t = selection_start_x; |
|
- | 342 | selection_start_x = selection_end_x; |
|
- | 343 | selection_end_x = t; |
|
- | 344 | } |
|
- | 345 | ||
- | 346 | if (selection_end_y < selection_start_y) { |
|
- | 347 | t = selection_end_y; |
|
- | 348 | selection_end_y = selection_start_y; |
|
- | 349 | selection_start_y = t; |
|
- | 350 | } |
|
- | 351 | } |
|
- | 352 | ||
- | 353 | void reset_selection_moving() { |
|
- | 354 | if (selection_moving_started) { |
|
- | 355 | SelectTool_drawBuffer(selection_start_x, selection_start_y, 1); |
|
- | 356 | ||
- | 357 | selection_pivot_x = -1; |
|
- | 358 | selection_pivot_y = -1; |
|
- | 359 | ||
- | 360 | selection_moving_started = false; |
|
- | 361 | ||
- | 362 | actionsHistory.saveCurrentState(); |
|
- | 363 | DrawCanvas(); |
|
- | 364 | } |
|
- | 365 | } |
|
- | 366 | ||
- | 367 | bool is_selection_moving() { |
|
- | 368 | return selection_moving_started; |
|
- | 369 | } |
|
- | 370 | ||
- | 371 | void reset_selection() { |
|
- | 372 | reset_selection_moving(); |
|
- | 373 | ||
- | 374 | selection_start_x = -1; |
|
- | 375 | selection_start_y = -1; |
|
- | 376 | selection_end_x = -1; |
|
- | 377 | selection_end_y = -1; |
|
- | 378 | } |
|
- | 379 | ||
- | 380 | void SelectTool_activate() { |
|
- | 381 | reset_selection(); |
|
- | 382 | ||
- | 383 | selection_active = false; |
|
- | 384 | } |
|
- | 385 | ||
- | 386 | void SelectTool_deactivate() { |
|
- | 387 | reset_selection_moving(); |
|
- | 388 | } |
|
- | 389 | ||
- | 390 | bool SelectTool_pointInSelection(int x, int y) { |
|
- | 391 | if (x >= selection_start_x) && (x <= selection_end_x) && (y >= selection_start_y) && (y <= selection_end_y) |
|
- | 392 | return true; |
|
- | 393 | else |
|
- | 394 | return false; |
|
- | 395 | } |
|
- | 396 | ||
- | 397 | ||
- | 398 | void SelectTool_copyToBuffer() { |
|
- | 399 | dword offset, r, c; |
|
- | 400 | ||
- | 401 | if (SelectionTool_buffer != 0) |
|
- | 402 | free(SelectionTool_buffer); |
|
- | 403 | ||
- | 404 | SelectionTool_buffer_r = selection_end_y - selection_start_y + 1; |
|
- | 405 | SelectionTool_buffer_c = selection_end_x - selection_start_x + 1; |
|
- | 406 | SelectionTool_buffer = malloc(SelectionTool_buffer_r * SelectionTool_buffer_c * 4); |
|
- | 407 | ||
- | 408 | for (r = selection_start_y; r <= selection_end_y; r++) { |
|
- | 409 | for (c = selection_start_x; c <= selection_end_x; c++) { |
|
- | 410 | offset = calc(SelectionTool_buffer_c * calc(r - selection_start_y) + calc(c - selection_start_x)) * 4; |
|
- | 411 | ||
- | 412 | ESDWORD[SelectionTool_buffer + offset] = image.get_pixel(r, c); |
|
- | 413 | } |
|
- | 414 | } |
|
- | 415 | } |
|
- | 416 | ||
- | 417 | void SelectTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) { |
|
- | 418 | int click_x, click_y, dx, dy, m_x, m_y, r, c, color; |
|
- | 419 | dword pixel; |
|
- | 420 | ||
- | 421 | m_x = TO_CANVAS_X(mouseX); |
|
- | 422 | m_y = TO_CANVAS_Y(mouseY); |
|
- | 423 | ||
- | 424 | if (mouse.down) && (canvas.hovered()) && (!selection_active) { |
|
- | 425 | if (selection_start_x != -1) && (SelectTool_pointInSelection(m_x, m_y)) { |
|
- | 426 | if (selection_pivot_x == -1) { |
|
- | 427 | selection_pivot_x = m_x; |
|
- | 428 | selection_pivot_y = m_y; |
|
- | 429 | ||
- | 430 | GetKeys(); |
|
- | 431 | ||
- | 432 | if (!selection_moving_started) && ( !(key_modifier&KEY_LSHIFT) ) { |
|
- | 433 | for (r = selection_start_y; r <= selection_end_y; r++) |
|
- | 434 | for (c = selection_start_x; c <= selection_end_x; c++) { |
|
- | 435 | image.set_pixel(r, c, color2); |
|
- | 436 | } |
|
- | 437 | } |
|
- | 438 | ||
- | 439 | selection_moving_started = true; |
|
- | 440 | } |
|
- | 441 | } |
|
- | 442 | else { |
|
- | 443 | ||
- | 444 | reset_selection(); |
|
- | 445 | selection_active = true; |
|
- | 446 | } |
|
- | 447 | } |
|
- | 448 | ||
- | 449 | if (selection_pivot_x != -1) { |
|
- | 450 | dx = m_x - selection_pivot_x; |
|
- | 451 | dy = m_y - selection_pivot_y; |
|
- | 452 | ||
- | 453 | if (selection_start_x + dx < 0) |
|
- | 454 | dx = selection_start_x; |
|
- | 455 | ||
- | 456 | if (selection_end_x + dx >= 32) |
|
- | 457 | dx = 31 - selection_end_x; |
|
- | 458 | ||
- | 459 | if (selection_start_y + dy < 0) |
|
- | 460 | dy = selection_start_y; |
|
- | 461 | ||
- | 462 | if (selection_end_y + dy >= 32) |
|
- | 463 | dy = 31 - selection_end_y; |
|
- | 464 | ||
- | 465 | ||
- | 466 | selection_start_x += dx; |
|
- | 467 | selection_end_x += dx; |
|
- | 468 | ||
- | 469 | selection_start_y += dy; |
|
- | 470 | selection_end_y += dy; |
|
- | 471 | ||
- | 472 | selection_pivot_x += dx; |
|
- | 473 | selection_pivot_y += dy; |
|
- | 474 | ||
- | 475 | DrawCanvas(); |
|
- | 476 | } |
|
- | 477 | ||
- | 478 | if (selection_active) |
|
- | 479 | { |
|
- | 480 | if (mouseX>canvas.x+canvas.w-zoom.value) mouseX = canvas.x+canvas.w-zoom.value; |
|
- | 481 | if (mouseY>canvas.y+canvas.h-zoom.value) mouseY = canvas.y+canvas.h-zoom.value; |
|
- | 482 | ||
- | 483 | if (mouseX |
|
- | 484 | if (mouseY |
|
- | 485 | ||
- | 486 | if (mouse.key) { |
|
- | 487 | selection_end_x = TO_CANVAS_X(mouseX); |
|
- | 488 | selection_end_y = TO_CANVAS_Y(mouseY); |
|
- | 489 | ||
- | 490 | if ((selection_start_x < 0) || (selection_start_y < 0)) { |
|
- | 491 | selection_start_x = TO_CANVAS_X(mouseX); |
|
- | 492 | selection_start_y = TO_CANVAS_Y(mouseY); |
|
- | 493 | } |
|
- | 494 | else { |
|
- | 495 | DrawCanvas(); |
|
- | 496 | ||
- | 497 | /**if ((calc(TO_CANVAS_X(mouseX)) != selection_end_x) |
|
- | 498 | || (calc(TO_CANVAS_Y(mouseY)) != selection_end_y)) |
|
- | 499 | { |
|
- | 500 | DrawCanvas(); |
|
- | 501 | }*/ |
|
- | 502 | } |
|
- | 503 | ||
- | 504 | } |
|
- | 505 | ||
- | 506 | if (mouse.up) { |
|
- | 507 | selection_active = false; |
|
- | 508 | ||
- | 509 | SelectTool_normalizeSelection(); |
|
- | 510 | SelectTool_copyToBuffer(); |
|
- | 511 | } |
|
- | 512 | } |
|
- | 513 | ||
- | 514 | if (mouse.up) { |
|
- | 515 | if (selection_pivot_x != -1) { |
|
- | 516 | selection_pivot_x = -1; |
|
- | 517 | selection_pivot_y = -1; |
|
- | 518 | } |
|
- | 519 | } |
|
- | 520 | } |
|
- | 521 | ||
- | 522 | void SelectTool_onCanvasDraw() { |
|
- | 523 | if (selection_moving_started) |
|
- | 524 | SelectTool_drawBuffer(selection_start_x, selection_start_y, 2); |
|
- | 525 | ||
- | 526 | if ((selection_start_x >= 0) && (selection_start_y >= 0) && (selection_end_x >= 0) && (selection_end_y >= 0)) { |
|
- | 527 | DrawSelection(selection_start_x, selection_start_y, selection_end_x, selection_end_y); |
|
- | 528 | } |
|
- | 529 | } |
|
- | 530 | ||
- | 531 | void SelectTool_drawBuffer(int insert_x, int insert_y, int target) { |
|
- | 532 | dword color; |
|
- | 533 | dword offset, r, c; |
|
- | 534 | dword insert_to_x, insert_to_y; |
|
- | 535 | ||
- | 536 | if (SelectionTool_buffer != 0) { |
|
- | 537 | insert_to_x = insert_x + SelectionTool_buffer_c - 1; |
|
- | 538 | ||
- | 539 | if (insert_to_x >= image.columns) |
|
- | 540 | insert_to_x = image.columns-1; |
|
- | 541 | ||
- | 542 | insert_to_y = insert_y + SelectionTool_buffer_r - 1; |
|
- | 543 | ||
- | 544 | if (insert_to_y >= image.rows) |
|
- | 545 | insert_to_y = image.rows-1; |
|
- | 546 | ||
- | 547 | for (r = insert_y; r <= insert_to_y; r++) { |
|
- | 548 | for (c = insert_x; c <= insert_to_x; c++) { |
|
- | 549 | offset = calc(SelectionTool_buffer_c * calc(r - insert_y) + calc(c - insert_x)) * 4; |
|
- | 550 | ||
- | 551 | color = ESDWORD[SelectionTool_buffer + offset]; |
|
- | 552 | ||
- | 553 | if (target == 1) |
|
- | 554 | image.set_pixel(r, c, color); |
|
- | 555 | else |
|
- | 556 | DrawBar(c*zoom.value + canvas.x, r*zoom.value + canvas.y, |
|
- | 557 | zoom.value, zoom.value, color); |
|
- | 558 | } |
|
- | 559 | } |
|
- | 560 | } |
|
- | 561 | } |
|
- | 562 | ||
- | 563 | void SelectTool_onKeyEvent(dword keycode) { |
|
- | 564 | dword offset, r, c; |
|
- | 565 | dword insert_x, insert_y, insert_to_x, insert_to_y; |
|
- | 566 | ||
- | 567 | if (keycode == SCAN_CODE_KEY_V) { |
|
- | 568 | if (SelectionTool_buffer != 0) { |
|
- | 569 | reset_selection(); |
|
- | 570 | ||
- | 571 | selection_moving_started = true; |
|
- | 572 | selection_start_x = 0; |
|
- | 573 | selection_end_x = SelectionTool_buffer_c - 1; |
|
- | 574 | ||
- | 575 | selection_start_y = 0; |
|
- | 576 | selection_end_y = SelectionTool_buffer_r - 1; |
|
- | 577 | ||
- | 578 | DrawCanvas(); |
|
- | 579 | ||
- | 580 | } |
|
- | 581 | } |
|
- | 582 | } |
|
310 | 583 | ||
311 | void initTools() |
584 | void initTools() |
312 | { |
585 | { |
313 | tools[0].id = TOOL_PENCIL; |
586 | tools[0].id = TOOL_PENCIL; |
314 | tools[0].onMouseEvent = #PencilTool_onMouseEvent; |
587 | tools[0].onMouseEvent = #PencilTool_onMouseEvent; |
Line 330... | Line 603... | ||
330 | tools[4].id = TOOL_RECT; |
603 | tools[4].id = TOOL_RECT; |
331 | tools[4].activate = #SimpleFigureTool_Reset; |
604 | tools[4].activate = #SimpleFigureTool_Reset; |
332 | tools[4].deactivate = #SimpleFigureTool_Reset; |
605 | tools[4].deactivate = #SimpleFigureTool_Reset; |
333 | tools[4].onMouseEvent = #SimpleFigureTool_onMouseEvent; |
606 | tools[4].onMouseEvent = #SimpleFigureTool_onMouseEvent; |
334 | tools[4].onCanvasDraw = #SimpleFigureTool_onCanvasDraw; |
607 | tools[4].onCanvasDraw = #SimpleFigureTool_onCanvasDraw; |
- | 608 | ||
- | 609 | tools[5].id = TOOL_SELECT; |
|
- | 610 | tools[5].activate = #SelectTool_activate; |
|
- | 611 | tools[5].deactivate = #SelectTool_deactivate; |
|
- | 612 | tools[5].onMouseEvent = #SelectTool_onMouseEvent; |
|
- | 613 | tools[5].onCanvasDraw = #SelectTool_onCanvasDraw; |
|
- | 614 | tools[5].onKeyEvent = #SelectTool_onKeyEvent; |
|
335 | } |
615 | } |
Line 336... | Line 616... | ||
336 | 616 | ||
337 | void main() |
617 | void main() |
338 | { |
618 | { |
Line 392... | Line 672... | ||
392 | 672 | ||
Line 393... | Line 673... | ||
393 | break; |
673 | break; |
394 | 674 | ||
395 | case evButton: |
- | |
- | 675 | case evButton: |
|
396 | btn = GetButtonID(); |
676 | btn = GetButtonID(); |
397 | if (zoom.click(btn)) DrawEditArea(); |
677 | |
398 | switch(btn) |
678 | switch(btn) |
399 | { |
679 | { |
400 | case BTN_NEW: |
680 | case BTN_NEW: |
Line 446... | Line 726... | ||
446 | setCurrentTool(TOOL_LINE); |
726 | setCurrentTool(TOOL_LINE); |
447 | break; |
727 | break; |
448 | case BTN_RECT: |
728 | case BTN_RECT: |
449 | setCurrentTool(TOOL_RECT); |
729 | setCurrentTool(TOOL_RECT); |
450 | break; |
730 | break; |
- | 731 | case BTN_SELECT: |
|
- | 732 | setCurrentTool(TOOL_SELECT); |
|
- | 733 | break; |
|
- | 734 | case BTN_ZOOM_IN: |
|
- | 735 | zoom.inc(); |
|
- | 736 | DrawEditArea(); |
|
- | 737 | break; |
|
- | 738 | case BTN_ZOOM_OUT: |
|
- | 739 | zoom.dec(); |
|
- | 740 | DrawEditArea(); |
|
- | 741 | break; |
|
451 | case CLOSE_BTN: |
742 | case CLOSE_BTN: |
452 | ExitProcess(); |
743 | ExitProcess(); |
453 | break; |
744 | break; |
454 | } |
745 | } |
455 | break; |
746 | break; |
Line 456... | Line 747... | ||
456 | 747 | ||
457 | case evKey: |
748 | case evKey: |
- | 749 | GetKeys(); |
|
- | 750 | ||
- | 751 | if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0) |
|
- | 752 | tools[currentTool].onKeyEvent(key_scancode); |
|
458 | GetKeys(); |
753 | |
459 | if (key_scancode == SCAN_CODE_ESC) setCurrentTool(TOOL_PENCIL); |
754 | if (key_scancode == SCAN_CODE_ESC) setCurrentTool(TOOL_PENCIL); |
460 | if (key_scancode == SCAN_CODE_KEY_P) setCurrentTool(TOOL_PENCIL); |
755 | if (key_scancode == SCAN_CODE_KEY_P) setCurrentTool(TOOL_PENCIL); |
461 | if (key_scancode == SCAN_CODE_KEY_I) setCurrentTool(TOOL_PIPETTE); |
756 | if (key_scancode == SCAN_CODE_KEY_I) setCurrentTool(TOOL_PIPETTE); |
462 | if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL); |
757 | if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL); |
463 | if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE); |
758 | if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE); |
Line 464... | Line 759... | ||
464 | if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT); |
759 | if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT); |
465 | 760 | ||
- | 761 | if (key_scancode == SCAN_CODE_KEY_Z) && (key_modifier&KEY_LCTRL) actionsHistory.undoLastAction(); |
|
- | 762 | if (key_scancode == SCAN_CODE_KEY_Y) && (key_modifier&KEY_LCTRL) actionsHistory.redoLastAction(); |
|
- | 763 | ||
Line 466... | Line -... | ||
466 | if (key_scancode == SCAN_CODE_KEY_S) actionsHistory.undoLastAction(); |
- | |
467 | if (key_scancode == SCAN_CODE_KEY_C) actionsHistory.redoLastAction(); |
- | |
468 | 764 | if (key_scancode == SCAN_CODE_MINUS) {zoom.dec(); DrawEditArea();} |
|
Line 469... | Line 765... | ||
469 | if (key_scancode == SCAN_CODE_MINUS) {zoom.inc(); DrawEditArea();} |
765 | if (key_scancode == SCAN_CODE_PLUS) {zoom.inc(); DrawEditArea();} |
470 | if (key_scancode == SCAN_CODE_PLUS) {zoom.dec(); DrawEditArea();} |
766 | |
471 | break; |
767 | break; |
Line 543... | Line 839... | ||
543 | DrawLeftPanelButton(BTN_PENCIL, ty.inc(TB_ICON_PADDING), 38); |
839 | DrawLeftPanelButton(BTN_PENCIL, ty.inc(TB_ICON_PADDING), 38); |
544 | DrawLeftPanelButton(BTN_PICK, ty.inc(TB_ICON_PADDING), 39); |
840 | DrawLeftPanelButton(BTN_PICK, ty.inc(TB_ICON_PADDING), 39); |
545 | DrawLeftPanelButton(BTN_FILL, ty.inc(TB_ICON_PADDING), 40); |
841 | DrawLeftPanelButton(BTN_FILL, ty.inc(TB_ICON_PADDING), 40); |
546 | DrawLeftPanelButton(BTN_LINE, ty.inc(TB_ICON_PADDING), 41); |
842 | DrawLeftPanelButton(BTN_LINE, ty.inc(TB_ICON_PADDING), 41); |
547 | DrawLeftPanelButton(BTN_RECT, ty.inc(TB_ICON_PADDING), 42); |
843 | DrawLeftPanelButton(BTN_RECT, ty.inc(TB_ICON_PADDING), 42); |
- | 844 | DrawLeftPanelButton(BTN_SELECT, ty.inc(TB_ICON_PADDING), 43); |
|
548 | DrawRectangle3D(5, currentTool*TB_ICON_PADDING+TOOLBAR_H, 16+3+2, 16+3+2, 0x333333, 0x777777); |
845 | DrawRectangle3D(5, currentTool*TB_ICON_PADDING+TOOLBAR_H, 16+3+2, 16+3+2, 0x333333, 0x777777); |
549 | } |
846 | } |
Line 550... | Line 847... | ||
550 | 847 | ||
551 | void DrawEditArea() |
848 | void DrawEditArea() |
Line 819... | Line 1116... | ||
819 | DrawLine(x1, y1, x2, y1, color, target); |
1116 | DrawLine(x1, y1, x2, y1, color, target); |
820 | DrawLine(x2, y1, x2, y2, color, target); |
1117 | DrawLine(x2, y1, x2, y2, color, target); |
821 | DrawLine(x2, y2, x1, y2, color, target); |
1118 | DrawLine(x2, y2, x1, y2, color, target); |
822 | DrawLine(x1, y2, x1, y1, color, target); |
1119 | DrawLine(x1, y2, x1, y1, color, target); |
823 | }>>>>>>>>>>>>>=w;>>>>> |
1120 | } |
824 | 1121 | ||
- | 1122 | #define SELECTION_COLOR 0xAAE5EF |
|
- | 1123 | ||
- | 1124 | void DrawSelection(int x1, int y1, int x2, int y2) { |
|
- | 1125 | int p1x, p1y, p2x, p2y, r, c, old_color, new_color; |
|
- | 1126 | dword offset; |
|
- | 1127 | ||
- | 1128 | if (x1 <= x2) { |
|
- | 1129 | p1x = x1; |
|
- | 1130 | p2x = x2; |
|
- | 1131 | } |
|
- | 1132 | else { |
|
- | 1133 | p1x = x2; |
|
- | 1134 | p2x = x1; |
|
- | 1135 | } |
|
- | 1136 | ||
- | 1137 | if (y1 <= y2) { |
|
- | 1138 | p2y = y1; |
|
- | 1139 | p1y = y2; |
|
- | 1140 | } |
|
- | 1141 | else { |
|
- | 1142 | p2y = y2; |
|
- | 1143 | p1y = y1; |
|
- | 1144 | } |
|
- | 1145 | ||
- | 1146 | for (r = p1y; r >= p2y; r--) { |
|
- | 1147 | for (c = p1x; c <= p2x; c++) { |
|
- | 1148 | ||
- | 1149 | if (selection_moving_started) && (SelectTool_pointInSelection(c, r)) { |
|
- | 1150 | offset = calc(SelectionTool_buffer_c * calc(r - selection_start_y) + calc(c - selection_start_x)) * 4; |
|
- | 1151 | old_color = ESDWORD[SelectionTool_buffer + offset]; |
|
- | 1152 | } |
|
- | 1153 | else { |
|
- | 1154 | old_color = image.get_pixel(r, c); |
|
- | 1155 | } |
|
- | 1156 | ||
- | 1157 | new_color = MixColors(old_color, SELECTION_COLOR, 64); |
|
- | 1158 | ||
- | 1159 | DrawBar(c*zoom.value + canvas.x, r*zoom.value + canvas.y, |
|
- | 1160 | zoom.value, zoom.value, new_color); |
|
- | 1161 | ||
- | 1162 | } |
|
- | 1163 | } |
|
- | 1164 | }=>=>=>>>>>>>>>>>>>>=w;>>>=>=>>>>>=>=>=>=>=>=>>>>> |
|
- | 1165 | ||
825 | 1166 |