WIP: Shape controls -- center vs corner

Adding control buttons to the Shapes tool, allowing for shapes
to be drawn from the center (as before) or from a corner
(more like other paint packages).  The controls do nothing
at this time, but are visible and can be clicked.  This is a
work in progress.

The controls may be removed using a configuration option.
This commit is contained in:
Bill Kendrick 2020-08-15 00:55:31 -07:00
parent d5b020520d
commit 2159f8616b
12 changed files with 168 additions and 48 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -27,6 +27,13 @@ $Id$
* The "--exportdir" option can be used to override the default
location (but a "TuxPaint" subdir. will NOT be placed there).
* Shape controls: -- WORK IN PROGRESS
* Draw shapes from the center (as in previous versions of Tux Paint)
or from a corner (similar to the default mode of most other
graphics tools).
* The controls to modify the drawing behavior can be removed,
for simplification of Tux Paint's interface (for younger users).
* Ports & Building
----------------
* Corrections for Haiku not opening saved files.

View file

@ -6,7 +6,7 @@ Options Documentation
Copyright (c) 2002-2020 by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/
July 27, 2020
August 14, 2020
----------------------------------------------------------------------
@ -358,6 +358,12 @@ Windows Users
controls, and only provides the default functionality (usually
paint-mode).
noshapecontrols=yes
Disable the control buttons shown when using the Shapes tool
that allow changing how shapes are drawn — centered around the
initial mouse click, or with a corner at the initial mouse
click.
nolabel=yes
Disables the Label tool: the tool that allows text entry which
can be edited later.
@ -1018,6 +1024,7 @@ Windows Users
--nostamps
--nostampcontrols
--nomagiccontrols
--noshapecontrols
--nolabel
--newcolorslast
--mouse-accessibility
@ -1091,6 +1098,7 @@ Windows Users
--stamps
--stampcontrols
--magiccontrols
--shapecontrols
--label
--newcolorsfirst
--nosysfonts

View file

@ -32,7 +32,7 @@
</p>
<p>
July 27, 2020
August 14, 2020
</p>
</center>
@ -742,6 +742,17 @@
default functionality (usually paint-mode).
</dd>
<dt>
<code><b>noshapecontrols=yes</b></code>
</dt>
<dd>
Disable the control buttons shown when using the <b>Shapes</b>
tool that allow changing how shapes are drawn &mdash;
centered around the initial mouse click, or with a corner
at the initial mouse click.
</dd>
<dt>
<code><b>nolabel=yes</b></code>
</dt>
@ -3090,6 +3101,7 @@
--nostamps<br>
--nostampcontrols<br>
--nomagiccontrols<br>
--noshapecontrols<br>
--nolabel<br>
--newcolorslast<br>
--mouse-accessibility<br>
@ -3170,6 +3182,7 @@
--stamps<br>
--stampcontrols<br>
--magiccontrols<br>
--shapecontrols<br>
--label<br>
--newcolorsfirst<br>
--nosysfonts<br>

View file

@ -1,5 +1,5 @@
.\" tuxpaint.1 - 2020.06.22
.TH TUXPAINT 1 "22 June 2020" "0.9.25" "Tux Paint"
.\" tuxpaint.1 - 2020.08.15
.TH TUXPAINT 1 "15 August 2020" "0.9.25" "Tux Paint"
.SH NAME
tuxpaint -- "Tux Paint", a drawing program for young children.
@ -61,6 +61,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-nomagiccontrols]
.br
[\-\-noshapecontrols]
.br
[\-\-nolabel]
.br
[\-\-newcolorslast]
@ -191,6 +193,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-magiccontrols]
.br
[\-\-shapecontrols]
.br
[\-\-label]
.br
[\-\-newcolorsfirst]
@ -418,6 +422,12 @@ controlling whether a Magic tool is used like a paint brush, or if it
affects the entire image at once. (Note: Not all Magic tools will be
controllable.)
.TP 8
.B \-\-noshapecontrols \-\-shapecontrols
Disable or enable (default) buttons to change the Shape tool's behavior --
shapes expanding from the center, or from a corner, where the mouse is
initially clicked.
.TP 8
.B \-\-nolabel \-\-label
Disable or enable (default) the \fILabel\fP tool, which lets you create

