Notes 1.1:

- fixed bugs found by TheOnlyMirage
- if CPU frequency < 1000 then while drag show only window frame else whow window contents
- add to autobuild
CPUid: 
- fix app crash at unknown Intel CPU name by Sh@dy
- non-cropped "intel.gif" logo
- delete redundant knopka* files
icons32.png:
- new Notes icon
- better icons: CPUid, Gmon
- reduce file size
IconEdit 0.58:
- update preview
- rotate squire images
- Ctrl+KeyArrow moves image on the canvas
- screen copy key events
- triangle gradient marker
- improve window appearance for dark skins

git-svn-id: svn://kolibrios.org@7444 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2018-10-09 19:12:02 +00:00
parent a623f90476
commit 2a5b8498fd
16 changed files with 138 additions and 35 deletions

View File

@ -571,6 +571,7 @@ tup.append_table(img_files, {
{"APP_PLUS", PROGS .. "/cmm/app_plus/app_plus.com"}, {"APP_PLUS", PROGS .. "/cmm/app_plus/app_plus.com"},
{"EASYSHOT", PROGS .. "/cmm/easyshot/easyshot.com"}, {"EASYSHOT", PROGS .. "/cmm/easyshot/easyshot.com"},
{"MOUSECFG", PROGS .. "/cmm/mousecfg/mousecfg.com"}, {"MOUSECFG", PROGS .. "/cmm/mousecfg/mousecfg.com"},
{"NOTES", PROGS .. "/cmm/notes/notes.com"},
{"PANELS_CFG", PROGS .. "/cmm/panels_cfg/panels_cfg.com"}, {"PANELS_CFG", PROGS .. "/cmm/panels_cfg/panels_cfg.com"},
{"SYSPANEL", PROGS .. "/cmm/software_widget/software_widget.com"}, {"SYSPANEL", PROGS .. "/cmm/software_widget/software_widget.com"},
{"SYSMON", PROGS .. "/cmm/sysmon/sysmon.com"}, {"SYSMON", PROGS .. "/cmm/sysmon/sysmon.com"},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -53,6 +53,7 @@ struct _image
{ {
unsigned rows, columns; unsigned rows, columns;
dword mas[MAX_CELL_SIZE*MAX_CELL_SIZE]; dword mas[MAX_CELL_SIZE*MAX_CELL_SIZE];
dword mas_copy[MAX_CELL_SIZE*MAX_CELL_SIZE];
dword img; dword img;
_pixel_state pixel_state; _pixel_state pixel_state;
void create(); void create();
@ -221,7 +222,8 @@ enum {
MOVE_DOWN, MOVE_DOWN,
FLIP_VER, FLIP_VER,
FLIP_HOR, FLIP_HOR,
ROTE ROTATE_LEFT,
ROTATE_RIGHT
}; };
void _image::move(int _direction) void _image::move(int _direction)
{ {
@ -278,9 +280,44 @@ void _image::move(int _direction)
set_pixel(rows-r-1, c, first_element_data); set_pixel(rows-r-1, c, first_element_data);
} }
break; break;
case ROTATE_LEFT:
//slow but the code is simple
//need to rewrite in case of big images support
move(ROTATE_RIGHT);
move(ROTATE_RIGHT);
move(ROTATE_RIGHT);
break;
case ROTATE_RIGHT:
if (columns!=rows) {
notify("Sorry, rotate is implemented for square canvaces only!");
break;
}
for (r=0; r<MAX_CELL_SIZE*MAX_CELL_SIZE; r++) {
mas_copy[r] = mas[r];
}
for (c = 0; c < columns; c++)
for (r = 0; r < rows; r++) {
set_pixel(c, rows-r-1, mas_copy[columns*r + c]);
}
columns >< rows;
break;
} }
} }
/*
1234
5678
90AB
951
0
A
B
*/

View File

