WIP Label "apply" option

Starting work towards
https://sourceforge.net/p/tuxpaint/feature-requests/213/

The ability to 'apply' a label to the canvas, making it permanent
(as if added using the "Text" tool instead).

Removed unused "label rotate" option's code (and hence addressed
a bug we didn't relalize when choosing the "Label" tool while in
in "--nostampcontrols" mode; the unused "rotate" button would appear).
This commit is contained in:
Bill Kendrick 2022-02-09 22:41:13 -08:00
parent b60a4ec4d1
commit f787cb0f75
3 changed files with 50 additions and 68 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View file

@ -70,6 +70,12 @@ http://www.tuxpaint.org/
(h/t Anat Caspi) (h/t Anat Caspi)
Bill Kendrick <bill@newbreedsoftware.com> Bill Kendrick <bill@newbreedsoftware.com>
* WIP "Label" tool now offers a way to "apply" a label to the
canvas (as if it were 'painted' onto the drawing with the "Text"
tool).
Closes https://sourceforge.net/p/tuxpaint/feature-requests/213/
Bill Kendrick <bill@newbreedsoftware.com>
* More instruction text are shown (and sound effects play) when * More instruction text are shown (and sound effects play) when
using the Label tool. using the Label tool.
Bill Kendrick <bill@newbreedsoftware.com> Bill Kendrick <bill@newbreedsoftware.com>

View file

@ -685,7 +685,6 @@ enum
LABEL_OFF, LABEL_OFF,
LABEL_LABEL, LABEL_LABEL,
LABEL_SELECT LABEL_SELECT
/* , LABEL_ROTATE */
}; };
@ -1536,7 +1535,7 @@ static SDL_Surface *img_grow, *img_shrink;
static SDL_Surface *img_magic_paint, *img_magic_fullscreen; static SDL_Surface *img_magic_paint, *img_magic_fullscreen;
static SDL_Surface *img_shapes_corner, *img_shapes_center; static SDL_Surface *img_shapes_corner, *img_shapes_center;
static SDL_Surface *img_bold, *img_italic; static SDL_Surface *img_bold, *img_italic;
static SDL_Surface *img_label, *img_label_select; static SDL_Surface *img_label_select, *img_label_apply;
static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_paintwell, *img_color_sel, *img_color_mix; static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_paintwell, *img_color_sel, *img_color_mix;
static int color_picker_x, color_picker_y; static int color_picker_x, color_picker_y;
static int color_mixer_reset; static int color_mixer_reset;
@ -9657,29 +9656,19 @@ static void draw_fonts(void)
/* Draw text controls: */ /* Draw text controls: */
if (!disable_stamp_controls) /* Label controls, if in label tool (always!) */
{
SDL_Surface *button_color;
SDL_Surface *button_body;
if (cur_tool == TOOL_LABEL) if (cur_tool == TOOL_LABEL)
{ {
/* "Apply Label" button */
/* disabling rotation as I am not sure how this should be implemented */
dest.x = WINDOW_WIDTH - r_ttoolopt.w; dest.x = WINDOW_WIDTH - r_ttoolopt.w;
dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h);
SDL_BlitSurface(img_btn_off, NULL, screen, &dest); SDL_BlitSurface(img_btn_off, NULL, screen, &dest);
/* if(cur_label == LABEL_ROTATE) */ /* FIXME: Draw img_label_apply -bjk 2022.02.09 */
/* SDL_BlitSurface(img_btn_down, NULL, screen, &dest); */
/* else */
/* SDL_BlitSurface(img_btn_up, NULL, screen, &dest); */
/* dest.x = WINDOW_WIDTH - r_ttoolopt.w + (48 - img_label->w) / 2; */
/* dest.y = (40 + ((4 + TOOLOFFSET / 2) * 48) + (48 - img_label->h) / 2); */
/* SDL_BlitSurface(img_label, NULL, screen, &dest); */
/* "Select Label" button */
dest.x = WINDOW_WIDTH - button_w; dest.x = WINDOW_WIDTH - button_w;
dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h);
@ -9702,6 +9691,15 @@ static void draw_fonts(void)
most = most + gd_toolopt.cols; most = most + gd_toolopt.cols;
} }
/* Size, italic, and bold, only appear when not UI is not being simplified */
if (!disable_stamp_controls)
{
SDL_Surface *button_color;
SDL_Surface *button_body;
// label_ctrl_y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h);
/* Show bold button: */ /* Show bold button: */
dest.x = WINDOW_WIDTH - r_ttoolopt.w; dest.x = WINDOW_WIDTH - r_ttoolopt.w;
@ -9734,7 +9732,7 @@ static void draw_fonts(void)
SDL_BlitSurface(img_italic, NULL, screen, &dest); SDL_BlitSurface(img_italic, NULL, screen, &dest);
most = most + gd_toolopt.cols; most = most + gd_toolopt.cols;
// printf("most %d\n", most);
/* Show shrink button: */ /* Show shrink button: */
@ -9783,31 +9781,6 @@ static void draw_fonts(void)
SDL_BlitSurface(button_color, NULL, img_grow, NULL); SDL_BlitSurface(button_color, NULL, img_grow, NULL);
SDL_BlitSurface(img_grow, NULL, screen, &dest); SDL_BlitSurface(img_grow, NULL, screen, &dest);
} }
else
{
if (cur_tool == TOOL_LABEL)
{
dest.x = WINDOW_WIDTH - r_ttoolopt.w;
dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h);
SDL_BlitSurface(img_btn_up, NULL, screen, &dest);
dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_label->w) / 2;
dest.y = (r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_label->h) / 2);
SDL_BlitSurface(img_label, NULL, screen, &dest);
dest.x = WINDOW_WIDTH - button_w;
dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h);
SDL_BlitSurface(img_btn_up, NULL, screen, &dest);
dest.x = WINDOW_WIDTH - button_w + (button_w - img_label_select->w) / 2;
dest.y = (r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_label_select->h) / 2);
SDL_BlitSurface(img_label_select, NULL, screen, &dest);
}
}
} }
@ -13878,6 +13851,9 @@ static void cleanup(void)
free_surface(&img_bold); free_surface(&img_bold);
free_surface(&img_italic); free_surface(&img_italic);
free_surface(&img_label_select);
free_surface(&img_label_apply);
free_surface_array(undo_bufs, NUM_UNDO_BUFS); free_surface_array(undo_bufs, NUM_UNDO_BUFS);
#ifdef LOW_QUALITY_COLOR_SELECTOR #ifdef LOW_QUALITY_COLOR_SELECTOR
@ -26721,8 +26697,8 @@ static void setup(void)
img_bold = loadimagerb(DATA_PREFIX "images/ui/bold.png"); img_bold = loadimagerb(DATA_PREFIX "images/ui/bold.png");
img_italic = loadimagerb(DATA_PREFIX "images/ui/italic.png"); img_italic = loadimagerb(DATA_PREFIX "images/ui/italic.png");
img_label = loadimagerb(DATA_PREFIX "images/tools/label.png");
img_label_select = loadimagerb(DATA_PREFIX "images/tools/label_select.png"); img_label_select = loadimagerb(DATA_PREFIX "images/tools/label_select.png");
img_label_apply = loadimagerb(DATA_PREFIX "images/tools/label_apply.png");
show_progress_bar(screen); show_progress_bar(screen);