View file

@ -124,6 +124,7 @@ lang, MULTI(parsertmp_lang)
locale, MULTI(parsertmp_locale)
lockfile, POSBOOL(ok_to_use_lockfile)
magiccontrols, NEGBOOL(disable_magic_controls)
shapecontrols, NEGBOOL(disable_shape_controls)
mirrorstamps, POSBOOL(mirrorstamps)
mixedcase, NEGBOOL(only_uppercase)
mouse, NEGBOOL(keymouse)

View file

@ -15,6 +15,7 @@ struct cfginfo
const char *datadir;
const char *disable_label;
const char *disable_magic_controls;
const char *disable_shape_controls;
const char *disable_print;
const char *disable_quit;
const char *disable_save;

View file

@ -4,7 +4,7 @@
For Tux Paint
List of available shapes.
Copyright (c) 2002-2007 by Bill Kendrick and others
Copyright (c) 2002-2020 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - July 26, 2007
June 14, 2002 - August 15, 2020
$Id$
*/
@ -352,3 +352,23 @@ const char *const shape_img_fnames[NUM_SHAPES] = {
DATA_PREFIX "images/shapes/star5p.png",
DATA_PREFIX "images/shapes/star5p_f.png"
};
/* Shape controls */
enum
{
SHAPEMODE_CENTER,
SHAPEMODE_CORNER,
NUM_SHAPEMODES
};
const char *const shapemode_img_fnames[NUM_SHAPEMODES] = {
DATA_PREFIX "images/ui/shapes_center.png",
DATA_PREFIX "images/ui/shapes_corner.png"
};
const char *const shapemode_tips[NUM_SHAPES] = {
gettext_noop("Draw shapes from the center."),
gettext_noop("Draw shapes from a corner."),
};

View file

