/programs/cmm/iconedit/actions_history.h |
---|
1,4 → 1,3 |
// Actions history |
#define MAX_ACTIONS_COUNT 15 |
24,8 → 23,10 |
head = tail = 0; |
currentIndex = -1; |
for (i = 0; i < MAX_ACTIONS_COUNT; i++) |
for (i = 0; i < MAX_ACTIONS_COUNT; i++) { |
stack[i] = free(stack[i]); |
stack[i] = malloc(image.columns * image.rows * 4); |
} |
saveCurrentState(); |
} |
/programs/cmm/iconedit/canvas_resize.h |
---|
0,0 → 1,96 |
child_window Window_CanvasReSize = {#CanvasReSize_Thread}; |
//===================================================// |
// // |
// CODE // |
// // |
//===================================================// |
char text_columns[4]; |
char text_rows[4]; |
edit_box edit_columns = {60,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
0x10000000,sizeof(text_columns)-1,#text_columns,0, 1000000000000010b}; |
edit_box edit_rows = {60,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff, |
0x10000000,sizeof(text_rows)-1,#text_rows,0, 1000000000000000b}; |
#define BTN_APPLY 10 |
void CanvasReSize_Thread() |
{ |
int id, butw; |
sprintf(#text_columns, "%i", image.columns); |
sprintf(#text_rows, "%i", image.rows); |
edit_columns.size = edit_columns.pos = edit_columns.shift = edit_columns.shift_old = strlen(#text_columns); |
edit_rows.size = edit_rows.pos = edit_rows.shift = edit_rows.shift_old = strlen(#text_rows); |
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); |
loop() switch(WaitEvent()) |
{ |
case evMouse: |
edit_box_mouse stdcall (#edit_columns); |
edit_box_mouse stdcall (#edit_rows); |
break; |
case evKey: |
GetKeys(); |
if (SCAN_CODE_ESC == key_scancode) ExitProcess(); |
if (SCAN_CODE_ENTER == key_scancode) EventApplyClick(); |
if (SCAN_CODE_TAB == key_scancode) EventTabClick(); |
EAX= key_ascii << 8; |
edit_box_key stdcall (#edit_columns); |
edit_box_key stdcall (#edit_rows); |
break; |
case evButton: |
id = GetButtonID(); |
if (CLOSE_BTN == id) ExitProcess(); |
if (BTN_APPLY == id) EventApplyClick(); |
break; |
case evReDraw: |
DefineAndDrawWindow(Form.left+canvas.x + 100, Form.top+skin_height+canvas.y+40, |
200, 170, 0x34, system.color.work, "Canvas", 0); |
WriteText(20, 20, 0x90, system.color.work_text, "Width"); |
WriteText(20, 60, 0x90, system.color.work_text, "Height"); |
DrawStandartCaptButton(20, 100, BTN_APPLY, "OK"); |
DrawEditBoxes(); |
} |
} |
void DrawEditBoxes() |
{ |
DrawEditBoxPos(20+70, 20-4, #edit_columns); |
DrawEditBoxPos(20+70, 60-4, #edit_rows); |
} |
//===================================================// |
// // |
// EVENTS // |
// // |
//===================================================// |
void EventApplyClick() |
{ |
int new_rows = atoi(#text_rows); |
int new_columns = atoi(#text_columns); |
if (new_columns>MAX_CELL_SIZE) || (new_rows>MAX_CELL_SIZE) { |
notify("'Maximum icon size exceeded!\nPlease, try something less or equal to 256x256.' -E"); |
return; |
} |
image.create(new_rows, new_columns); |
actionsHistory.init(); |
ActivateWindow(GetProcessSlot(Form.ID)); |
ExitProcess(); |
} |
void EventTabClick() |
{ |
if (edit_columns.flags & 0b10) { edit_columns.flags -= 0b10; edit_rows.flags += 0b10; } |
else { edit_columns.flags += 0b10; edit_rows.flags -= 0b10; } |
DrawEditBoxes(); |
} |
/programs/cmm/iconedit/cursors/bar.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/cursors/fill.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/cursors/line.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/cursors/pipette.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/cursors/rectangle.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/cursors/select.cur |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/cmm/iconedit/iconedit.c |
---|
32,7 → 32,7 |
// // |
//===================================================// |
#define T_TITLE "Icon Editor 0.54.2 Alpha" |
#define T_TITLE "Icon Editor 0.55 Alpha" |
#define TOPBAR_H 24+8 |
#define LEFTBAR_W 16+5+5+3+3 |
86,6 → 86,7 |
BTN_SCREEN_COPY, |
BTN_ZOOM_IN, |
BTN_ZOOM_OUT, |
BTN_CANVAS_RESIZE, |
BTNS_PALETTE_COLOR_MAS = 100, |
BTNS_LAST_USED_COLORS = 400 |
}; |
131,6 → 132,7 |
_ActionsHistory actionsHistory; |
#include "tools.h" |
#include "canvas_resize.h" |
//===================================================// |
// // |
188,6 → 190,7 |
loop() switch(WaitEvent()) |
{ |
case evMouse: |
if (Window_CanvasReSize.thread_exists()) break; |
mouse.get(); |
if (mouse.lkm) tool_color = color1; |
233,6 → 236,7 |
break; |
case evButton: |
if (Window_CanvasReSize.thread_exists()) break; |
btn = GetButtonID(); |
if (zoom.click(btn)) DrawEditArea(); |
240,7 → 244,7 |
switch(btn) |
{ |
case BTN_NEW: |
EventCleanCanvas(); |
EventCreateNewIcon(); |
break; |
case BTN_OPEN: |
RunProgram("/sys/lod", sprintf(#param, "*png* %s",#program_path)); |
293,6 → 297,9 |
case BTN_SCREEN_COPY: |
setCurrentTool(TOOL_SCREEN_COPY); |
break; |
case BTN_CANVAS_RESIZE: |
notify("Sorry, not implemented yet."); |
break; |
case CLOSE_BTN: |
EventExitIconEdit(); |
break; |
305,6 → 312,8 |
if (currentTool != TOOL_NONE) && (tools[currentTool].onKeyEvent != 0) |
tools[currentTool].onKeyEvent(key_scancode); |
if (key_scancode == SCAN_CODE_DEL) EventCleanCanvas(); |
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); |
324,6 → 333,7 |
break; |
case evReDraw: |
Window_CanvasReSize.thread_exists(); |
draw_window(); |
break; |
} |
352,8 → 362,16 |
{ |
zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6); |
sprintf(#param,"Canvas: %ix%i", image.rows, image.columns); |
WriteText(wrapper.x+wrapper.w-calc(strlen(#param)*8), zoom.y+2, 0x90, system.color.work_text, #param); |
DrawCaptButton( |
wrapper.x+wrapper.w-calc(strlen(#param)*8) +6 - 1, |
zoom.y, |
calc(strlen(#param)*8)-6, |
18, |
BTN_CANVAS_RESIZE, |
system.color.work_button, |
system.color.work_button_text, |
sprintf(#param,"%i x %i", image.rows, image.columns) |
); |
} |
void draw_window() |
391,20 → 409,18 |
DrawEditArea(); |
//BG under LeftBar |
DrawBar(0, TOPBAR_H, LEFTBAR_W-1, Form.cheight - TOPBAR_H, system.color.work); |
//BG under RightBar |
DrawLeftPanel(); |
DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w, |
Form.cheight - TOPBAR_H, system.color.work); |
//BG under StatusBar |
DrawActiveColor(right_bar.y); |
DrawColorPallets(); |
DrawPreview(); |
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() |
608,6 → 624,12 |
// // |
//===================================================// |
void EventCreateNewIcon() |
{ |
EventSaveIconToFile(); |
Window_CanvasReSize.create(); |
} |
void EventSaveIconToFile() |
{ |
int i=0; |
623,8 → 645,8 |
void EventCleanCanvas() |
{ |
EventSaveIconToFile(); |
image.create(32, 32); |
image.create(image.rows, image.columns); |
actionsHistory.saveCurrentState(); |
DrawCanvas(); |
} |
/programs/cmm/lib/gui/child_window.h |
---|
0,0 → 1,23 |
:struct child_window |
{ |
dword window_loop_pointer; |
dword id; |
char stak[4096]; |
void create(); |
bool thread_exists(); |
}; |
:void child_window::create() |
{ |
id = CreateThread(window_loop_pointer, #stak+4092); |
} |
:bool child_window::thread_exists() |
{ |
dword proc_slot = GetProcessSlot(id); |
if (proc_slot) { |
ActivateWindow(proc_slot); |
return true; |
} |
return false; |
} |
/programs/cmm/lib/gui/text_view_area.h |
---|
0,0 → 1,54 |
/* |
We have a long text and need to show it in block. |
Normal line break '\n' must be applied. |
Long lines should be breaked by word. |
TODO: scroll |
*/ |
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col) |
{ |
dword write_start; |
dword buf_end; |
int line_h = 15; |
int label_length_max; |
int write_length; |
bool end_found; |
write_start = buf_start; |
buf_end = strlen(buf_start) + buf_start; |
label_length_max = w / 8; // 8 big font char width |
loop() |
{ |
if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col); |
end_found = false; |
write_length = strchr(write_start, '\n') - write_start; //search normal line break |
if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found |
{ |
if (buf_end - write_start < label_length_max) //check does current line the last |
{ |
write_length = buf_end - write_start; |
end_found = true; |
} |
else |
{ |
for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break |
if (ESBYTE[write_start+write_length] == ' ') { |
end_found = true; |
break; |
} |
} |
} |
if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max |
} |
ESI = write_length; //set text length attribute for WriteText() |
WriteText(x, y, 0x10, text_col, write_start); |
// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) { |
// WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|"); |
// } |
write_start += write_length + 1; |
y += line_h; |
if (write_start >= buf_end) break; |
} |
if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col); |
return y+line_h; |
} |
/programs/cmm/lib/gui.h |
---|
20,6 → 20,8 |
#include "../lib/gui/tabs.h" |
#include "../lib/gui/more_less_box.h" |
#include "../lib/gui/checkbox.h" |
#include "../lib/gui/child_window.h" |
#include "../lib/gui/text_view_area.h" |
:int last_free_button_id = 1000; |
:int GetFreeButtonId() |
229,62 → 231,6 |
ESBYTE[next_word_pointer] = '\n'; |
} |
/* |
We have a long text and need to show it in block. |
Normal line break '\n' must be applied. |
Long lines should be breaked by word. |
TODO: scroll |
*/ |
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col) |
{ |
dword write_start; |
dword buf_end; |
int line_h = 15; |
int label_length_max; |
int write_length; |
bool end_found; |
write_start = buf_start; |
buf_end = strlen(buf_start) + buf_start; |
label_length_max = w / 8; // 8 big font char width |
loop() |
{ |
if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col); |
end_found = false; |
write_length = strchr(write_start, '\n') - write_start; //search normal line break |
if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found |
{ |
if (buf_end - write_start < label_length_max) //check does current line the last |
{ |
write_length = buf_end - write_start; |
end_found = true; |
} |
else |
{ |
for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break |
if (ESBYTE[write_start+write_length] == ' ') { |
end_found = true; |
break; |
} |
} |
} |
if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max |
} |
ESI = write_length; //set text length attribute for WriteText() |
WriteText(x, y, 0x10, text_col, write_start); |
// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) { |
// WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|"); |
// } |
write_start += write_length + 1; |
y += line_h; |
if (write_start >= buf_end) break; |
} |
if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col); |
return y+line_h; |
} |
//this function increase falue and return it |
//useful for list of controls which goes one after one |
:struct incn |