Brush container (unfinished). Temporarily bound to right-click 'Brush FX'. Only accepts monochrome brushes of any size at the moment.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@997 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
c957107d85
commit
29ee887c78
187
buttons.c
187
buttons.c
@ -51,6 +51,7 @@
|
|||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "brush.h"
|
#include "brush.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "special.h"
|
||||||
|
|
||||||
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
|
||||||
#include <proto/dos.h>
|
#include <proto/dos.h>
|
||||||
@ -5633,12 +5634,184 @@ void Button_Text()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Display_stored_brush_in_window(word x_pos,word y_pos,int index)
|
||||||
|
{
|
||||||
|
if (Brush_container[index].Paintbrush_shape <= PAINTBRUSH_SHAPE_MISC)
|
||||||
|
{
|
||||||
|
int x,y;
|
||||||
|
int offset_x=0, offset_y=0;
|
||||||
|
//int brush_offset_x=0, brush_offset_y=0;
|
||||||
|
|
||||||
|
// Determine draw offset (small brushes are stacked on corner of their preview)
|
||||||
|
if (Brush_container[index].Width<BRUSH_CONTAINER_PREVIEW_WIDTH)
|
||||||
|
offset_x = (BRUSH_CONTAINER_PREVIEW_WIDTH-Brush_container[index].Width)/2;
|
||||||
|
if (Brush_container[index].Height<BRUSH_CONTAINER_PREVIEW_HEIGHT)
|
||||||
|
offset_y = (BRUSH_CONTAINER_PREVIEW_HEIGHT-Brush_container[index].Height)/2;
|
||||||
|
// Determine corner pixel of paintbrush to draw (if bigger than preview area)
|
||||||
|
//
|
||||||
|
|
||||||
|
// Clear
|
||||||
|
Window_rectangle(x_pos,y_pos,BRUSH_CONTAINER_PREVIEW_WIDTH,BRUSH_CONTAINER_PREVIEW_HEIGHT,MC_Light);
|
||||||
|
|
||||||
|
// Draw up to 16x16
|
||||||
|
for (y=0; y<Brush_container[index].Height && y<BRUSH_CONTAINER_PREVIEW_HEIGHT; y++)
|
||||||
|
for (x=0; x<Brush_container[index].Width && x<BRUSH_CONTAINER_PREVIEW_WIDTH; x++)
|
||||||
|
Pixel_in_window(x_pos+x+offset_x,y_pos+y+offset_y,Brush_container[index].Thumbnail[y][x]?MC_Black:MC_Light);
|
||||||
|
Update_window_area(x_pos,y_pos,BRUSH_CONTAINER_PREVIEW_WIDTH,BRUSH_CONTAINER_PREVIEW_HEIGHT);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (Brush_container[index].Paintbrush_shape == PAINTBRUSH_SHAPE_COLOR_BRUSH)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Store_brush(int index)
|
||||||
|
{
|
||||||
|
if (Brush_container[index].Paintbrush_shape < PAINTBRUSH_SHAPE_MAX)
|
||||||
|
{
|
||||||
|
// Free previous stored brush
|
||||||
|
Brush_container[index].Paintbrush_shape = PAINTBRUSH_SHAPE_MAX;
|
||||||
|
free(Brush_container[index].Brush);
|
||||||
|
Brush_container[index].Brush = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// Store a mono brush
|
||||||
BUTTON_GRADRECT
|
if (Paintbrush_shape <= PAINTBRUSH_SHAPE_MISC)
|
||||||
-BUTTON_SPHERES (Ellipses dégradées à améliorer)
|
{
|
||||||
BUTTON_TEXT
|
int x,y;
|
||||||
-BUTTON_ADJUST (Effets sur l'image)
|
int brush_offset_x=0, brush_offset_y=0;
|
||||||
-BUTTON_BRUSH_EFFECTS (Distort, Rot. any angle)
|
|
||||||
*/
|
Brush_container[index].Paintbrush_shape=Paintbrush_shape;
|
||||||
|
Brush_container[index].Width=Paintbrush_width;
|
||||||
|
Brush_container[index].Height=Paintbrush_height;
|
||||||
|
memcpy(Brush_container[index].Palette,Main_palette,sizeof(T_Palette));
|
||||||
|
// Preview: pick center for big mono brush
|
||||||
|
if (Paintbrush_width>BRUSH_CONTAINER_PREVIEW_WIDTH)
|
||||||
|
brush_offset_x = (Paintbrush_width-BRUSH_CONTAINER_PREVIEW_WIDTH)/2;
|
||||||
|
if (Paintbrush_height>BRUSH_CONTAINER_PREVIEW_HEIGHT)
|
||||||
|
brush_offset_y = (Paintbrush_height-BRUSH_CONTAINER_PREVIEW_HEIGHT)/2;
|
||||||
|
|
||||||
|
for (y=0; y<BRUSH_CONTAINER_PREVIEW_HEIGHT && y<Paintbrush_height; y++)
|
||||||
|
for (x=0; x<BRUSH_CONTAINER_PREVIEW_WIDTH && x<Paintbrush_width; x++)
|
||||||
|
Brush_container[index].Thumbnail[y][x]=Paintbrush_sprite[((y+brush_offset_y)*MAX_PAINTBRUSH_SIZE)+x+brush_offset_x];
|
||||||
|
// Re-init the rest
|
||||||
|
Brush_container[index].Transp_color=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
byte Restore_brush(int index)
|
||||||
|
{
|
||||||
|
byte shape;
|
||||||
|
word x_pos;
|
||||||
|
word y_pos;
|
||||||
|
|
||||||
|
shape = Brush_container[index].Paintbrush_shape;
|
||||||
|
|
||||||
|
if (shape == PAINTBRUSH_SHAPE_MAX)
|
||||||
|
return 0;
|
||||||
|
// Mono brushes
|
||||||
|
if (shape <= PAINTBRUSH_SHAPE_MISC)
|
||||||
|
{
|
||||||
|
Paintbrush_shape=shape;
|
||||||
|
Paintbrush_width=Brush_container[index].Width;
|
||||||
|
Paintbrush_height=Brush_container[index].Height;
|
||||||
|
if (shape == PAINTBRUSH_SHAPE_HORIZONTAL_BAR)
|
||||||
|
Paintbrush_height=1;
|
||||||
|
else if (shape == PAINTBRUSH_SHAPE_VERTICAL_BAR)
|
||||||
|
Paintbrush_width=1;
|
||||||
|
|
||||||
|
if (Paintbrush_width <= BRUSH_CONTAINER_PREVIEW_WIDTH &&
|
||||||
|
Paintbrush_height <= BRUSH_CONTAINER_PREVIEW_HEIGHT)
|
||||||
|
{
|
||||||
|
// Manually copy the "pixels"
|
||||||
|
for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
|
||||||
|
for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
|
||||||
|
Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Brush_container[index].Thumbnail[y_pos][x_pos];
|
||||||
|
|
||||||
|
Paintbrush_offset_X=Paintbrush_width>>1;
|
||||||
|
Paintbrush_offset_Y=Paintbrush_height>>1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Recreate the brush pixels from its shape and dimensions
|
||||||
|
Set_paintbrush_size(Paintbrush_width,Paintbrush_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Change_paintbrush_shape(shape);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button_Brush_container(void)
|
||||||
|
{
|
||||||
|
short clicked_button;
|
||||||
|
short x_pos,y_pos;
|
||||||
|
byte index;
|
||||||
|
|
||||||
|
Open_window(BRUSH_CONTAINER_COLUMNS*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+8,
|
||||||
|
BRUSH_CONTAINER_ROWS*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+40,
|
||||||
|
"Brushes");
|
||||||
|
|
||||||
|
Window_set_normal_button(
|
||||||
|
(BRUSH_CONTAINER_COLUMNS*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)-59)/2,
|
||||||
|
(BRUSH_CONTAINER_ROWS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18,
|
||||||
|
67,14,"Cancel",0,1,KEY_ESC); // 1
|
||||||
|
|
||||||
|
index=0;
|
||||||
|
for (index=0; index < BRUSH_CONTAINER_ROWS*BRUSH_CONTAINER_COLUMNS; index++)
|
||||||
|
{
|
||||||
|
x_pos = (index % BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+7;
|
||||||
|
y_pos = (index / BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18;
|
||||||
|
Window_set_normal_button(
|
||||||
|
x_pos,
|
||||||
|
y_pos,
|
||||||
|
BRUSH_CONTAINER_PREVIEW_WIDTH+2,
|
||||||
|
BRUSH_CONTAINER_PREVIEW_HEIGHT+2,
|
||||||
|
"",0,1,SDLK_LAST);
|
||||||
|
Display_stored_brush_in_window(x_pos+1, y_pos+1, index);
|
||||||
|
}
|
||||||
|
Update_window_area(0,0,Window_width, Window_height);
|
||||||
|
|
||||||
|
Display_cursor();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
clicked_button=Window_clicked_button();
|
||||||
|
//if (Is_shortcut(Key,0x100+BUTTON_HELP))
|
||||||
|
// Window_help(BUTTON_PAINTBRUSHES, NULL);
|
||||||
|
|
||||||
|
if (clicked_button == 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (clicked_button>1)
|
||||||
|
{
|
||||||
|
index = clicked_button-2;
|
||||||
|
|
||||||
|
if (Window_attribute1==RIGHT_SIDE)
|
||||||
|
{
|
||||||
|
// Store
|
||||||
|
|
||||||
|
x_pos = (index % BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_WIDTH+8)+7;
|
||||||
|
y_pos = (index / BRUSH_CONTAINER_COLUMNS)*(BRUSH_CONTAINER_PREVIEW_HEIGHT+8)+18;
|
||||||
|
|
||||||
|
Store_brush(index);
|
||||||
|
Hide_cursor();
|
||||||
|
Display_stored_brush_in_window(x_pos+1, y_pos+1, index);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Restore and exit
|
||||||
|
|
||||||
|
if (Restore_brush(index))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (1);
|
||||||
|
Close_window();
|
||||||
|
|
||||||
|
//Unselect_button(BUTTON_PAINTBRUSHES);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
@ -651,5 +651,7 @@ void Button_Smooth_menu(void);
|
|||||||
*/
|
*/
|
||||||
void Button_Smear_mode(void);
|
void Button_Smear_mode(void);
|
||||||
|
|
||||||
|
void Button_Brush_container(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
8
const.h
8
const.h
@ -65,6 +65,11 @@
|
|||||||
/// Character to display in menus for an ellipsis.
|
/// Character to display in menus for an ellipsis.
|
||||||
#define ELLIPSIS_CHARACTER '…'
|
#define ELLIPSIS_CHARACTER '…'
|
||||||
|
|
||||||
|
#define BRUSH_CONTAINER_PREVIEW_WIDTH 16 ///< Size for preview of a brush in Brush container
|
||||||
|
#define BRUSH_CONTAINER_PREVIEW_HEIGHT 16 ///< Size for preview of a brush in Brush container
|
||||||
|
#define BRUSH_CONTAINER_COLUMNS 4 ///< Number of columns in the Brush container
|
||||||
|
#define BRUSH_CONTAINER_ROWS 3 ///< Number of rows in the Brush container
|
||||||
|
|
||||||
///
|
///
|
||||||
/// We force the dynamic backup page allocation to leave a minimum of
|
/// We force the dynamic backup page allocation to leave a minimum of
|
||||||
/// 256Kb of free memory, to allow the rest of the program to work safely.
|
/// 256Kb of free memory, to allow the rest of the program to work safely.
|
||||||
@ -210,7 +215,8 @@ enum PAINTBRUSH_SHAPES
|
|||||||
PAINTBRUSH_SHAPE_MISC, ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types.
|
PAINTBRUSH_SHAPE_MISC, ///< A raw monochrome bitmap, can't be resized. This must be the last of the preset paintbrush types.
|
||||||
PAINTBRUSH_SHAPE_POINT, ///< Used to reduce the paintbrush to a single pixel, during operations like colorpicker.
|
PAINTBRUSH_SHAPE_POINT, ///< Used to reduce the paintbrush to a single pixel, during operations like colorpicker.
|
||||||
PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode
|
PAINTBRUSH_SHAPE_COLOR_BRUSH, ///< User's brush, in color mode
|
||||||
PAINTBRUSH_SHAPE_MONO_BRUSH ///< User's brush, in mono mode
|
PAINTBRUSH_SHAPE_MONO_BRUSH, ///< User's brush, in mono mode
|
||||||
|
PAINTBRUSH_SHAPE_MAX ///< Upper limit.
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Normal resting state for a menu button.
|
/// Normal resting state for a menu button.
|
||||||
|
|||||||
2
global.h
2
global.h
@ -830,6 +830,8 @@ GFX2_GLOBAL short Colorpicker_X;
|
|||||||
/// Position of the colorpicker tool, in image coordinates.
|
/// Position of the colorpicker tool, in image coordinates.
|
||||||
GFX2_GLOBAL short Colorpicker_Y;
|
GFX2_GLOBAL short Colorpicker_Y;
|
||||||
|
|
||||||
|
/// Brush container
|
||||||
|
GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTAINER_ROWS];
|
||||||
|
|
||||||
#ifdef GLOBAL_VARIABLES
|
#ifdef GLOBAL_VARIABLES
|
||||||
byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
|
byte CURSOR_FOR_OPERATION[NB_OPERATIONS]=
|
||||||
|
|||||||
22
init.c
22
init.c
@ -1063,7 +1063,7 @@ void Init_buttons(void)
|
|||||||
106,18,
|
106,18,
|
||||||
16,16,
|
16,16,
|
||||||
BUTTON_SHAPE_RECTANGLE,
|
BUTTON_SHAPE_RECTANGLE,
|
||||||
Button_Brush_FX,Button_Brush_FX,
|
Button_Brush_FX,Button_Brush_container,
|
||||||
Do_nothing,
|
Do_nothing,
|
||||||
FAMILY_INSTANT);
|
FAMILY_INSTANT);
|
||||||
|
|
||||||
@ -2446,3 +2446,23 @@ void Init_sighandler(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Init_brush_container(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<BRUSH_CONTAINER_COLUMNS*BRUSH_CONTAINER_ROWS; i++)
|
||||||
|
{
|
||||||
|
int x,y;
|
||||||
|
|
||||||
|
Brush_container[i].Paintbrush_shape=PAINTBRUSH_SHAPE_MAX;
|
||||||
|
Brush_container[i].Width=0;
|
||||||
|
Brush_container[i].Height=0;
|
||||||
|
memset(Brush_container[i].Palette,sizeof(T_Palette),0);
|
||||||
|
Brush_container[i].Transp_color=0;
|
||||||
|
for (y=0; y<BRUSH_CONTAINER_PREVIEW_WIDTH; y++)
|
||||||
|
for (x=0; x<BRUSH_CONTAINER_PREVIEW_HEIGHT; x++)
|
||||||
|
Brush_container[i].Thumbnail[y][x]=0;
|
||||||
|
|
||||||
|
Brush_container[i].Brush = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
init.h
1
init.h
@ -25,6 +25,7 @@
|
|||||||
T_Gui_skin *Load_graphics(const char * skin_file);
|
T_Gui_skin *Load_graphics(const char * skin_file);
|
||||||
void Init_buttons(void);
|
void Init_buttons(void);
|
||||||
void Init_operations(void);
|
void Init_operations(void);
|
||||||
|
void Init_brush_container(void);
|
||||||
int Load_CFG(int reload_all);
|
int Load_CFG(int reload_all);
|
||||||
int Save_CFG(void);
|
int Save_CFG(void);
|
||||||
void Set_all_video_modes(void);
|
void Set_all_video_modes(void);
|
||||||
|
|||||||
3
main.c
3
main.c
@ -513,6 +513,9 @@ int Init_program(int argc,char * argv[])
|
|||||||
// Initialisation des opérations
|
// Initialisation des opérations
|
||||||
Init_operations();
|
Init_operations();
|
||||||
|
|
||||||
|
// Initialize the brush container
|
||||||
|
Init_brush_container();
|
||||||
|
|
||||||
Windows_open=0;
|
Windows_open=0;
|
||||||
|
|
||||||
// Charger la configuration des touches
|
// Charger la configuration des touches
|
||||||
|
|||||||
@ -42,3 +42,7 @@ void Scroll_magnifier(short delta_x,short delta_y);
|
|||||||
|
|
||||||
void Zoom(short delta);
|
void Zoom(short delta);
|
||||||
void Zoom_set(int index);
|
void Zoom_set(int index);
|
||||||
|
|
||||||
|
void Display_stored_brush_in_window(word x,word y,int number);
|
||||||
|
void Store_brush(int index);
|
||||||
|
byte Restore_brush(int index);
|
||||||
19
struct.h
19
struct.h
@ -336,11 +336,24 @@ typedef struct
|
|||||||
/// Collection of undo/redo steps.
|
/// Collection of undo/redo steps.
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int List_size; /// Number of ::T_Page in the vector "Pages".
|
int List_size; ///< Number of ::T_Page in the vector "Pages".
|
||||||
int Nb_pages_allocated;/// Number of ::T_Page used so far in the vector "Pages".
|
int Nb_pages_allocated;///< Number of ::T_Page used so far in the vector "Pages".
|
||||||
T_Page * Pages; /// Vector of Pages, each one being a undo/redo step.
|
T_Page * Pages; ///< Vector of Pages, each one being a undo/redo step.
|
||||||
} T_List_of_pages;
|
} T_List_of_pages;
|
||||||
|
|
||||||
|
/// A single memorized brush from the Brush Container
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
byte Paintbrush_shape; ///< Kind of brush
|
||||||
|
byte Thumbnail[BRUSH_CONTAINER_PREVIEW_WIDTH][BRUSH_CONTAINER_PREVIEW_HEIGHT];
|
||||||
|
// Data for color brush
|
||||||
|
word Width;
|
||||||
|
word Height;
|
||||||
|
byte * Brush; /// < Color brush (if any)
|
||||||
|
T_Palette Palette;
|
||||||
|
byte Transp_color;
|
||||||
|
} T_Brush_template;
|
||||||
|
|
||||||
|
|
||||||
/// GUI skin data
|
/// GUI skin data
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user