@ -19,11 +19,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Copyright (c) 2002-2019 by Bill Kendrick
Copyright (c) 2002-2020 by Bill Kendrick
bill@newbreedsoftware.com
http://www.tuxpaint.org/
June 14, 2002 - September 12, 2019
June 14, 2002 - August 15, 2020
$Id$
*/
@ -122,7 +122,7 @@ const char *const tool_tips[NUM_TOOLS] = {
// Shape tool instructions
gettext_noop
("Pick a shape. Click to pick the center, drag, then let go when it is the size you want. Move around to rotate it, and click to draw it."),
("Pick a shape. Click to start drawing, drag, and let go when it is the size you want. Move around to rotate it, and click to draw it."),
// Text tool instructions
gettext_noop

View file

@ -3,7 +3,7 @@
# Bill Kendrick <bill@newbreedsoftware.com>; http://www.tuxpaint.org/
# Based on inkscape's completion file, by allali@univ-mlv.fr
#
# Last modified 2020-07-25
# Last modified 2020-08-15
#
# $Id$
@ -50,6 +50,7 @@ _tuxpaint()
--sysfonts --nosysfonts \
--nostampcontrols --stampcontrols \
--nomagiccontrols --magiccontrols \
--noshapecontrols --shapecontrols \
--mirrorstamps --dontmirrorstamps \
--stampsize=0 --stampsize=1 \
--stampsize=2 --stampsize=3 \

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - July 29, 2020
June 14, 2002 - August 14, 2020
*/
@ -55,8 +55,6 @@
#define VIDEO_BPP 32 /* might be fastest, if conversion funcs removed */
#endif
/* #define CORNER_SHAPES *//* need major work! */
/* Method for printing images: */
#define PRINTMETHOD_PS /* Direct to PostScript */
@ -1226,6 +1224,9 @@ static int simple_shapes;
static int only_uppercase;
static int disable_magic_controls;
static int disable_shape_controls;
static int shape_mode = SHAPEMODE_CENTER;
static int starter_mirrored;
static int starter_flipped;
@ -1446,6 +1447,7 @@ static SDL_Surface *img_scroll_up, *img_scroll_down;
static SDL_Surface *img_scroll_up_off, *img_scroll_down_off;
static SDL_Surface *img_grow, *img_shrink;
static SDL_Surface *img_magic_paint, *img_magic_fullscreen;
static SDL_Surface *img_shapes_corner, *img_shapes_center;
static SDL_Surface *img_bold, *img_italic;
static SDL_Surface *img_label, *img_label_select;
static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_paintwell, *img_color_sel;
@ -3511,6 +3513,15 @@ static void mainloop(void)
}
}
else if (cur_tool == TOOL_SHAPES)
{
if (!disable_shape_controls)
{
gd_controls.rows = 1;
gd_controls.cols = 2;
}
}
/* number of whole or partial rows that will be needed
(can make this per-tool if variable columns needed) */
num_rows_needed = (num_things + gd_items.cols - 1) / gd_items.cols;
@ -3717,6 +3728,17 @@ static void mainloop(void)
}
/* FIXME: Sfx */
}
else if (cur_tool == TOOL_SHAPES)
{
/* Shape controls! */
shape_mode = which;
draw_shapes();
update_screen_rect(&r_toolopt);
draw_tux_text(TUX_GREAT, shapemode_tips[shape_mode], 1);
playsound(screen, 0, SND_CLICK, 0, SNDPOS_RIGHT, SNDDIST_NEAR);
update_screen_rect(&r_tuxarea);
toolopt_changed = 0;
}
else if (cur_tool == TOOL_TEXT)
{
/* Text controls! */
@ -4137,8 +4159,8 @@ static void mainloop(void)
update_canvas(0, 0, canvas->w, canvas->h);
}
draw_tux_text(TUX_GREAT, shape_tips[cur_shape], 1);
if (toolopt_changed)
draw_tux_text(TUX_GREAT, shape_tips[cur_shape], 1);
if (do_draw)
draw_shapes();
@ -4731,6 +4753,14 @@ static void mainloop(void)
gd_controls.cols = 2;
}
}
else if (cur_tool == TOOL_SHAPES)
{
if (!disable_shape_controls)
{
gd_controls.rows = 1;
gd_controls.cols = 2;
}
}
/* number of whole or partial rows that will be needed
(can make this per-tool if variable columns needed) */
@ -5167,6 +5197,8 @@ static void mainloop(void)
max = 10;
if (cur_tool == TOOL_MAGIC && !disable_magic_controls)
max = 12;
if (cur_tool == TOOL_SHAPES && !disable_shape_controls)
max = 12;
if (num_things > max + TOOLOFFSET)
@ -6512,6 +6544,7 @@ void show_usage(int exitcode)
" [--stamps | --nostamps]\n"
" [--nostampcontrols | --stampcontrols]\n"
" [--nomagiccontrols | --magiccontrols]\n"
" [--noshapecontrols | --shapecontrols]\n"
" [--nolabel | --label]\n"
" [--newcolorsfirst | --newcolorslast]\n"
"\n"
@ -8280,7 +8313,7 @@ static void draw_magic(void)
}
/* Draw text controls: */
/* Draw magic controls: */
if (!disable_magic_controls)
{
@ -9126,17 +9159,20 @@ static void draw_stamps(void)
/* Draw the shape selector: */
static void draw_shapes(void)
{
int i, shape, max, off_y;
int i, shape, max, off_y, most;
SDL_Rect dest;
draw_image_title(TITLE_SHAPES, r_ttoolopt);
most = 12;
if (disable_shape_controls)
most = 14;
if (NUM_SHAPES > 14 + TOOLOFFSET)
if (NUM_SHAPES > most + TOOLOFFSET)
{
off_y = 24;
max = 12 + TOOLOFFSET;
max = (most - 2) + TOOLOFFSET;
dest.x = WINDOW_WIDTH - 96;
dest.y = 40;
@ -9151,9 +9187,9 @@ static void draw_shapes(void)
}
dest.x = WINDOW_WIDTH - 96;
dest.y = 40 + 24 + ((6 + TOOLOFFSET / 2) * 48);
dest.y = 40 + 24 + ((((most - 2) / 2) + TOOLOFFSET / 2) * 48);
if (shape_scroll < NUM_SHAPES - 12 - TOOLOFFSET)
if (shape_scroll < NUM_SHAPES - (most - 2) - TOOLOFFSET)
{
SDL_BlitSurface(img_scroll_down, NULL, screen, &dest);
}
@ -9165,7 +9201,7 @@ static void draw_shapes(void)
else
{
off_y = 0;
max = 14 + TOOLOFFSET;
max = most + TOOLOFFSET;
}
for (shape = shape_scroll; shape < shape_scroll + max; shape++)
@ -9202,6 +9238,48 @@ static void draw_shapes(void)
SDL_BlitSurface(img_shape_names[shape], NULL, screen, &dest);
}
}
/* Draw magic controls: */
if (!disable_shape_controls)
{
SDL_Surface *button_color;
/* Show shape-from-center button: */
if (shape_mode == SHAPEMODE_CENTER)
button_color = img_btn_down;
else
button_color = img_btn_up;
dest.x = WINDOW_WIDTH - 96;
dest.y = 40 + ((6 + TOOLOFFSET / 2) * 48);
SDL_BlitSurface(button_color, NULL, screen, &dest);
dest.x = WINDOW_WIDTH - 96 + (48 - img_shapes_center->w) / 2;
dest.y = (40 + ((6 + TOOLOFFSET / 2) * 48) + (48 - img_shapes_center->h) / 2);
SDL_BlitSurface(img_shapes_center, NULL, screen, &dest);
/* Show shape-from-corner button: */
if (shape_mode == SHAPEMODE_CORNER)
button_color = img_btn_down;
else
button_color = img_btn_up;
dest.x = WINDOW_WIDTH - 48;
dest.y = 40 + ((6 + TOOLOFFSET / 2) * 48);
SDL_BlitSurface(button_color, NULL, screen, &dest);
dest.x = WINDOW_WIDTH - 48 + (48 - img_shapes_corner->w) / 2;
dest.y = (40 + ((6 + TOOLOFFSET / 2) * 48) + (48 - img_shapes_corner->h) / 2);
SDL_BlitSurface(img_shapes_corner, NULL, screen, &dest);
}
}
@ -12510,6 +12588,9 @@ static void cleanup(void)
free_surface(&img_magic_paint);
free_surface(&img_magic_fullscreen);
free_surface(&img_shapes_center);
free_surface(&img_shapes_corner);
free_surface(&img_bold);
free_surface(&img_italic);
@ -12751,32 +12832,6 @@ static void do_shape(int cx, int cy, int ox, int oy, int rotn, int use_brush)
old_brush = 0;
#ifdef CORNER_SHAPES
int tmp = 0;
if (cx > ox)
{
tmp = cx;
cx = ox;
ox = tmp;
}
if (cy > oy)
{
tmp = cy;
cy = oy;
oy = tmp;
}
x1 = cx;
x2 = ox;
y1 = cy;
y2 = oy;
cx += ((x2 - x1) / 2);
cy += ((y2 - y1) / 2);
#endif
rx = abs(ox - cx);
ry = abs(oy - cy);
@ -22813,6 +22868,7 @@ static void setup_config(char *argv[])
SETBOOL(autosave_on_quit);
SETBOOL(disable_label);
SETBOOL(disable_magic_controls);
SETBOOL(disable_shape_controls);
SETBOOL(disable_print);
SETBOOL(disable_quit);
SETBOOL(disable_save);
@ -24208,6 +24264,9 @@ static void setup(void)
img_magic_paint = loadimage(DATA_PREFIX "images/ui/magic_paint.png");
img_magic_fullscreen = loadimage(DATA_PREFIX "images/ui/magic_fullscreen.png");
img_shapes_center = loadimage(DATA_PREFIX "images/ui/shapes_center.png");
img_shapes_corner = loadimage(DATA_PREFIX "images/ui/shapes_corner.png");
img_bold = loadimage(DATA_PREFIX "images/ui/bold.png");
img_italic = loadimage(DATA_PREFIX "images/ui/italic.png");