GrafX2 2.9.3227
The ultimate 256-color painting program
buttons_effects.c File Reference

Handles all the effects buttons and setup windows in the effects menu. More...

#include <stdlib.h>
#include <string.h>
#include "gfx2log.h"
#include "brush.h"
#include "buttons.h"
#include "engine.h"
#include "global.h"
#include "graph.h"
#include "help.h"
#include "input.h"
#include "misc.h"
#include "pages.h"
#include "readline.h"
#include "screen.h"
#include "struct.h"
#include "windows.h"
#include "tiles.h"
#include "oldies.h"
#include "palette.h"
#include "layers.h"
+ Include dependency graph for buttons_effects.c:

Macros

#define MIN(a, b)   ((a)<(b)?(a):(b))
 

Functions

void Menu_tag_colors (char *window_title, byte *table, byte *mode, byte can_cancel, const char *help_section, word close_shortcut)
 Generic color tagging menu, for various effects. More...
 
static int Check_block_constraints (enum IMAGE_MODES mode)
 Block Constraint check. More...
 
static void Convert_to_hgr (void)
 convert a picture to the HGR mode More...
 
static void Convert_to_dhgr (void)
 convert a picture to the DHGR mode More...
 
void Button_Constraint_mode (void)
 Constaint enforcer/checker. More...
 
void Button_Constraint_menu (void)
 
void Button_Tilemap_mode (void)
 
void Button_Tilemap_menu (void)
 
void Button_Stencil_mode (void)
 Callback for the Stencil button (in the FX window) left click. More...
 
void Stencil_tag_color (byte color, byte tag_color)
 
void Stencil_update_color (byte color)
 
void Button_Stencil_menu (void)
 Callback for the Stencil button (in the FX window) right click. More...
 
void Button_Mask_mode (void)
 Callback for the Mask button (in the FX window) left click. More...
 
void Button_Mask_menu (void)
 Callback for the Mask button (in the FX window) right click. More...
 
void Button_Snap_mode (void)
 Callback for the Grid button (in the FX window) left click. More...
 
void Button_Grid_menu (void)
 Callback for the Grid button (in the FX window) right click. More...
 
void Button_Show_grid (void)
 Callback to toggle the grid visible in the magnified view. More...
 
void Button_Smooth_mode (void)
 Callback for the smooth button (in the FX window) left click. More...
 
void Button_Smooth_menu (void)
 Display the menu for the smooth effect. More...
 
void Button_Smear_mode (void)
 Toogles the smear mode. More...
 
void Compute_colorize_table (void)
 Computes the tables used by the transparency/colorize mode. More...
 
void Button_Colorize_mode (void)
 Callback for the Tranparency button (in the FX window) left click. More...
 
void Button_Colorize_display_selection (int mode)
 
void Button_Colorize_menu (void)
 Callback for the Transparency button (in the FX window) right click. More...
 
void Button_Tiling_mode (void)
 Callback for the Tiling button (in the FX window) left click. More...
 
void Button_Tiling_menu (void)
 Callback for the Tiling button (in the FX window) right click. More...
 
void Effects_off (void)
 Callback for the command that turns off all drawaing effects. More...
 
void Button_Sieve_mode (void)
 Callback for the Sieve button (in the FX window) left click. More...
 
void Draw_sieve_scaled (short origin_x, short origin_y)
 
void Draw_preset_sieve_patterns (void)
 
void Copy_preset_sieve (byte index)
 In the sieve window, copy one of the presets patterns to the current one. More...
 
void Invert_trame (void)
 In the sieve window, swaps black and white in the current pattern. More...
 
void Update_sieve_area (short x, short y)
 
void Button_Sieve_menu (void)
 Callback for the Sieve button (in the FX window) right click. More...
 

Variables

static const byte Smooth_default_matrices [4][3][3]
 

Detailed Description

Handles all the effects buttons and setup windows in the effects menu.

Macro Definition Documentation

◆ MIN

#define MIN (   a,
 
)    ((a)<(b)?(a):(b))

Function Documentation

◆ Menu_tag_colors()

◆ Check_block_constraints()

static int Check_block_constraints ( enum IMAGE_MODES  mode)
static

Block Constraint check.

This function count the number of colors in a block and reports errors by marking the pixel in color 17 in layer 2.

Parameters
mode
Returns
-1 if the mode is invalid
the number of constraint errors detected