@ -41,7 +41,7 @@ In other case please use <Photo> tool to get an image from screen.' -Wt"
#endif #endif
#define T_TITLE "Icon Editor 0.57b Alpha" #define T_TITLE "Icon Editor 0.58 Alpha"
#define TOPBAR_H 24+8 #define TOPBAR_H 24+8
#define LEFTBAR_W 16+5+5+3+3 #define LEFTBAR_W 16+5+5+3+3
@ -162,7 +162,7 @@ void main()
{ {
word btn; word btn;
libimg_image open_image; libimg_image open_image;
dword tmp_bg_col; dword bg_col;
load_dll(libio, #libio_init, 1); load_dll(libio, #libio_init, 1);
load_dll(libimg, #libimg_init, 1); load_dll(libimg, #libimg_init, 1);
@ -172,8 +172,10 @@ void main()
Libimg_LoadImage(#left_icons, "/sys/icons16.png"); Libimg_LoadImage(#left_icons, "/sys/icons16.png");
system.color.get(); system.color.get();
bg_col = system.color.work;
if (GrayScaleImage(#bg_col,1,1)<65) bg_dark=true; else bg_dark=false;
semi_white = MixColors(system.color.work, 0xFFFfff, 96); semi_white = MixColors(system.color.work, 0xFFFfff, bg_dark*90 + 96);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white); Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffFFFfff, semi_white);
Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220)); Libimg_ReplaceColor(top_icons.image, top_icons.w, top_icons.h, 0xffCACBD6, MixColors(semi_white, 0, 220));
@ -181,7 +183,6 @@ void main()
Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200)); Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xffCACBD6, MixColors(system.color.work, 0, 200));
//fix line and rectandle color for dark skins //fix line and rectandle color for dark skins
if (GrayScaleImage(#system.color.work,1,1)<65) bg_dark=true; else bg_dark=false;
if (bg_dark) Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xff545454, 0xffD3D3D4); if (bg_dark) Libimg_ReplaceColor(left_icons.image, left_icons.w, left_icons.h, 0xff545454, 0xffD3D3D4);
EventSetActiveColor(1, color1); EventSetActiveColor(1, color1);
@ -293,6 +294,12 @@ void main()
case BTN_FLIP_HOR: case BTN_FLIP_HOR:
EventMove(FLIP_HOR); EventMove(FLIP_HOR);
break; break;
case BTN_ROTATE_LEFT:
EventMove(ROTATE_LEFT);
break;
case BTN_ROTATE_RIGHT:
EventMove(ROTATE_RIGHT);
break;
case BTN_TEST_ICON: case BTN_TEST_ICON:
EventTestIcon(); EventTestIcon();
break; break;
@ -345,6 +352,24 @@ void main()
case SCAN_CODE_KEY_O: case SCAN_CODE_KEY_O:
EventOpenIcon(); EventOpenIcon();
break; break;
case SCAN_CODE_LEFT:
EventMove(MOVE_LEFT);
break;
case SCAN_CODE_RIGHT:
EventMove(MOVE_RIGHT);
break;
case SCAN_CODE_UP:
EventMove(MOVE_UP);
break;
case SCAN_CODE_DOWN:
EventMove(MOVE_DOWN);
break;
case SCAN_CODE_KEY_R:
EventMove(BTN_ROTATE_RIGHT);
break;
case SCAN_CODE_KEY_L:
EventMove(BTN_ROTATE_LEFT);
break;
} }
} }
@ -434,7 +459,7 @@ void DrawWindow()
DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph); DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, system.color.work_graph);
tx.n = 5-GAP; tx.n = 5-GAP;
DrawTopPanelButton(BTN_NEW, tx.inc(GAP), 2); //not implemented DrawTopPanelButton(BTN_NEW, tx.inc(GAP), 2);
DrawTopPanelButton(BTN_OPEN, tx.inc(GAP), 0); //not implemented DrawTopPanelButton(BTN_OPEN, tx.inc(GAP), 0); //not implemented
DrawTopPanelButton(BTN_SAVE, tx.inc(GAP), 5); DrawTopPanelButton(BTN_SAVE, tx.inc(GAP), 5);
DrawTopPanelButton(BTN_MOVE_LEFT, tx.inc(GAP+BLOCK_SPACE), 30); DrawTopPanelButton(BTN_MOVE_LEFT, tx.inc(GAP+BLOCK_SPACE), 30);
@ -444,12 +469,12 @@ void DrawWindow()
DrawTopPanelButton(BTN_FLIP_HOR, tx.inc(GAP+BLOCK_SPACE), 34); DrawTopPanelButton(BTN_FLIP_HOR, tx.inc(GAP+BLOCK_SPACE), 34);
DrawTopPanelButton(BTN_FLIP_VER, tx.inc(GAP), 35); DrawTopPanelButton(BTN_FLIP_VER, tx.inc(GAP), 35);
DrawTopPanelButton(BTN_ROTATE_LEFT, tx.inc(GAP), 37);
DrawTopPanelButton(BTN_ROTATE_RIGHT, tx.inc(GAP), 36);
DrawTopPanelButton(BTN_TEST_ICON, tx.inc(GAP+BLOCK_SPACE), 12); DrawTopPanelButton(BTN_TEST_ICON, tx.inc(GAP+BLOCK_SPACE), 12);
DrawTopPanelButton(BTN_CROP, tx.inc(GAP+BLOCK_SPACE), 46); DrawTopPanelButton(BTN_CROP, tx.inc(GAP+BLOCK_SPACE), 46);
// DrawTopPanelButton(BTN_ROTATE_LEFT, tx.inc(GAP), 36); //not implemented
// DrawTopPanelButton(BTN_ROTATE_RIGHT, tx.inc(GAP), 37); //not implemented
DrawEditArea(); DrawEditArea();
@ -566,21 +591,24 @@ void GenerateCurrentColorGradient()
} }
} }
int DrawGradientMarker(dword marker_x, marker_color)
{
if (marker_x > b_color_gradient.w - 1) marker_x = b_color_gradient.w - 1;
DrawBar(b_color_gradient.x + marker_x-2, b_color_gradient.y-3, 5, 1, marker_color);
DrawBar(b_color_gradient.x + marker_x-1, b_color_gradient.y-2, 3, 1, marker_color);
PutPixel(b_color_gradient.x + marker_x, b_color_gradient.y-1, marker_color);
return marker_x;
}
int old_marker_pos;
void DrawCurrentColorGradient() void DrawCurrentColorGradient()
{ {
int i; int i;
dword hitch_color=system.color.work;
int hitch_x = b_color_gradient.x+lmax-1;
if (lmax>b_color_gradient.w-2) hitch_x=b_color_gradient.x+b_color_gradient.w-3;
for (i=0 ; i<b_color_gradient.w; i++) { for (i=0 ; i<b_color_gradient.w; i++) {
DrawBar(b_color_gradient.x+i, b_color_gradient.y, 1, b_color_gradient.h, linear_gradient[i]); DrawBar(b_color_gradient.x+i, b_color_gradient.y, 1, b_color_gradient.h, linear_gradient[i]);
} }
//current color marker DrawGradientMarker(old_marker_pos, system.color.work);
DrawBar( b_color_gradient.x-1, b_color_gradient.y-2, b_color_gradient.w+4, 2, system.color.work); old_marker_pos = DrawGradientMarker(lmax, 0xFFFfff * bg_dark);
if (bg_dark) hitch_color=0xFFFfff; else hitch_color=0;
DrawBar(hitch_x, b_color_gradient.y-2, 3,2, hitch_color);
} }
void DrawColorPallets() void DrawColorPallets()
@ -639,9 +667,16 @@ void DrawCanvas()
void DrawPreview() void DrawPreview()
{ {
int x = right_bar.x; int x = right_bar.x;
int y = wrapper.y + wrapper.h - image.rows-2; int y = b_default_palette.y + b_default_palette.h + 6;
DrawRectangle(x, y, image.columns+1, image.rows+1, system.color.work_graph); int preview_h = Form.cheight - y;
_PutImage(x+1,y+1, image.columns, image.rows, image.get_image());
if (image.columns > right_bar.w) return;
if (image.rows > preview_h) return;
_PutImage(right_bar.w - image.columns / 2 + x - 3,
preview_h - image.rows / 2 + y,
image.columns, image.rows, image.get_image()
);
} }
dword GetPixelUnderMouse() dword GetPixelUnderMouse()

