"New colors last"; place colors at end of New

New option to place color palette items at the end of the "New"
dialog, rather than at the beginning.  Useful for when users
would want to pick from a set of Starters and/or Templates,
e.g., in a school or museum environment.

Available via command-line option "--newcolorslast", and
config file setting "newcolorslast=yes".  (And anti-option to
override config file settings, "--newcolorsfirst" and "...=no",
which represents the original behavior, which continues to be
the default).

Suggested by Bernard Verhaeghe.
This commit is contained in:
Bill Kendrick 2018-12-18 22:37:03 -08:00
parent 268e213e6d
commit 5d9ceca076
7 changed files with 122 additions and 66 deletions

View file

@ -26,6 +26,14 @@ $Id$
or configure Tux Paint to always bring up the dialog upon print.
Mark K. Kim <mkkim214@gmail.com>
* Other Improvements
------------------
* Added ability to move color palette options to the end of
the New dialog, for situations where users are meant to start
drawings with specific Starters or Templates.
Use "--newcolorslast" option.
(Suggested by Bernard Verhaeghe)
* Documentation updates
---------------------
* Mended link to MinGW/MSYS instructions at John Popplewell's website.

View file

@ -1,12 +1,12 @@
Tux Paint
version 0.9.23c
version 0.9.24
Options Documentation
Copyright (c) 2002-2018 by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/
October 7, 2018
December 18, 2018
----------------------------------------------------------------------
@ -358,6 +358,10 @@ Windows Users
Disables the Label tool: the tool that allows text entry which
can be edited later.
newcolorslast=yes
Places the blank color options in the New dialog at the end,
so that any Starters and/or Templates are shown first.
mirrorstamps=yes
For stamps that can be mirrored, this option sets them to
@ -980,6 +984,7 @@ Windows Users
--nostampcontrols
--nomagiccontrols
--nolabel
--newcolorslast
--mouse-accessibility
--onscreen-keyboard
--onscreen-keyboard-layout
@ -1050,6 +1055,7 @@ Windows Users
--stampcontrols
--magiccontrols
--label
--newcolorsfirst
--nosysfonts
--currentlocalefont
--dontmirrorstamps

View file

@ -11,7 +11,7 @@ alink="#FF00FF">
version
0.9.23c
0.9.24
</h1>
<h2>Options Documentation</h2>
@ -19,7 +19,7 @@ version
<p>Copyright (c) 2002-2018 by various contributors; see AUTHORS.txt<br/>
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
<p>October 7, 2018</p>
<p>December 18, 2018</p>
</center>
@ -447,6 +447,12 @@ version
which can be edited later.
</dd>
<dt><code><b>newcolorslast=yes</b></code></dt>
<dd>
Places the blank color options in the <b>New</b> dialog at the end,
so that any Starters and/or Templates are shown first.
</dd>
<dt><code><b>mirrorstamps=yes</b></code></dt>
<dd>
<p>For stamps that can be mirrored, this option sets them to their
@ -1527,6 +1533,7 @@ version
--nostampcontrols<br>
--nomagiccontrols<br>
--nolabel<br>
--newcolorslast<br>
--mouse-accessibility<br>
--onscreen-keyboard<br>
--onscreen-keyboard-layout<br>
@ -1600,6 +1607,7 @@ version
--stampcontrols<br>
--magiccontrols<br>
--label<br>
--newcolorsfirst<br>
--nosysfonts<br>
--currentlocalefont<br>
--dontmirrorstamps<br>

View file

@ -123,6 +123,8 @@ mirrorstamps, POSBOOL(mirrorstamps)
mixedcase, NEGBOOL(only_uppercase)
mouse, NEGBOOL(keymouse)
native, POSBOOL(native_screensize)
newcolorsfirst, NEGBOOL(new_colors_last)
newcolorslast, POSBOOL(new_colors_last)
orient, MULTI(rotate_orientation)
outlines, NEGBOOL(dont_do_xor)
papersize, MULTI(papersize)

View file

@ -28,6 +28,7 @@ struct cfginfo
const char *keymouse;
const char *mirrorstamps;
const char *native_screensize;
const char *new_colors_last;
const char *no_button_distinction;
const char *no_fancy_cursors;
const char *no_system_fonts;

View file