References Add_layer(), T_Document::backups, T_Document::current_layer, GFX2_INFO, GFX2_Log(), T_Document::image_height, IMAGE_MODE_C64HIRES, IMAGE_MODE_C64MULTI, IMAGE_MODE_GBC, IMAGE_MODE_MEGADRIVE, IMAGE_MODE_THOMSON, IMAGE_MODE_TMS9918G2, IMAGE_MODE_ZX, T_Document::image_width, Main, mode, T_Page::Nb_layers, T_List_of_pages::Pages, Pixel_in_layer(), and Read_pixel_from_layer().

Referenced by Button_Constraint_mode().

◆ Convert_to_hgr()

static void Convert_to_hgr ( void  )
static

convert a picture to the HGR mode

Recognize monochrome pictures. Color pictures should use the 8 first colors.

References Count_used_colors(), GFX2_DEBUG, GFX2_Log(), T_Document::image_height, T_Document::image_width, Main, Pixel_in_layer(), Read_pixel_from_layer(), and Update_color_hgr_pixel().

Referenced by Button_Constraint_mode().

◆ Convert_to_dhgr()

static void Convert_to_dhgr ( void  )
static

◆ Button_Constraint_mode()

◆ Button_Constraint_menu()

void Button_Constraint_menu ( void  )
Todo:
enable WIDE pixels when switching to 160x200
Todo:
enable TALL pixels when switching to 560x192

References Back_color, T_Document::backups, Button_Constraint_mode(), BUTTON_EFFECTS, BUTTON_HELP, C64_set_palette(), Check_menu_mode(), Close_window(), Compute_optimal_menu_colors(), Config, CPC_set_default_BASIC_palette(), CPC_set_HW_palette(), DHGR_set_palette(), Dialog_multiple_choice(), Display_all_screen(), Display_cursor(), Display_menu(), End_of_modification(), Favorite_GUI_color(), First_color_in_palette, Fore_color, HGR_set_palette(), Hide_cursor, T_Page::Image_mode, IMAGE_MODE_ANIMATION, IMAGE_MODE_C64FLI, IMAGE_MODE_C64HIRES, IMAGE_MODE_C64MULTI, IMAGE_MODE_DHGR, IMAGE_MODE_EGX, IMAGE_MODE_EGX2, IMAGE_MODE_GBC, IMAGE_MODE_HGR, IMAGE_MODE_MEGADRIVE, IMAGE_MODE_MODE5, IMAGE_MODE_RASTER, IMAGE_MODE_THOMSON, IMAGE_MODE_TMS9918G2, IMAGE_MODE_ZX, Is_shortcut(), Key, KEY_ESC, KEY_g, KEY_p, KEY_RETURN, KEY_s, label, LEFT_SIDE, MACHINE_MO5, MACHINE_MO6, MACHINE_TO7, MACHINE_TO8, Main, MC_Black, MC_Dark, MC_Light, mode, T_Config::MOTO_gamma, MOTO_set_MO5_palette(), MOTO_set_TO7_palette(), MSX_set_palette(), NULL, Open_window(), T_List_of_pages::Pages, T_Document::palette, Print_in_window(), Print_in_window_underscore(), Redraw_layered_image(), Remap_screen_after_menu_colors_change(), Resize_image(), RIGHT_SIDE, Selected_Constraint_Mode, Set_palette(), Set_palette_Gamma(), Set_palette_RGB_scale(), Show_grid, Snap_height, Snap_mode, Snap_offset_X, Snap_offset_Y, Snap_width, Update_window_area, Window_attribute2, Window_clicked_button(), Window_dropdown_add_item(), Window_height, Window_help(), Window_set_dropdown_button(), Window_set_normal_button(), Window_width, and ZX_Spectrum_set_palette().

Referenced by Button_Effects().

◆ Button_Tilemap_mode()

void Button_Tilemap_mode ( void  )

◆ Button_Tilemap_menu()

◆ Button_Stencil_mode()

void Button_Stencil_mode ( void  )

Callback for the Stencil button (in the FX window) left click.

Toogle stencil mode.

References Stencil_mode.

Referenced by Button_Effects(), and Main_handler().

◆ Stencil_tag_color()

void Stencil_tag_color ( byte  color,
byte  tag_color 
)

◆ Stencil_update_color()

void Stencil_update_color ( byte  color)

◆ Button_Stencil_menu()

void Button_Stencil_menu ( void  )

Callback for the Stencil button (in the FX window) right click.

Displays the stencil setup menu.

References Menu_tag_colors(), SPECIAL_STENCIL_MENU, Stencil, and Stencil_mode.

Referenced by Button_Effects(), and Main_handler().

◆ Button_Mask_mode()

void Button_Mask_mode ( void  )

Callback for the Mask button (in the FX window) left click.

Toogles the mask mode/

References Mask_mode.

Referenced by Button_Effects(), and Main_handler().

◆ Button_Mask_menu()

void Button_Mask_menu ( void  )

Callback for the Mask button (in the FX window) right click.

Displays the mask setup menu.

References Mask_mode, Mask_table, Menu_tag_colors(), and SPECIAL_MASK_MENU.

Referenced by Button_Effects(), and Main_handler().

◆ Button_Snap_mode()

void Button_Snap_mode ( void  )

Callback for the Grid button (in the FX window) left click.

Toogle the grid.

References Compute_paintbrush_coordinates(), Display_cursor(), Hide_cursor, and Snap_mode.

Referenced by Button_Effects(), and Main_handler().

◆ Button_Grid_menu()

◆ Button_Show_grid()

void Button_Show_grid ( void  )

Callback to toggle the grid visible in the magnified view.

References Display_all_screen(), Display_cursor(), Hide_cursor, and Show_grid.

Referenced by Main_handler().

◆ Button_Smooth_mode()

void Button_Smooth_mode ( void  )

Callback for the smooth button (in the FX window) left click.

Callback for the Smooth button (in the FX window) right click.

Toogles smooth mode.

Displays the smooth setup menu.

References Colorize_mode, Effect_function, Effect_smooth(), No_effect(), Quick_shade_mode, Shade_mode, Smear_mode, Smooth_mode, and Tiling_mode.

Referenced by Button_Effects(), Button_Smooth_menu(), and Main_handler().

◆ Button_Smooth_menu()

◆ Button_Smear_mode()

void Button_Smear_mode ( void  )

◆ Compute_colorize_table()

void Compute_colorize_table ( void  )

Computes the tables used by the transparency/colorize mode.

These tables are used to match the drawing color*picture color to the color that is painted on screen.

References Colorize_opacity, Factors_inv_table, and Factors_table.

Referenced by Button_Colorize_menu(), Init_program(), and Transparency_set().

◆ Button_Colorize_mode()

void Button_Colorize_mode ( void  )

◆ Button_Colorize_display_selection()

void Button_Colorize_display_selection ( int  mode)

References MC_Black, MC_Light, mode, and Print_in_window().

Referenced by Button_Colorize_menu().

◆ Button_Colorize_menu()

◆ Button_Tiling_mode()

void Button_Tiling_mode ( void  )

Callback for the Tiling button (in the FX window) left click.

Toogles tiling mode.

References Colorize_mode, Effect_function, Effect_tiling(), No_effect(), Quick_shade_mode, Shade_mode, Smear_mode, Smooth_mode, and Tiling_mode.

Referenced by Button_Effects(), Button_Tiling_menu(), and Main_handler().

◆ Button_Tiling_menu()

◆ Effects_off()

void Effects_off ( void  )

◆ Button_Sieve_mode()

void Button_Sieve_mode ( void  )

Callback for the Sieve button (in the FX window) left click.

Toogle sieve mode.

References Sieve_mode.

Referenced by Button_Effects(), Button_Sieve_menu(), and Main_handler().

◆ Draw_sieve_scaled()

void Draw_sieve_scaled ( short  origin_x,
short  origin_y 
)

◆ Draw_preset_sieve_patterns()

◆ Copy_preset_sieve()

void Copy_preset_sieve ( byte  index)

In the sieve window, copy one of the presets patterns to the current one.

Parameters
indexIndex of the pattern to copy

References Gfx, Sieve, Sieve_height, T_Gui_skin::Sieve_pattern, and Sieve_width.

Referenced by Button_Sieve_menu(), and Init_program().

◆ Invert_trame()

void Invert_trame ( void  )

In the sieve window, swaps black and white in the current pattern.

References Sieve, Sieve_height, and Sieve_width.

Referenced by Button_Sieve_menu(), and Main_handler().

◆ Update_sieve_area()

void Update_sieve_area ( short  x,
short  y 
)

◆ Button_Sieve_menu()

Variable Documentation

◆ Smooth_default_matrices

const byte Smooth_default_matrices[4][3][3]
static
Initial value:
=
{
{ {1,2,1}, {2,4,2}, {1,2,1} },
{ {1,3,1}, {3,9,3}, {1,3,1} },
{ {0,1,0}, {1,2,1}, {0,1,0} },
{ {2,3,2}, {3,1,3}, {2,3,2} }
}

Referenced by Button_Smooth_menu().