IconEdit 0.51: tools cursor support

git-svn-id: svn://kolibrios.org@7262 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-04-29 20:42:03 +00:00
parent db0198fa2d
commit 2c8b040e97
7 changed files with 35 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@ -16,6 +16,7 @@ pipet aside color view
#include "../lib/gui.h" #include "../lib/gui.h"
#include "../lib/random.h" #include "../lib/random.h"
#include "../lib/mem.h" #include "../lib/mem.h"
#include "../lib/cursor.h"
#include "../lib/obj/libimg.h" #include "../lib/obj/libimg.h"
#include "../lib/obj/box_lib.h" #include "../lib/obj/box_lib.h"
@ -31,7 +32,7 @@ pipet aside color view
// // // //
//===================================================// //===================================================//
#define T_TITLE "Icon Editor 0.50 Alpha" #define T_TITLE "Icon Editor 0.51 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
@ -114,6 +115,15 @@ dword last_used_colors[13*2] = {
0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF 0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF,0xFFFFFF
}; };
CustomCursor Cursor;
dword CursorBar = FROM "cursors/bar.cur";
dword CursorFill = FROM "cursors/fill.cur";
dword CursorLine = FROM "cursors/line.cur";
dword CursorPencil = FROM "cursors/pencil.cur";
dword CursorPipette = FROM "cursors/pipette.cur";
dword CursorRectangle = FROM "cursors/rectangle.cur";
dword CursorSelect = FROM "cursors/select.cur";
_image image; _image image;
#include "actions_history.h" #include "actions_history.h"
@ -200,6 +210,9 @@ void main()
DrawEditArea(); DrawEditArea();
} }
if (wrapper.hovered()) SetCursor();
else Cursor.Restore();
if (mouse.down) { if (mouse.down) {
if (b_color_gradient.hovered()) if (b_color_gradient.hovered())
|| (b_last_colors.hovered()) || (b_last_colors.hovered())

View File

@ -4,6 +4,7 @@
struct Tool { struct Tool {
int id; int id;
dword cursor;
void (*activate)(); void (*activate)();
void (*deactivate)(); void (*deactivate)();
void (*onMouseEvent)(int x, int y, int lkm, int pkm); void (*onMouseEvent)(int x, int y, int lkm, int pkm);
@ -37,35 +38,42 @@ enum {
void initTools() void initTools()
{ {
tools[TOOL_PENCIL].id = TOOL_PENCIL; tools[TOOL_PENCIL].id = TOOL_PENCIL;
tools[TOOL_PENCIL].cursor = #CursorPencil;
tools[TOOL_PENCIL].onMouseEvent = #PencilTool_onMouseEvent; tools[TOOL_PENCIL].onMouseEvent = #PencilTool_onMouseEvent;
tools[TOOL_PENCIL].deactivate = #PencilTool_reset; tools[TOOL_PENCIL].deactivate = #PencilTool_reset;
tools[TOOL_PIPETTE].id = TOOL_PIPETTE; tools[TOOL_PIPETTE].id = TOOL_PIPETTE;
tools[TOOL_PIPETTE].cursor = #CursorPipette;
tools[TOOL_PIPETTE].activate = #PipetteTool_activate; tools[TOOL_PIPETTE].activate = #PipetteTool_activate;
tools[TOOL_PIPETTE].onMouseEvent = #PipetteTool_onMouseEvent; tools[TOOL_PIPETTE].onMouseEvent = #PipetteTool_onMouseEvent;
tools[TOOL_FILL].id = TOOL_FILL; tools[TOOL_FILL].id = TOOL_FILL;
tools[TOOL_FILL].cursor = #CursorFill;
tools[TOOL_FILL].onMouseEvent = #FillTool_onMouseEvent; tools[TOOL_FILL].onMouseEvent = #FillTool_onMouseEvent;
tools[TOOL_LINE].id = TOOL_LINE; tools[TOOL_LINE].id = TOOL_LINE;
tools[TOOL_LINE].cursor = #CursorLine;
tools[TOOL_LINE].activate = #SimpleFigureTool_Reset; tools[TOOL_LINE].activate = #SimpleFigureTool_Reset;
tools[TOOL_LINE].deactivate = #SimpleFigureTool_Reset; tools[TOOL_LINE].deactivate = #SimpleFigureTool_Reset;
tools[TOOL_LINE].onMouseEvent = #SimpleFigureTool_onMouseEvent; tools[TOOL_LINE].onMouseEvent = #SimpleFigureTool_onMouseEvent;
tools[TOOL_LINE].onCanvasDraw = #SimpleFigureTool_onCanvasDraw; tools[TOOL_LINE].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
tools[TOOL_RECT].id = TOOL_RECT; tools[TOOL_RECT].id = TOOL_RECT;
tools[TOOL_RECT].cursor = #CursorRectangle;
tools[TOOL_RECT].activate = #SimpleFigureTool_Reset; tools[TOOL_RECT].activate = #SimpleFigureTool_Reset;
tools[TOOL_RECT].deactivate = #SimpleFigureTool_Reset; tools[TOOL_RECT].deactivate = #SimpleFigureTool_Reset;
tools[TOOL_RECT].onMouseEvent = #SimpleFigureTool_onMouseEvent; tools[TOOL_RECT].onMouseEvent = #SimpleFigureTool_onMouseEvent;
tools[TOOL_RECT].onCanvasDraw = #SimpleFigureTool_onCanvasDraw; tools[TOOL_RECT].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
tools[TOOL_BAR].id = TOOL_BAR; tools[TOOL_BAR].id = TOOL_BAR;
tools[TOOL_BAR].cursor = #CursorBar;
tools[TOOL_BAR].activate = #SimpleFigureTool_Reset; tools[TOOL_BAR].activate = #SimpleFigureTool_Reset;
tools[TOOL_BAR].deactivate = #SimpleFigureTool_Reset; tools[TOOL_BAR].deactivate = #SimpleFigureTool_Reset;
tools[TOOL_BAR].onMouseEvent = #SimpleFigureTool_onMouseEvent; tools[TOOL_BAR].onMouseEvent = #SimpleFigureTool_onMouseEvent;
tools[TOOL_BAR].onCanvasDraw = #SimpleFigureTool_onCanvasDraw; tools[TOOL_BAR].onCanvasDraw = #SimpleFigureTool_onCanvasDraw;
tools[TOOL_SELECT].id = TOOL_SELECT; tools[TOOL_SELECT].id = TOOL_SELECT;
tools[TOOL_SELECT].cursor = #CursorSelect;
tools[TOOL_SELECT].activate = #SelectTool_activate; tools[TOOL_SELECT].activate = #SelectTool_activate;
tools[TOOL_SELECT].deactivate = #SelectTool_deactivate; tools[TOOL_SELECT].deactivate = #SelectTool_deactivate;
tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent; tools[TOOL_SELECT].onMouseEvent = #SelectTool_onMouseEvent;
@ -73,6 +81,7 @@ void initTools()
tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent; tools[TOOL_SELECT].onKeyEvent = #SelectTool_onKeyEvent;
tools[TOOL_SCREEN_COPY].id = TOOL_SCREEN_COPY; tools[TOOL_SCREEN_COPY].id = TOOL_SCREEN_COPY;
tools[TOOL_SCREEN_COPY].cursor = NULL;
tools[TOOL_SCREEN_COPY].activate = #ScreenCopy_activate; tools[TOOL_SCREEN_COPY].activate = #ScreenCopy_activate;
tools[TOOL_SCREEN_COPY].onMouseEvent = #ScreenCopy_onMouseEvent; tools[TOOL_SCREEN_COPY].onMouseEvent = #ScreenCopy_onMouseEvent;
} }
@ -94,7 +103,16 @@ void setCurrentTool(int index) {
if ((index != TOOL_NONE) && (tools[index].activate != 0)) if ((index != TOOL_NONE) && (tools[index].activate != 0))
tools[index].activate(); tools[index].activate();
Cursor.Restore();
if (wrapper.hovered()) SetCursor();
DrawLeftPanel(); DrawLeftPanel();
DrawCanvas(); DrawCanvas();
} }
void SetCursor()
{
if (tools[currentTool].cursor) && (!Cursor.CursorPointer) {
Cursor.Load(tools[currentTool].cursor);
Cursor.Set();
}
}

View File

@ -4,7 +4,7 @@ void PipetteTool_activate() {
} }
void PipetteTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) { void PipetteTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
//if (!canvas.hovered()) return; //TODO: option "Restrict pipette to canvas area" if (!canvas.hovered()) return; //TODO: option "Restrict pipette to canvas area"
tool_color = GetPixelUnderMouse(); tool_color = GetPixelUnderMouse();
DrawBar(Form.cwidth-30, 5, 20, 20, tool_color); DrawBar(Form.cwidth-30, 5, 20, 20, tool_color);

View File

@ -37,10 +37,12 @@ dword CustomCursor::Set()
dword CustomCursor::Restore() dword CustomCursor::Restore()
{ {
if (!CursorPointer) return;
EAX = 37; EAX = 37;
EBX = 5; EBX = 5;
ECX = 0; ECX = 0;
$int 0x40 $int 0x40
CursorPointer = 0;
} }
void CustomCursor::Delete() void CustomCursor::Delete()