|
// ----------------------------------------------------------------------------
//
// Function: Ima_Click
//
// Parameters: up_down (int) state of the mouse buttons
// Returns: (int) 1 if action was used
//
// This is called each time the cursor is inside an image and the state
// of the mouse buttons has changed.
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ima_Click( HWND wnd, SliceO_Window *window, int up_down, short x, short y )
{
if ( ! up_down ) {
// --- stop recording ---
Undo_Pixel_TAG *pix_list = Undo_Pixel_Stop_TAG() ;
// --- if there's a list, add it to an undo structure ---
if ( pix_list ) {
unsigned int size = Undo_TAG_Size( pix_list ) ;
Undo_Save_Command( NULL, pix_list, "TAG Edit: Stroke \001(%s)", Int_2_Byte(size) ) ;
return( 1 ) ;
}
return( 0 ) ;
}
// --- get a pointer to the "current" frame ---
SliceO_Frame *Frame_Ovr = (SliceO_Frame *) Fct_Variable_Value( "$FRAME_OVR" ) ;
// --- only edit when over an image ---
if ( ! Frame_Ovr )
return( 0 ) ;
// --- only edit if the image is selected ---
if ( ! Frame_Ovr->Flag_Get_Bit( CLASS_MODE_THIS, window, CLASS_FLAG_SELECT ) )
return( 0 ) ;
// --- if we do not have an "erase" buffer, load it now ---
if ( ! Frame_Ovr->Erase_Get() )
Frame_Ovr->Erase_Load() ;
// --- start recording ---
Undo_Pixel_Start_TAG() ;
// --- we have the cursor in "Wnd" space, we want it in "Frm" space ---
Point_2D pos_wnd( COORD_WND, x, y ) ;
Point_2D pos_inf = window->Wnd_2_Inf( pos_wnd ) ;
Point_2D pos_frm = Frame_Ovr->Inf_2_Frm( window, pos_inf ) ;
// --- we do not want pixel fractions here ---
pos_frm[0] = (float) ((int) pos_frm[0]) ;
pos_frm[1] = (float) ((int) pos_frm[1]) ;
switch( up_down & MOUSE_KEY_MASK ) {
case MOUSE_KEY_LEFT :
Edit_Paint_Pix_Add( Frame_Ovr, &pos_frm ) ;
break ;
case MOUSE_KEY_RIGHT :
Edit_Paint_Pix_Erase( Frame_Ovr, &pos_frm ) ;
break ;
case MOUSE_KEY_LEFT | MOUSE_KEY_MIDDLE :
Edit_Paint_Full_Add( Frame_Ovr, &pos_frm ) ;
break ;
case MOUSE_KEY_RIGHT | MOUSE_KEY_MIDDLE :
Edit_Paint_Full_Erase( Frame_Ovr, &pos_frm ) ;
break ;
}
return( 1 ) ;
}
|