SliceO_Class::Interface_Motion

 

This method is called by sliceOmatic when the user move the mouse inside one of the 2D windows.

 

 

Syntax

 

int  Interface_Motion(

          SliceO_Window * window,

          int up_down,

          Point_2D * mouse_inf

) ;

 

 

Parameters

 

window

                    Pointer to the window where the event has occurred.

 

up_down

          is an image of the 3 mouse button states. The lower byte contain a code giving the mouse button action (off, on, pressed or double clicked).  The next byte give the state of each of the 3 keys as on or off. The different values for the variable are:

 

KEY_DBLCLK          3

KEY_PRESS          2

KEY_ON          1

KEY_OFF          0

MOUSE_KEY_LEFT          0x010

MOUSE_KEY_MIDDLE          0x020

MOUSE_KEY_RIGHT          0x040

 

So, for example, if you click on the left mouse button, the value of up_down will be (KEY_PRESS | MOUSE_KEY_LEFT). When you release the button the value will be KEY_OFF.

 

mouse_inf

                    Position of the cursor in infinite space.

 

 

Return value

 

This method return "1" if it use the event.

 

 

Remarks

 

The method is responsible for calling the "Motion" method for all its children.  The following lines must be included at the end of the method:

 

...

// --- 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 ) ;

 

// --- we did not use this click ---

return( 0 ) ;

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Default method for SliceO_Class::Interface_Motion.

 

// ----------------------------------------------------------------------------

//

//          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 ) ;

}

 

See also