IconEdit 0.50: new tool "Screen copy"

git-svn-id: svn://kolibrios.org@7260 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-04-25 19:09:26 +00:00
parent 5959be0518
commit 668f8c2bdb
4 changed files with 42 additions and 7 deletions

View File

@ -11,7 +11,7 @@ enhance icon
pipet aside color view pipet aside color view
*/ */
#define MEMSIZE 4096*200 #define MEMSIZE 4096*250
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/random.h" #include "../lib/random.h"
@ -31,7 +31,7 @@ pipet aside color view
// // // //
//===================================================// //===================================================//
#define T_TITLE "Icon Editor 0.49 Alpha" #define T_TITLE "Icon Editor 0.50 Alpha"
#define TOOLBAR_H 24+8 #define TOOLBAR_H 24+8
#define PANEL_LEFT_W 16+5+5+3+3 #define PANEL_LEFT_W 16+5+5+3+3
@ -82,7 +82,7 @@ enum {
BTN_RECT, BTN_RECT,
BTN_BAR, BTN_BAR,
BTN_SELECT, BTN_SELECT,
BTN_SCREEN, BTN_SCREEN_COPY,
BTN_ZOOM_IN, BTN_ZOOM_IN,
BTN_ZOOM_OUT, BTN_ZOOM_OUT,
BTNS_PALETTE_COLOR_MAS = 100, BTNS_PALETTE_COLOR_MAS = 100,
@ -272,6 +272,9 @@ void main()
case BTN_SELECT: case BTN_SELECT:
setCurrentTool(TOOL_SELECT); setCurrentTool(TOOL_SELECT);
break; break;
case BTN_SCREEN_COPY:
setCurrentTool(TOOL_SCREEN_COPY);
break;
case CLOSE_BTN: case CLOSE_BTN:
EventExitIconEdit(); EventExitIconEdit();
break; break;
@ -290,6 +293,8 @@ void main()
if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL); if (key_scancode == SCAN_CODE_KEY_F) setCurrentTool(TOOL_FILL);
if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE); if (key_scancode == SCAN_CODE_KEY_L) setCurrentTool(TOOL_LINE);
if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT); if (key_scancode == SCAN_CODE_KEY_R) setCurrentTool(TOOL_RECT);
if (key_scancode == SCAN_CODE_KEY_B) setCurrentTool(TOOL_BAR);
if (key_scancode == SCAN_CODE_KEY_S) setCurrentTool(TOOL_SELECT);
if (key_scancode == SCAN_CODE_KEY_Z) && (key_modifier&KEY_LCTRL) actionsHistory.undoLastAction(); if (key_scancode == SCAN_CODE_KEY_Z) && (key_modifier&KEY_LCTRL) actionsHistory.undoLastAction();
if (key_scancode == SCAN_CODE_KEY_Y) && (key_modifier&KEY_LCTRL) actionsHistory.redoLastAction(); if (key_scancode == SCAN_CODE_KEY_Y) && (key_modifier&KEY_LCTRL) actionsHistory.redoLastAction();
@ -377,7 +382,7 @@ void DrawLeftPanel()
DrawLeftPanelButton(BTN_RECT, ty.inc(TB_ICON_PADDING), 42); DrawLeftPanelButton(BTN_RECT, ty.inc(TB_ICON_PADDING), 42);
DrawLeftPanelButton(BTN_BAR, ty.inc(TB_ICON_PADDING), 43); DrawLeftPanelButton(BTN_BAR, ty.inc(TB_ICON_PADDING), 43);
DrawLeftPanelButton(BTN_SELECT, ty.inc(TB_ICON_PADDING), 44); DrawLeftPanelButton(BTN_SELECT, ty.inc(TB_ICON_PADDING), 44);
//DrawLeftPanelButton(BTN_SCREEN, ty.inc(TB_ICON_PADDING), 45); DrawLeftPanelButton(BTN_SCREEN_COPY, ty.inc(TB_ICON_PADDING), 45);
DrawRectangle3D(5, currentTool*TB_ICON_PADDING+right_bar.y, 16+3+2, 16+3+2, 0x333333, 0x777777); DrawRectangle3D(5, currentTool*TB_ICON_PADDING+right_bar.y, 16+3+2, 16+3+2, 0x333333, 0x777777);
} }

View File

@ -13,7 +13,7 @@ struct Tool {
int previousTool = -1; int previousTool = -1;
int currentTool = -1; int currentTool = -1;
Tool tools[7]; Tool tools[8];
enum { enum {
TOOL_NONE = -1, TOOL_NONE = -1,
@ -23,13 +23,15 @@ enum {
TOOL_LINE, TOOL_LINE,
TOOL_RECT, TOOL_RECT,
TOOL_BAR, TOOL_BAR,
TOOL_SELECT TOOL_SELECT,
TOOL_SCREEN_COPY
}; };
#include "tools/pencil.h"; #include "tools/pencil.h";
#include "tools/pipette.h"; #include "tools/pipette.h";
#include "tools/fill.h"; #include "tools/fill.h";
#include "tools/selection.h";
#include "tools/simple_figure.h"; #include "tools/simple_figure.h";
#include "tools/selection.h";
#include "tools/screen_copy.h";
void initTools() void initTools()
@ -69,6 +71,10 @@ void initTools()
tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent; tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent;
tools[TOOL_SELECT].onCanvasDraw = #SelectTool_onCanvasDraw; tools[TOOL_SELECT].onCanvasDraw = #SelectTool_onCanvasDraw;
tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent; tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent;
tools[TOOL_SCREEN_COPY].id = TOOL_SCREEN_COPY;
tools[TOOL_SCREEN_COPY].activate = #ScreenCopy_activate;
tools[TOOL_SCREEN_COPY].onMouseEvent = #ScreenCopy_onMouseEvent;
} }

View File

@ -0,0 +1,23 @@
dword screen_copy;
void ScreenCopy_activate() {
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE);
screen_copy = malloc(image.columns * image.rows * 3 );
}
void ScreenCopy_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
dword i;
CopyScreen(screen_copy, mouse.x + Form.left + 5, mouse.y + Form.top + skin_height, image.columns, image.rows);
for (i = 0; i < image.columns*image.rows; i++;)
{
image.mas[i] = ESDWORD[i*3+screen_copy] & 0xFFFFFF;
}
DrawCanvas();
if (mouse.down) {
screen_copy = free(screen_copy);
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
actionsHistory.saveCurrentState();
setCurrentTool(previousTool);
}
}

View File

@ -42,6 +42,7 @@
#define SCAN_CODE_F1 059 #define SCAN_CODE_F1 059
#define SCAN_CODE_KEY_B 048
#define SCAN_CODE_KEY_C 046 #define SCAN_CODE_KEY_C 046
#define SCAN_CODE_KEY_E 018 #define SCAN_CODE_KEY_E 018
#define SCAN_CODE_KEY_F 033 #define SCAN_CODE_KEY_F 033