|
// ----------------------------------------------------------------------------
//
// Interface_Motion()
//
// param: window (SliceO_Window *) The curent window
// up_down (int) state of the mouse buttons
// mouse inf (Point_2D *) mouse pos (in "Inf" coord)
//
// return: (int) 1 if this event has been used
//
// Note: this method is only called if up_down != 0
//
// ----------------------------------------------------------------------------
int SliceO_Class::Interface_Motion( SliceO_Window *window, int up_down, Point_2D *mouse_inf )
{
VALIDITY_TEST_CLASS( this, "SliceO_Class::Interface_Motion" ) ;
// --- if this element is not visible get out ---
if ( ! this->Flag_Get_Bit( CLASS_MODE_THIS, window, CLASS_FLAG_VISIBLE ) )
return( 0 ) ;
int a_x, a_y ;
a_x = (int) m_inside[window->Id_Get()].min_x - 2 ;
a_x += MODE_ALL_HORIZ_SPACING+1 ;
a_x += 24 ;
a_y = (int) m_inside[window->Id_Get()].min_y ;
Region_2D region_slider( COORD_INF, a_x, a_y, a_x+MODE_ALL_SLIDER_DIM_X, a_y+MODE_ALL_SLIDER_DIM_Y ) ;
// ====================================================================
// === The slider for display one and loop ===
// ====================================================================
switch( Flag_Get_Bit( CLASS_MODE_THIS, window, CLASS_MASK_DISPLAY ) ) {
case CLASS_FLAG_ONE :
// --- for display one, the slice selection slider on the right of the icon ---
if ( region_slider.Inside( mouse_inf ) ) {
float fact = (float) MODE_ALL_SLIDER_DIM_X / (float) Child_Get_Nb() ;
int val = (int) (*mouse_inf)[0] - a_x ;
val -= (int) (fact/2) ;
val = (int) ((float) val / fact) ;
val = CLIP( 0, val, Child_Get_Nb()-1 ) ;
Fct_Change_Child( window, Child_Get_Pt( val ) ) ;
return( 1 ) ;
}
break ;
case CLASS_FLAG_LOOP :
// --- for display one, the slice selection slider on the right of the icon ---
if ( region_slider.Inside( mouse_inf ) ) {
float fact = (float) MODE_ALL_SLIDER_DIM_X / (float) 30 ;
int val = (int) (*mouse_inf)[0] - a_x ;
val -= (int) (fact/2) ;
val = (int) ((float) val / fact) ;
val = CLIP( 0, val, 29 ) ;
m_fps[window->Id_Get()] = (unsigned short) val + 1 ;
// --- set the timer ---
Fct_Loop_Start( window, this ) ;
// -- we need to redraw this level ---
Fct_Redraw( REDRAW_DB_OPENGL_AND_UP, window, this ) ;
return( 1 ) ;
}
break ;
}
// --- does one of the children use this event ? ---
for ( int i=0; i < m_child_nb; i++ )
if ( m_child_pt[i]->Interface_Motion( window, up_down, mouse_inf ) )
return( 1 ) ;
// --- by default, we do not use this event ---
return( 0 ) ;
}
|