Backgen 0.6
git-svn-id: svn://kolibrios.org@7096 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
96565ecfba
commit
3752a68975
@ -4,10 +4,12 @@
|
||||
* Licence: GPL v2
|
||||
*/
|
||||
|
||||
#define MEMSIZE 4096*10
|
||||
#define MEMSIZE 4096*40
|
||||
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/obj/libimg.h"
|
||||
#include "../lib/patterns/rgb.h"
|
||||
#include "../lib/patterns/libimg_load_skin.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
@ -15,23 +17,46 @@
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
#define T_TITLE "Background generator 0.6"
|
||||
|
||||
#define MAX_COLORS 10
|
||||
#define TOOLBAR_H 24+8
|
||||
#define PALLETE_SIZE 116
|
||||
|
||||
more_less_box x_count = { 10, 220, NULL, 1, MAX_COLORS, 22, 23, "X count" };
|
||||
more_less_box y_count = { 10, 250, NULL, 1, MAX_COLORS, 24, 25, "Y count" };
|
||||
more_less_box x_count = { 10, TOOLBAR_H+220, NULL, 1, MAX_COLORS, 22, 23, "X count" };
|
||||
more_less_box y_count = { 10, TOOLBAR_H+250, NULL, 1, MAX_COLORS, 24, 25, "Y count" };
|
||||
|
||||
rect preview = { 10, 10, 200, 200 };
|
||||
rect right_bar = { 230, 10, 280, 400 };
|
||||
rect preview = { 10, TOOLBAR_H+10, 200, 200 };
|
||||
rect right_bar = { 230, TOOLBAR_H+10, 280, 320 };
|
||||
|
||||
dword active_color = 0xFFFfff;
|
||||
char active_color_string[11]="0x00111222\0";
|
||||
|
||||
enum {
|
||||
APPLY_BACKGROUND_BTN = 10
|
||||
BTN_APPLY_BACKGROUND = 10,
|
||||
|
||||
BTN_NEW = 40,
|
||||
BTN_OPEN,
|
||||
BTN_SAVE,
|
||||
BTN_MOVE_LEFT,
|
||||
BTN_MOVE_RIGHT,
|
||||
BTN_MOVE_UP,
|
||||
BTN_MOVE_DOWN,
|
||||
BTN_FLIP_HOR,
|
||||
BTN_FLIP_VER,
|
||||
BTN_ROTATE_LEFT,
|
||||
BTN_ROTATE_RIGHT,
|
||||
|
||||
BTN_PICK,
|
||||
|
||||
BTN_PALETTE_COLOR_MAS = 100,
|
||||
|
||||
};
|
||||
|
||||
proc_info Form;
|
||||
|
||||
bool pick_active = false;
|
||||
|
||||
dword default_colors[] = {
|
||||
0x330000,0x331900,0x333300,0x193300,0x003300,0x003319,0x003333,0x001933,0x000033,0x190033,0x330033,0x330019,0x000000,
|
||||
0x660000,0x663300,0x666600,0x336600,0x006600,0x006633,0x006666,0x003366,0x000066,0x330066,0x660066,0x660033,0x202020,
|
||||
@ -56,23 +81,46 @@ void main()
|
||||
{
|
||||
word btn;
|
||||
|
||||
load_dll(libio, #libio_init, 1);
|
||||
load_dll(libimg, #libimg_init, 1);
|
||||
Libimg_LoadImage(#skin, "/sys/icons16.png");
|
||||
|
||||
colors.set_default_values();
|
||||
x_count.value = colors.columns;
|
||||
y_count.value = colors.rows;
|
||||
|
||||
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
||||
|
||||
loop() switch(WaitEvent())
|
||||
{
|
||||
case evMouse:
|
||||
mouse.get();
|
||||
if (pick_active) EventPickColor();
|
||||
|
||||
case evButton:
|
||||
btn = GetButtonID();
|
||||
if (btn == CLOSE_BTN) ExitProcess();
|
||||
if (btn == APPLY_BACKGROUND_BTN) {
|
||||
SetBackgroundImage(colors.columns, colors.rows, colors.get_image(), DRAW_DESKTOP_BG_STRETCH);
|
||||
}
|
||||
btn = GetButtonID();
|
||||
if (x_count.click(btn)) EventChangeFieldSize();
|
||||
if (y_count.click(btn)) EventChangeFieldSize();
|
||||
if (btn >= 100) && (btn < 228)
|
||||
switch(btn)
|
||||
{
|
||||
case BTN_MOVE_LEFT:
|
||||
colors.move(DIRECTION_LEFT);
|
||||
break;
|
||||
case BTN_MOVE_RIGHT:
|
||||
colors.move(DIRECTION_RIGHT);
|
||||
break;
|
||||
case CLOSE_BTN:
|
||||
ExitProcess();
|
||||
case BTN_APPLY_BACKGROUND:
|
||||
EventApplyBackground();
|
||||
break;
|
||||
case BTN_PICK:
|
||||
EventPickActivate();
|
||||
break;
|
||||
}
|
||||
if (btn >= BTN_PALETTE_COLOR_MAS) && (btn < BTN_PALETTE_COLOR_MAS+PALLETE_SIZE)
|
||||
{
|
||||
active_color = default_colors[btn-100];
|
||||
active_color = default_colors[btn-BTN_PALETTE_COLOR_MAS];
|
||||
DrawActiveColor(NULL);
|
||||
}
|
||||
if (btn >= 300) && (btn < 401)
|
||||
@ -87,6 +135,8 @@ void main()
|
||||
case evKey:
|
||||
GetKeys();
|
||||
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
|
||||
if (key_scancode == SCAN_CODE_ENTER) EventApplyBackground();
|
||||
if (key_scancode == SCAN_CODE_KEY_I) EventPickActivate();
|
||||
break;
|
||||
|
||||
case evReDraw:
|
||||
@ -95,28 +145,54 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
void DrawToolbarButton(dword _id, _x, _icon_n)
|
||||
{
|
||||
DrawWideRectangle(_x, 4, 24, 24, 4, 0xFFFfff);
|
||||
DefineHiddenButton(_x, 4, 23, 23, _id);
|
||||
img_draw stdcall(skin.image, _x+4, 8, 16, 16, 0, _icon_n*16);
|
||||
}
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
#define TB_ICON_PADDING 26
|
||||
incn tx;
|
||||
system.color.get();
|
||||
DefineAndDrawWindow(215, 100, right_bar.x+right_bar.w+9,
|
||||
right_bar.y+right_bar.h+skin_height+5,
|
||||
0x34, system.color.work, "Background generator",0
|
||||
0x34, system.color.work, T_TITLE,0
|
||||
);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
|
||||
tx.n = preview.x - TB_ICON_PADDING;
|
||||
// DrawToolbarButton(BTN_NEW, tx.inc(TB_ICON_PADDING), 2);
|
||||
// DrawToolbarButton(BTN_OPEN, tx.inc(TB_ICON_PADDING), 0);
|
||||
// DrawToolbarButton(BTN_SAVE, tx.inc(TB_ICON_PADDING), 5);
|
||||
DrawToolbarButton(BTN_MOVE_LEFT, tx.inc(TB_ICON_PADDING), 30);
|
||||
DrawToolbarButton(BTN_MOVE_RIGHT, tx.inc(TB_ICON_PADDING), 31);
|
||||
// DrawToolbarButton(BTN_MOVE_UP, tx.inc(TB_ICON_PADDING), 32);
|
||||
// DrawToolbarButton(BTN_MOVE_DOWN, tx.inc(TB_ICON_PADDING), 33);
|
||||
// DrawToolbarButton(BTN_FLIP_HOR, tx.inc(TB_ICON_PADDING+8), 34);
|
||||
// DrawToolbarButton(BTN_FLIP_VER, tx.inc(TB_ICON_PADDING), 35);
|
||||
// DrawToolbarButton(BTN_ROTATE_LEFT, tx.inc(TB_ICON_PADDING), 36);
|
||||
// DrawToolbarButton(BTN_ROTATE_RIGHT, tx.inc(TB_ICON_PADDING), 37);
|
||||
|
||||
DrawBar(0, TOOLBAR_H-1, Form.cwidth, 1, system.color.work_dark);
|
||||
DrawBar(0, TOOLBAR_H, Form.cwidth, 1, system.color.work_light);
|
||||
|
||||
x_count.draw();
|
||||
y_count.draw();
|
||||
|
||||
DrawColorsField();
|
||||
|
||||
DrawStandartCaptButton(10, 320, APPLY_BACKGROUND_BTN, "Fill background");
|
||||
DrawStandartCaptButton(preview.x, 320, BTN_APPLY_BACKGROUND, "Fill background");
|
||||
DrawStandartCaptButton(right_bar.x + 150, right_bar.y, BTN_PICK, "Pipette");
|
||||
|
||||
DrawRightBar();
|
||||
}
|
||||
|
||||
void DrawColorsField()
|
||||
{
|
||||
DrawRectangle(preview.x, preview.y, preview.w, preview.h, 0x808080);
|
||||
DrawRectangle(preview.x, preview.y, preview.w, preview.h, system.color.work_graph); //0x808080);
|
||||
DrawBar(preview.x+1, preview.y+1, preview.w-1, preview.h-1, 0xBFCAD2); //F3F3F3
|
||||
|
||||
colors.x = -colors.cell_size*colors.columns+preview.w/2 + preview.x;
|
||||
@ -132,7 +208,7 @@ void DrawRightBar()
|
||||
EDI = system.color.work;
|
||||
WriteTextB(right_bar.x, y.inc(3), 0x90, system.color.work_text, "Active color");
|
||||
DrawActiveColor(y.inc(22));
|
||||
WriteTextB(right_bar.x, y.inc(34), 0x90, system.color.work_text, "Default colors");
|
||||
WriteTextB(right_bar.x, y.inc(34), 0x90, system.color.work_text, "Palette");
|
||||
DrawDefaultColors(right_bar.x, y.inc(22));
|
||||
}
|
||||
|
||||
@ -154,11 +230,14 @@ void DrawDefaultColors(dword _x, _y)
|
||||
{
|
||||
for (c = 0; c < 13; c++)
|
||||
{
|
||||
colors.draw_cell(c*colors.cell_size + _x, r*colors.cell_size + _y, default_colors[i]);
|
||||
DefineHiddenButton(c*colors.cell_size + _x, r*colors.cell_size + _y, colors.cell_size, colors.cell_size, 100+i);
|
||||
colors.draw_cell(c*colors.cell_size + _x, r*colors.cell_size + _y, default_colors[PALLETE_SIZE-i]);
|
||||
DefineHiddenButton(c*colors.cell_size + _x, r*colors.cell_size + _y,
|
||||
colors.cell_size-1, colors.cell_size-1, BTN_PALETTE_COLOR_MAS+PALLETE_SIZE-i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
DrawRectangle(_x-1, _y-1, c*colors.cell_size+1, r*colors.cell_size+1, system.color.work_light);
|
||||
DrawRectangle(_x-2, _y-2, c*colors.cell_size+3, r*colors.cell_size+3, system.color.work_dark);
|
||||
}
|
||||
|
||||
|
||||
@ -174,3 +253,24 @@ void EventChangeFieldSize()
|
||||
colors.rows = y_count.value;
|
||||
DrawColorsField();
|
||||
}
|
||||
|
||||
void EventPickActivate()
|
||||
{
|
||||
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE);
|
||||
pick_active = true;
|
||||
}
|
||||
|
||||
void EventPickColor()
|
||||
{
|
||||
active_color = GetPixelColorFromScreen(mouse.x + Form.left, mouse.y + Form.top);
|
||||
DrawActiveColor(NULL);
|
||||
if (mouse.down) && (mouse.key&MOUSE_LEFT) {
|
||||
pick_active = false;
|
||||
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
||||
}
|
||||
}
|
||||
|
||||
void EventApplyBackground()
|
||||
{
|
||||
SetBackgroundImage(colors.columns, colors.rows, colors.get_image(), DRAW_DESKTOP_BG_STRETCH);
|
||||
}
|
@ -11,6 +11,7 @@ struct _colors
|
||||
dword get_image();
|
||||
void draw_cell();
|
||||
void draw_all_cells();
|
||||
void move();
|
||||
} colors;
|
||||
|
||||
void _colors::set_default_values()
|
||||
@ -28,8 +29,6 @@ void _colors::set_default_values()
|
||||
|
||||
void _colors::set_color(int _r, _c, _color)
|
||||
{
|
||||
debugval("_r", _r);
|
||||
debugval("_c", _c);
|
||||
mas[MAX_COLORS*_r + _c] = _color;
|
||||
}
|
||||
|
||||
@ -62,8 +61,9 @@ dword _colors::get_image()
|
||||
|
||||
void _colors::draw_cell(int _x, _y, _color)
|
||||
{
|
||||
DrawRectangle(_x, _y, cell_size, cell_size, 0xA7B2BA);
|
||||
DrawBar(_x+1, _y+1, cell_size-1, cell_size-1, _color);
|
||||
//DrawRectangle(_x, _y, cell_size, cell_size, system.color.work_graph);
|
||||
//DrawBar(_x+1, _y+1, cell_size-1, cell_size-1, _color);
|
||||
DrawBar(_x, _y, cell_size, cell_size, _color);
|
||||
}
|
||||
|
||||
void _colors::draw_all_cells()
|
||||
@ -75,8 +75,40 @@ void _colors::draw_all_cells()
|
||||
for (c = 0; c < columns; c++)
|
||||
{
|
||||
draw_cell(c*cell_size + x, r*cell_size + y, get_color(r, c));
|
||||
DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300);
|
||||
DefineHiddenButton(c*cell_size + x, r*cell_size + y, cell_size, cell_size, r*columns+c+300+BT_NOFRAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
DIRECTION_LEFT,
|
||||
DIRECTION_RIGHT,
|
||||
DIRECTION_UP,
|
||||
DIRECTION_DOWN
|
||||
};
|
||||
void _colors::move(int direction)
|
||||
{
|
||||
int r, c;
|
||||
dword first_element_data;
|
||||
|
||||
if (direction == DIRECTION_LEFT)
|
||||
{
|
||||
for (r = 0; r < rows; r++)
|
||||
{
|
||||
first_element_data = get_color(r, 0);
|
||||
for (c = 0; c < columns-1; c++) set_color(r, c, get_color(r, c+1));
|
||||
set_color(r, columns-1, first_element_data);
|
||||
}
|
||||
}
|
||||
if (direction == DIRECTION_RIGHT)
|
||||
{
|
||||
for (r = 0; r < rows; r++)
|
||||
{
|
||||
first_element_data = get_color(r, columns-1);
|
||||
for (c = columns-1; c > 0; c--) set_color(r, c, get_color(r, c-1));
|
||||
set_color(r, 0, first_element_data);
|
||||
}
|
||||
}
|
||||
|
||||
draw_all_cells();
|
||||
}
|
||||
|
@ -36,40 +36,14 @@ void IconFairing(dword filenum, x,y, color)
|
||||
{
|
||||
case 0: //folder
|
||||
case 22: //<up>
|
||||
DrawBar(x+7,y,8,2,color);
|
||||
IF (filenum==22) PutPixel(x+10,y+1,0x1A7B17); //green arrow part
|
||||
DrawBar(x,y+13,15,2,color);
|
||||
PutPixel(x,y,color);
|
||||
PutPixel(x+6,y,color);
|
||||
PutPixel(x+14,y+2,color);
|
||||
PutPixel(x,y+12,color);
|
||||
PutPixel(x+14,y+12,color);
|
||||
return;
|
||||
case 13: //html
|
||||
DrawBar(x,y,1,7,color);
|
||||
DrawBar(x+1,y,1,6,color);
|
||||
DrawBar(x,y+10,1,5,color);
|
||||
DrawBar(x+1,y+11,1,4,color);
|
||||
return;
|
||||
case 12: //font
|
||||
DrawBar(x+1,y+1,1,13,color);
|
||||
DrawBar(x+2,y+1,1,11,color);
|
||||
DrawBar(x+3,y+1,1,10,color);
|
||||
DrawBar(x+4,y+1,1,9,color);
|
||||
DrawBar(x+5,y+1,1,7,color);
|
||||
DrawBar(x+6,y+1,1,5,color);
|
||||
DrawBar(x+7,y+1,1,4,color);
|
||||
DrawBar(x+8,y+1,1,2,color);
|
||||
DrawBar(x+14,y+1,1,13,color);
|
||||
DrawBar(x+13,y+1,1,11,color);
|
||||
PutPixel(x+9,y+6,color);
|
||||
DrawBar(x+8,y+10,2,1,color);
|
||||
DrawBar(x+7,y+11,2,3,color);
|
||||
return;
|
||||
case 23: //nes
|
||||
DrawBar(x,y+11,1,2,color);
|
||||
DrawBar(x+15,y+11,1,2,color);
|
||||
DrawBar(x,y+13,16,1,color);
|
||||
DrawBar(x+7,y+1,8,2,color);
|
||||
IF (filenum==22) PutPixel(x+10,y+2,0x1A7B17); //green arrow part
|
||||
DrawBar(x,y+14,15,2,color);
|
||||
PutPixel(x,y+1,color);
|
||||
PutPixel(x+6,y+1,color);
|
||||
PutPixel(x+14,y+3,color);
|
||||
PutPixel(x,y+13,color);
|
||||
PutPixel(x+14,y+13,color);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#define SCAN_CODE_KEY_C 046
|
||||
#define SCAN_CODE_KEY_M 050
|
||||
#define SCAN_CODE_KEY_I 023
|
||||
#define SCAN_CODE_KEY_O 024
|
||||
#define SCAN_CODE_KEY_P 025
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user