View File

@ -85,6 +85,7 @@ void initTools()
tools[TOOL_SCREEN_COPY].cursor = NULL; 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;
tools[TOOL_SCREEN_COPY].onKeyEvent = #ScreenCopy_onKeyEvent;
} }

View File

@ -27,10 +27,20 @@ void ScreenCopy_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
DrawCanvas(); DrawCanvas();
if (mouse.down) { if (mouse.down) {
ScreenCopy_onKeyEvent(SCAN_CODE_ENTER);
}
}
void ScreenCopy_onKeyEvent(dword keycode) {
if (SCAN_CODE_ENTER == keycode) {
actionsHistory.saveCurrentState();
screen_copy = free(screen_copy); screen_copy = free(screen_copy);
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
actionsHistory.saveCurrentState();
setCurrentTool(previousTool); setCurrentTool(previousTool);
if (!CheckActiveProcess(Form.ID)) ActivateWindow(GetProcessSlot(Form.ID)); if (!CheckActiveProcess(Form.ID)) ActivateWindow(GetProcessSlot(Form.ID));
} }
if (SCAN_CODE_ESC == keycode) {
ScreenCopy_onKeyEvent(SCAN_CODE_ENTER);
actionsHistory.undoLastAction();
}
} }

View File

@ -200,9 +200,18 @@ void SelectTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
} }
if (mouse.up) { if (mouse.up) {
selection.copy_to_buf(); selection.copy_to_buf();
} }
} }
/*
//forbid to select a single pixel
if (mouse.up) {
if (! selection.end_x-selection.start_x)
&& (! selection.end_y-selection.start_y) {
selection.reset();
}
}
*/
} }
void SelectTool_onKeyEvent(dword keycode) { void SelectTool_onKeyEvent(dword keycode) {

View File

@ -254,8 +254,8 @@ struct block {
}; };
:bool block::hovered() { :bool block::hovered() {
if ((mouse.x>x) && (mouse.y>y) if ((mouse.x>=x) && (mouse.y>=y)
&& (mouse.y<y+h) && (mouse.x<x+w)) && (mouse.y<=y+h) && (mouse.x<=x+w))
return true; return true;
return false; return false;
} }

View File

@ -116,6 +116,7 @@ dword NOTES::DrawLine(int line_n, draw_h) {
COL_BOTTOM_LINE=0xE8EFF4, COL_BOTTOM_LINE=0xE8EFF4,
COL_BG, COL_BG,
cur_text; cur_text;
int drawy;
char line_text[4096]; char line_text[4096];
if (line_n<0) return; if (line_n<0) return;
x = 1; x = 1;
@ -131,10 +132,12 @@ dword NOTES::DrawLine(int line_n, draw_h) {
} }
else else
{ {
DefineButton(RED_LINE_X-CHBOX/2+x, item_h*line_n+5+y, CHBOX-1,CHBOX-1, CHECKBOX_ID+line_n+BT_HIDE, 0); //checkbox drawy = item_h*line_n+5+y;
_PutImage(RED_LINE_X-CHBOX/2+x, item_h*line_n+5+y, CHBOX,CHBOX, lines[line_n].state*CHBOX*CHBOX*3+#checkbox); DefineButton(RED_LINE_X-CHBOX/2+x, drawy, CHBOX-1,CHBOX-1, CHECKBOX_ID+line_n+BT_HIDE, 0); //checkbox
if (cur_text) WriteText(x+RED_LINE_X+6, item_h*line_n+7+y, 0x80, lines[line_n].state*0x777777, cur_text); _PutImage(RED_LINE_X-CHBOX/2+x,drawy, CHBOX,CHBOX, lines[line_n].state*CHBOX*CHBOX*3+#checkbox);
if (lines[line_n].state == true) DrawBar(x+RED_LINE_X+6, item_h*line_n+11+y, strlen(cur_text)*6, 1, 0x444444); //strike if (cur_text) WriteText(x+RED_LINE_X+6, drawy+2, 0x80, lines[line_n].state*0x777777, cur_text);
if (lines[line_n].state == true) DrawBar(x+RED_LINE_X+6, drawy+6, strlen(cur_text)*6, 1, 0x444444); //strike
DrawBar(WIN_W,drawy,1,item_h,0xBBBBBB); //fast fix; proper fix is to restrict WriteText() char length
} }
DrawBar(x, line_n*item_h+draw_h-1+y, w, 1, COL_BOTTOM_LINE); DrawBar(x, line_n*item_h+draw_h-1+y, w, 1, COL_BOTTOM_LINE);
DrawBar(x+RED_LINE_X, line_n*item_h+y, 1, draw_h, COL_RED_LINE); DrawBar(x+RED_LINE_X, line_n*item_h+y, 1, draw_h, COL_RED_LINE);

View File

@ -1,4 +1,4 @@
// Notes v1.0 // Notes v1.1
#define MEMSIZE 0xDAE80 #define MEMSIZE 0xDAE80
#include "..\lib\kolibri.h" #include "..\lib\kolibri.h"
@ -47,6 +47,7 @@ edit_box notebox = {NULL,NULL,NULL,COL_BG_ACTIVE,0x94AECE,COL_BG_ACTIVE,0xffffff
dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 }; dword lists[] = { 0xEAEAEA, 0xCDCDCD, 0xF0F0F0, 0xD8D8D8, 0 };
bool delete_active = false; bool delete_active = false;
bool window_dragable = true;
block delBtn; block delBtn;
//===================================================// //===================================================//
@ -62,6 +63,8 @@ void main()
dword cur_line_offset; dword cur_line_offset;
load_dll(boxlib, #box_lib_init,0); load_dll(boxlib, #box_lib_init,0);
if (GetCpuFrequency()/1000000>=1000) window_dragable=true; else window_dragable=false;
if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt")); if (param) notes.OpenTxt(#param); else notes.OpenTxt(abspath("notes.txt"));
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
@ -75,7 +78,8 @@ void main()
if (delete_active) && (delBtn.hovered()) break; if (delete_active) && (delBtn.hovered()) break;
if (mouse.lkm) && (mouse.y<TITLE_H) && (mouse.x<WIN_W-39) EventDragWindow(); if (mouse.lkm) && (mouse.y<TITLE_H) && (mouse.x<WIN_W-39)
&& (window_dragable) EventDragWindow();
if (mouse.pkm) if (mouse.pkm)
&& (notes.MouseOver(mouse.x, mouse.y)) { && (notes.MouseOver(mouse.x, mouse.y)) {
@ -159,7 +163,10 @@ void DrawCloseButton(dword x,y,w,h)
void draw_window() void draw_window()
{ {
int i; int i;
DefineUnDragableWindow(100,100,WIN_W, WIN_H); if (window_dragable)
DefineUnDragableWindow(100,100,WIN_W, WIN_H);
else
DefineDragableWindow(100,100,WIN_W, WIN_H);
notes.SetSizes(RED_LINE_X+1, HEADER_HEIGHT, WIN_W-1, RED_LINE_X*LINES_COUNT, RED_LINE_X); notes.SetSizes(RED_LINE_X+1, HEADER_HEIGHT, WIN_W-1, RED_LINE_X*LINES_COUNT, RED_LINE_X);
DrawRectangle3D(0,0,WIN_W,TITLE_H-1,0xBB6535, 0xCD6F3B); DrawRectangle3D(0,0,WIN_W,TITLE_H-1,0xBB6535, 0xCD6F3B);
DrawRectangle3D(1,1,WIN_W-2,TITLE_H-3,0xEFBFA4, 0xDD8452); DrawRectangle3D(1,1,WIN_W-2,TITLE_H-3,0xEFBFA4, 0xDD8452);
@ -196,7 +203,7 @@ void DrawEditBoxN()
void EventActivateLine(int line_n) void EventActivateLine(int line_n)
{ {
if (line_n<0) || (line_n>notes.count) return; if (line_n<0) || (line_n>=notes.count) return;
notes.cur_y = line_n; notes.cur_y = line_n;
notebox.text = notes.DrawLine(notes.cur_y, notes.item_h); notebox.text = notes.DrawLine(notes.cur_y, notes.item_h);
EventListRedraw(); EventListRedraw();

View File

@ -1,9 +1,9 @@
[Window] [Window]
t=20 t=20
l=100 l=100
w=840 w=780
h=740 h=680
symbol_w=9 symbol_w=8
symbol_h=16 symbol_h=16
font_s=16 font_s=16
scroll_type=0 scroll_type=0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB