Issue 233: Added mouse panning. Default is 'space' for new users, others need pick a key in Help screen.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1901 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
46f2ec9475
commit
cbcb7a6b8f
@ -518,6 +518,8 @@ enum SPECIAL_ACTIONS
|
|||||||
SPECIAL_FORMAT_CHECKER,
|
SPECIAL_FORMAT_CHECKER,
|
||||||
SPECIAL_FORMAT_CHECKER_MENU,
|
SPECIAL_FORMAT_CHECKER_MENU,
|
||||||
|
|
||||||
|
SPECIAL_HOLD_PAN,
|
||||||
|
|
||||||
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
|
NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -558,6 +560,7 @@ enum OPERATIONS
|
|||||||
OPERATION_DISTORT_BRUSH, ///< Distort brush
|
OPERATION_DISTORT_BRUSH, ///< Distort brush
|
||||||
OPERATION_GRAD_RECTANGLE, ///< Gradient-filled rectangle
|
OPERATION_GRAD_RECTANGLE, ///< Gradient-filled rectangle
|
||||||
OPERATION_RMB_COLORPICK, ///< Colorpick on right mouse button
|
OPERATION_RMB_COLORPICK, ///< Colorpick on right mouse button
|
||||||
|
OPERATION_PAN_VIEW, ///< Pan view
|
||||||
NB_OPERATIONS ///< Number of operations handled by the engine
|
NB_OPERATIONS ///< Number of operations handled by the engine
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
12
src/engine.c
12
src/engine.c
@ -734,7 +734,14 @@ void Main_handler(void)
|
|||||||
Button_Quit();
|
Button_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Key)
|
if (Pan_shortcut_pressed && Current_operation!=OPERATION_PAN_VIEW)
|
||||||
|
{
|
||||||
|
Hide_cursor();
|
||||||
|
Start_operation_stack(OPERATION_PAN_VIEW);
|
||||||
|
Display_cursor();
|
||||||
|
action++;
|
||||||
|
}
|
||||||
|
else if (Key)
|
||||||
{
|
{
|
||||||
effect_modified = 0;
|
effect_modified = 0;
|
||||||
|
|
||||||
@ -1341,6 +1348,9 @@ void Main_handler(void)
|
|||||||
Set_palette(Main_palette);
|
Set_palette(Main_palette);
|
||||||
action++;
|
action++;
|
||||||
break;
|
break;
|
||||||
|
case SPECIAL_HOLD_PAN:
|
||||||
|
// already handled by Pan_shortcut_pressed
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // End of special keys
|
} // End of special keys
|
||||||
|
|||||||
@ -900,7 +900,7 @@ GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTA
|
|||||||
CURSOR_SHAPE_TARGET , // Polyform
|
CURSOR_SHAPE_TARGET , // Polyform
|
||||||
CURSOR_SHAPE_TARGET , // Filled polygon
|
CURSOR_SHAPE_TARGET , // Filled polygon
|
||||||
CURSOR_SHAPE_TARGET , // Filled polyform
|
CURSOR_SHAPE_TARGET , // Filled polyform
|
||||||
CURSOR_SHAPE_MULTIDIRECTIONAL , // Scroll (pan)
|
CURSOR_SHAPE_MULTIDIRECTIONAL , // Scroll image
|
||||||
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled circle
|
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled circle
|
||||||
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled ellipse
|
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled ellipse
|
||||||
CURSOR_SHAPE_XOR_ROTATION , // Rotate brush
|
CURSOR_SHAPE_XOR_ROTATION , // Rotate brush
|
||||||
@ -908,6 +908,7 @@ GFX2_GLOBAL T_Brush_template Brush_container[BRUSH_CONTAINER_COLUMNS*BRUSH_CONTA
|
|||||||
CURSOR_SHAPE_TARGET , // Distort brush
|
CURSOR_SHAPE_TARGET , // Distort brush
|
||||||
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled rectangle
|
CURSOR_SHAPE_XOR_TARGET , // Gradient-filled rectangle
|
||||||
CURSOR_SHAPE_COLORPICKER , // Colorpick on right mouse button
|
CURSOR_SHAPE_COLORPICKER , // Colorpick on right mouse button
|
||||||
|
CURSOR_SHAPE_MULTIDIRECTIONAL , // Pan view
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
/// ::Cursor_shape to use for each operation.
|
/// ::Cursor_shape to use for each operation.
|
||||||
|
|||||||
@ -122,6 +122,7 @@ static const T_Help_table helptable_help[] =
|
|||||||
HELP_LINK (" down slower: %s", SPECIAL_SCROLL_DOWN_SLOW)
|
HELP_LINK (" down slower: %s", SPECIAL_SCROLL_DOWN_SLOW)
|
||||||
HELP_LINK (" left slower: %s", SPECIAL_SCROLL_LEFT_SLOW)
|
HELP_LINK (" left slower: %s", SPECIAL_SCROLL_LEFT_SLOW)
|
||||||
HELP_LINK (" right slower: %s", SPECIAL_SCROLL_RIGHT_SLOW)
|
HELP_LINK (" right slower: %s", SPECIAL_SCROLL_RIGHT_SLOW)
|
||||||
|
HELP_LINK ("Mouse pan: %s", SPECIAL_HOLD_PAN)
|
||||||
HELP_TEXT ("Emulate mouse")
|
HELP_TEXT ("Emulate mouse")
|
||||||
HELP_LINK (" Up: %s", SPECIAL_MOUSE_UP)
|
HELP_LINK (" Up: %s", SPECIAL_MOUSE_UP)
|
||||||
HELP_LINK (" Down: %s", SPECIAL_MOUSE_DOWN)
|
HELP_LINK (" Down: %s", SPECIAL_MOUSE_DOWN)
|
||||||
|
|||||||
@ -163,7 +163,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
|
|||||||
"left mouse button. It's useful",
|
"left mouse button. It's useful",
|
||||||
"when you want ultra-high precision.",
|
"when you want ultra-high precision.",
|
||||||
true,
|
true,
|
||||||
SDLK_SPACE, // Space
|
SDLK_SPACE|MOD_CTRL, // Ctrl + Space
|
||||||
0},
|
0},
|
||||||
{17,
|
{17,
|
||||||
"Simulate right mouse click",
|
"Simulate right mouse click",
|
||||||
@ -1721,6 +1721,14 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = {
|
|||||||
true,
|
true,
|
||||||
0, // No shortcut
|
0, // No shortcut
|
||||||
0},
|
0},
|
||||||
|
{208,
|
||||||
|
"Pan view",
|
||||||
|
"While this key is being held,",
|
||||||
|
"click and drag the mouse to",
|
||||||
|
"pan the view.",
|
||||||
|
true,
|
||||||
|
SDLK_SPACE, // Space
|
||||||
|
0},
|
||||||
};
|
};
|
||||||
|
|
||||||
word Ordering[NB_SHORTCUTS]=
|
word Ordering[NB_SHORTCUTS]=
|
||||||
@ -1933,4 +1941,5 @@ word Ordering[NB_SHORTCUTS]=
|
|||||||
0x100+BUTTON_ANIM_PREV_FRAME,
|
0x100+BUTTON_ANIM_PREV_FRAME,
|
||||||
0x100+BUTTON_ANIM_NEXT_FRAME,
|
0x100+BUTTON_ANIM_NEXT_FRAME,
|
||||||
0x100+BUTTON_ANIM_PLAY,
|
0x100+BUTTON_ANIM_PLAY,
|
||||||
|
SPECIAL_HOLD_PAN,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#define NB_SHORTCUTS 208 ///< Number of actions that can have a key combination associated to it.
|
#define NB_SHORTCUTS 209 ///< Number of actions that can have a key combination associated to it.
|
||||||
|
|
||||||
/*** Types definitions and structs ***/
|
/*** Types definitions and structs ***/
|
||||||
|
|
||||||
|
|||||||
13
src/init.c
13
src/init.c
@ -1737,9 +1737,20 @@ void Init_operations(void)
|
|||||||
Centered_lines_12_7,0,FAST_MOUSE);
|
Centered_lines_12_7,0,FAST_MOUSE);
|
||||||
Init_operation(OPERATION_CENTERED_LINES,0,7,
|
Init_operation(OPERATION_CENTERED_LINES,0,7,
|
||||||
Centered_lines_0_7,0,FAST_MOUSE);
|
Centered_lines_0_7,0,FAST_MOUSE);
|
||||||
|
|
||||||
Init_operation(OPERATION_RMB_COLORPICK,0,1,
|
Init_operation(OPERATION_RMB_COLORPICK,0,1,
|
||||||
Rightclick_colorpick_0_1,0,FAST_MOUSE);
|
Rightclick_colorpick_0_1,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,0,0,
|
||||||
|
Pan_view_0_0,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,1,0,
|
||||||
|
Pan_view_12_0,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,2,0,
|
||||||
|
Pan_view_12_0,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,1,2,
|
||||||
|
Pan_view_12_2,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,2,2,
|
||||||
|
Pan_view_12_2,0,FAST_MOUSE);
|
||||||
|
Init_operation(OPERATION_PAN_VIEW,0,2,
|
||||||
|
Pan_view_0_2,0,FAST_MOUSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/input.c
16
src/input.c
@ -85,6 +85,8 @@ word Input_new_mouse_Y;
|
|||||||
byte Input_new_mouse_K;
|
byte Input_new_mouse_K;
|
||||||
byte Button_inverter=0; // State of the key that swaps mouse buttons.
|
byte Button_inverter=0; // State of the key that swaps mouse buttons.
|
||||||
|
|
||||||
|
byte Pan_shortcut_pressed;
|
||||||
|
|
||||||
// Joystick/pad configurations for the various console ports.
|
// Joystick/pad configurations for the various console ports.
|
||||||
// See the #else for the documentation of fields.
|
// See the #else for the documentation of fields.
|
||||||
// TODO: Make these user-settable somehow.
|
// TODO: Make these user-settable somehow.
|
||||||
@ -443,7 +445,11 @@ int Handle_key_press(SDL_KeyboardEvent event)
|
|||||||
Directional_click=2;
|
Directional_click=2;
|
||||||
return Move_cursor_with_constraints();
|
return Move_cursor_with_constraints();
|
||||||
}
|
}
|
||||||
|
else if(Is_shortcut(Key,SPECIAL_HOLD_PAN))
|
||||||
|
{
|
||||||
|
Pan_shortcut_pressed=1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +513,13 @@ int Release_control(int key_code, int modifier)
|
|||||||
return Move_cursor_with_constraints() || need_feedback;
|
return Move_cursor_with_constraints() || need_feedback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if((key_code && key_code == (Config_Key[SPECIAL_HOLD_PAN][0]&0x0FFF)) || (Config_Key[SPECIAL_HOLD_PAN][0]&modifier) ||
|
||||||
|
(key_code && key_code == (Config_Key[SPECIAL_HOLD_PAN][1]&0x0FFF)) || (Config_Key[SPECIAL_HOLD_PAN][1]&modifier))
|
||||||
|
{
|
||||||
|
Pan_shortcut_pressed=0;
|
||||||
|
need_feedback = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Other keys don't need to be released : they are handled as "events" and procesed only once.
|
// Other keys don't need to be released : they are handled as "events" and procesed only once.
|
||||||
// These clicks are apart because they need to be continuous (ie move while key pressed)
|
// These clicks are apart because they need to be continuous (ie move while key pressed)
|
||||||
// We are relying on "hardware" keyrepeat to achieve that.
|
// We are relying on "hardware" keyrepeat to achieve that.
|
||||||
|
|||||||
@ -53,6 +53,10 @@ void Set_mouse_position(void);
|
|||||||
/// that will record and retrieve a real control ID.
|
/// that will record and retrieve a real control ID.
|
||||||
extern int Input_sticky_control;
|
extern int Input_sticky_control;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// State of the shortcut for panning (SPECIAL_HOLD_PAN) : pressed or not.
|
||||||
|
extern byte Pan_shortcut_pressed;
|
||||||
|
|
||||||
/// Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically.
|
/// Allows locking movement to X or Y axis: 0=normal, 1=lock on next move, 2=locked horizontally, 3=locked vertically.
|
||||||
extern int Snap_axis;
|
extern int Snap_axis;
|
||||||
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
/// For the :Snap_axis mode, sets the origin's point (in image coordinates)
|
||||||
|
|||||||
@ -70,6 +70,7 @@ void Start_operation_stack(word new_operation)
|
|||||||
case OPERATION_GRAB_BRUSH:
|
case OPERATION_GRAB_BRUSH:
|
||||||
case OPERATION_POLYBRUSH:
|
case OPERATION_POLYBRUSH:
|
||||||
case OPERATION_STRETCH_BRUSH:
|
case OPERATION_STRETCH_BRUSH:
|
||||||
|
case OPERATION_PAN_VIEW:
|
||||||
Operation_before_interrupt=Current_operation;
|
Operation_before_interrupt=Current_operation;
|
||||||
// On passe à l'operation demandée
|
// On passe à l'operation demandée
|
||||||
Current_operation=new_operation;
|
Current_operation=new_operation;
|
||||||
@ -4031,3 +4032,92 @@ void Centered_lines_0_7(void)
|
|||||||
Operation_push(Paintbrush_Y);
|
Operation_push(Paintbrush_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////// OPERATION_PAN_VIEW
|
||||||
|
|
||||||
|
void Pan_view_0_0(void)
|
||||||
|
// Opération : OPERATION_PAN_VIEW
|
||||||
|
// Click Souris: 0
|
||||||
|
// Taille_Pile : 0
|
||||||
|
//
|
||||||
|
// Souris effacée: Non
|
||||||
|
{
|
||||||
|
if (Pan_shortcut_pressed)
|
||||||
|
{
|
||||||
|
Print_coordinates();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// End of operation, return to previous
|
||||||
|
Hide_cursor();
|
||||||
|
Start_operation_stack(Operation_before_interrupt);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pan_view_12_0(void)
|
||||||
|
// Opération : OPERATION_PAN_VIEW
|
||||||
|
// Click Souris: 1 ou 2
|
||||||
|
// Taille_Pile : 0
|
||||||
|
//
|
||||||
|
// Souris effacée: Non
|
||||||
|
|
||||||
|
// First time the user clicks
|
||||||
|
{
|
||||||
|
Init_start_operation();
|
||||||
|
|
||||||
|
Operation_push(Paintbrush_X);
|
||||||
|
Operation_push(Paintbrush_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pan_view_12_2(void)
|
||||||
|
// Opération : OPERATION_PAN_VIEW
|
||||||
|
// Click Souris: 1 ou 2
|
||||||
|
// Taille_Pile : 2
|
||||||
|
//
|
||||||
|
// Souris effacée: Non
|
||||||
|
|
||||||
|
// While dragging view
|
||||||
|
{
|
||||||
|
short start_x;
|
||||||
|
short start_y;
|
||||||
|
|
||||||
|
Operation_pop(&start_y);
|
||||||
|
Operation_pop(&start_x);
|
||||||
|
|
||||||
|
if (Paintbrush_X!=start_x || Paintbrush_Y!=start_y)
|
||||||
|
{
|
||||||
|
// User moved
|
||||||
|
if (Main_magnifier_mode)
|
||||||
|
Scroll_magnifier(start_x-Paintbrush_X,start_y-Paintbrush_Y);
|
||||||
|
else
|
||||||
|
Scroll_screen(start_x-Paintbrush_X,start_y-Paintbrush_Y);
|
||||||
|
}
|
||||||
|
// The "scroll" functions have actualized the Paintbrush_X and Y
|
||||||
|
|
||||||
|
Operation_push(Paintbrush_X);
|
||||||
|
Operation_push(Paintbrush_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pan_view_0_2(void)
|
||||||
|
// Opération : OPERATION_PAN_VIEW
|
||||||
|
// Click Souris: 0
|
||||||
|
// Taille_Pile : 2
|
||||||
|
//
|
||||||
|
// Souris effacée: Non
|
||||||
|
|
||||||
|
// When releasing after dragging
|
||||||
|
{
|
||||||
|
short start_x;
|
||||||
|
short start_y;
|
||||||
|
|
||||||
|
Operation_pop(&start_y);
|
||||||
|
Operation_pop(&start_x);
|
||||||
|
|
||||||
|
if (!Pan_shortcut_pressed)
|
||||||
|
{
|
||||||
|
// End of operation, return to previous
|
||||||
|
Hide_cursor();
|
||||||
|
Start_operation_stack(Operation_before_interrupt);
|
||||||
|
Display_cursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -230,3 +230,10 @@ void Centered_lines_0_7(void);
|
|||||||
byte Rightclick_colorpick(byte cursor_visible);
|
byte Rightclick_colorpick(byte cursor_visible);
|
||||||
void Rightclick_colorpick_2_1(void);
|
void Rightclick_colorpick_2_1(void);
|
||||||
void Rightclick_colorpick_0_1(void);
|
void Rightclick_colorpick_0_1(void);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////// OPERATION_PAN_VIEW
|
||||||
|
|
||||||
|
void Pan_view_0_0(void);
|
||||||
|
void Pan_view_12_0(void);
|
||||||
|
void Pan_view_12_2(void);
|
||||||
|
void Pan_view_0_2(void);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user