From 3c391bc3af9233c0b08bec3939c1db666ebdc3d8 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 16 May 2010 17:37:32 +0000 Subject: [PATCH] Paintbrush menu: A dropdown list to choose a built-in resizable brush. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1480 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/buttons.c | 58 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index c885f6a4..54c356d3 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -2753,7 +2753,21 @@ void Button_Paintbrush_menu(void) Window_display_frame(8,21,294,132); - Window_set_normal_button(122,158,67,14,"Cancel",0,1,KEY_ESC); // 1 + Window_set_normal_button(10,158,67,14,"Cancel",0,1,KEY_ESC); // 1 + + Window_set_dropdown_button(216, 158, 84,14,84,"Preset...", 0,0,1,RIGHT_SIDE|LEFT_SIDE,1); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_ROUND, "Round"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_SQUARE, "Square"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_HORIZONTAL_BAR,"Horizontal"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_VERTICAL_BAR, "Vertical"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_SLASH, "Slash"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_ANTISLASH, "Antislash"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_RANDOM, "Random"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_CROSS, "Cross"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_PLUS, "Plus"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_DIAMOND, "Diamond"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_SIEVE_ROUND, "Sieve Rnd"); + Window_dropdown_add_item(Window_dropdown_button_list,PAINTBRUSH_SHAPE_SIEVE_SQUARE, "Sieve Sqr"); for (index=0; index(NB_PAINTBRUSH_SPRITES+1)) + if (clicked_button>=(NB_PAINTBRUSH_SPRITES+3)) { - index = clicked_button-NB_PAINTBRUSH_SPRITES-2; + index = clicked_button-NB_PAINTBRUSH_SPRITES-3; if (Window_attribute2==1) // Set { @@ -2815,20 +2829,20 @@ void Button_Paintbrush_menu(void) } } - else if (clicked_button>1) + else if (clicked_button>=3) // Standard paintbrushes { if (Window_attribute2!=1) { // Select paintbrush Close_window(); - Select_paintbrush(clicked_button-2); + Select_paintbrush(clicked_button-3); break; } else if (Window_attribute2==1) { // Store current - index=clicked_button-2; + index=clicked_button-3; if (!Store_paintbrush(index)) { // Redraw @@ -2846,6 +2860,38 @@ void Button_Paintbrush_menu(void) Close_window(); break; } + else if (clicked_button==2) + { + int size; + // Pick a standard shape + Paintbrush_shape=Window_attribute2; + // Assign a reasonable size + size=Max(Paintbrush_width,Paintbrush_height); + if (size==1) + size=3; + + switch (Paintbrush_shape) + { + case PAINTBRUSH_SHAPE_HORIZONTAL_BAR: + Set_paintbrush_size(size, 1); + break; + case PAINTBRUSH_SHAPE_VERTICAL_BAR: + Set_paintbrush_size(1, size); + break; + case PAINTBRUSH_SHAPE_CROSS: + case PAINTBRUSH_SHAPE_PLUS: + case PAINTBRUSH_SHAPE_DIAMOND: + Set_paintbrush_size(size|1,size|1); + break; + default: + Set_paintbrush_size(size,size); + break; + + } + Close_window(); + Change_paintbrush_shape(Paintbrush_shape); + break; + } } while (1);