@ -8,6 +8,8 @@
# FIXME: See http://www.debian-administration.org/articles/316 for an intro
# to how we should be doing this... -bjk 2009.09.09
# FIXME: Use the source to list all of the available options -bjk 2018.12.18
have tuxpaint &&
_tuxpaint()
{
@ -41,6 +43,7 @@ _tuxpaint()
--nobuttondistinction --buttondistinction \
--outlines --nooutlines \
--stamps --nostamps \
--newcolorsfirst --newcolorslast \
--sysfonts --nosysfonts \
--nostampcontrols --stampcontrols \
--nomagiccontrols --magiccontrols \

View file

@ -1203,6 +1203,7 @@ static int dont_load_stamps;
static int mirrorstamps;
static int disable_stamp_controls;
static int stamp_size_override = -1;
static int new_colors_last;
#ifdef NOKIA_770
static int simple_shapes = 1;
@ -1958,6 +1959,7 @@ static void get_new_file_id(void);
static int do_quit(int tool);
static int do_open(void);
static int do_new_dialog(void);
static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette);
static int do_color_picker(void);
static int do_color_sel(void);
static int do_slideshow(void);
@ -6395,7 +6397,6 @@ void show_version(int details)
void show_usage(int exitcode)
{
FILE *f = exitcode ? stderr : stdout;
unsigned i;
fprintf(f,
"\n"
@ -6430,6 +6431,7 @@ void show_usage(int exitcode)
" [--nostampcontrols | --stampcontrols]\n"
" [--nomagiccontrols | --magiccontrols]\n"
" [--nolabel | --label]\n"
" [--newcolorsfirst | --newcolorslast]\n"
"\n"
" Languages:\n"
" [--lang LANGUAGE | --locale LOCALE | --lang help]\n"
@ -18586,8 +18588,6 @@ static int do_new_dialog(void)
int places_to_look;
int tot;
int first_starter, first_template;
int added;
Uint8 r, g, b;
int white_in_palette;
int val_x, val_y, motioner;
int valhat_x, valhat_y, hatmotioner;
@ -18683,7 +18683,12 @@ static int do_new_dialog(void)
/* (Re)allocate space for the information about these files: */
tot = num_files_in_dirs + NUM_COLORS;
tot = num_files_in_dirs;
/* And colors... */
if (!new_colors_last) {
tot += NUM_COLORS;
}
thumbs = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * tot);
d_places = (int *)malloc(sizeof(int) * tot);
@ -18696,66 +18701,13 @@ static int do_new_dialog(void)
qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
/* Throw the color palette at the beginning: */
/* Throw the color palette at the beginning (default): */
white_in_palette = -1;
for (j = -1; j < NUM_COLORS; j++)
{
added = 0;
if (j < NUM_COLORS - 1)
{
if (j == -1 || /* (short circuit) */
color_hexes[j][0] != 255 || /* Ignore white, we'll have already added it */
color_hexes[j][1] != 255 || color_hexes[j][2] != 255)
{
/* Palette colors: */
thumbs[num_files] = SDL_CreateRGBSurface(screen->flags,
THUMB_W - 20, THUMB_H - 20,
screen->format->BitsPerPixel,
screen->format->Rmask,
screen->format->Gmask, screen->format->Bmask, 0);
if (thumbs[num_files] != NULL)
{
if (j == -1)
{
r = g = b = 255; /* White */
}
else
{
r = color_hexes[j][0];
g = color_hexes[j][1];
b = color_hexes[j][2];
}
SDL_FillRect(thumbs[num_files], NULL, SDL_MapRGB(thumbs[num_files]->format, r, g, b));
added = 1;
}
}
else
{
white_in_palette = j;
}
}
else
{
/* Color picker: */
thumbs[num_files] = thumbnail(img_color_picker, THUMB_W - 20, THUMB_H - 20, 0);
added = 1;
}
if (added)
{
d_places[num_files] = PLACE_COLOR_PALETTE;
d_names[num_files] = NULL;
d_exts[num_files] = NULL;
num_files++;
}
}
if (!new_colors_last) {
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
first_starter = num_files;
first_template = -1; /* In case there are none... */
@ -19058,10 +19010,15 @@ static int do_new_dialog(void)
}
}
/* Throw the color palette at the end (alternative option): */
if (new_colors_last) {
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
#ifdef DEBUG
printf("%d files were found!\n", num_files);
printf("%d files and colors were found!\n", num_files);
#endif
@ -19705,6 +19662,76 @@ static int do_new_dialog(void)
return (which != -1);
}
/* Add colors to the "New" dialog's list of choices;
normally appears at the beginning (above Starts & Templates),
but may be placed at the end with the "--newcolorslast" option.
*/
static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette) {
int j;
int added;
Uint8 r, g, b;
for (j = -1; j < NUM_COLORS; j++)
{
added = 0;
if (j < NUM_COLORS - 1)
{
if (j == -1 || /* (short circuit) */
color_hexes[j][0] != 255 || /* Ignore white, we'll have already added it */
color_hexes[j][1] != 255 || color_hexes[j][2] != 255)
{
/* Palette colors: */
thumbs[num_files] = SDL_CreateRGBSurface(screen->flags,
THUMB_W - 20, THUMB_H - 20,
screen->format->BitsPerPixel,
screen->format->Rmask,
screen->format->Gmask, screen->format->Bmask, 0);
if (thumbs[num_files] != NULL)
{
if (j == -1)
{
r = g = b = 255; /* White */
}
else
{
r = color_hexes[j][0];
g = color_hexes[j][1];
b = color_hexes[j][2];
}
SDL_FillRect(thumbs[num_files], NULL, SDL_MapRGB(thumbs[num_files]->format, r, g, b));
added = 1;
}
}
else
{
*white_in_palette = j;
}
}
else
{
/* Color picker: */
thumbs[num_files] = thumbnail(img_color_picker, THUMB_W - 20, THUMB_H - 20, 0);
added = 1;
}
if (added)
{
d_places[num_files] = PLACE_COLOR_PALETTE;
d_names[num_files] = NULL;
d_exts[num_files] = NULL;
num_files++;
}
}
return num_files;
}
/**
* FIXME
*/
@ -22492,6 +22519,7 @@ application support folder */
SETBOOL(keymouse);
SETBOOL(mirrorstamps);
SETBOOL(native_screensize);
SETBOOL(new_colors_last);
SETBOOL(no_button_distinction);
SETBOOL(no_fancy_cursors);
SETBOOL(no_system_fonts);