Exemple #1
0
/*! 
  callback for mouse button events

  \return  None
  \author  jfpatry
  \date    Created:  2000-09-16
  \date    Modified: 2000-09-16
*/
void ui_event_mouse_func( int button, int state, int x, int y )
{
    if ( is_mode_change_pending() ) {
	/* Don't process events until mode change occurs */
	return;
    }

    /* Reverse y coordinate */
    y = getparam_y_resolution() - y;

    if ( state == WS_MOUSE_DOWN ) {
	trigger_mouse_button_cbs( mouse_down_cbs, button, x, y );
    } else {
	trigger_mouse_button_cbs( mouse_up_cbs, button, x, y );
    }

    if ( button == WS_LEFT_BUTTON ) {
	left_mouse_button_down = (bool_t) ( state == WS_MOUSE_DOWN );
    }
    if ( button == WS_MIDDLE_BUTTON ) {
	middle_mouse_button_down = (bool_t) ( state == WS_MOUSE_DOWN );
    }
    if ( button == WS_RIGHT_BUTTON ) {
	right_mouse_button_down = (bool_t) ( state == WS_MOUSE_DOWN );
    }

    ui_check_dirty();
}
Exemple #2
0
/*! 
  Draws all UI widgets
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-17
  \date    Modified: 2000-09-17
*/
void ui_draw( )
{
    hash_search_t iter;
    ui_callback_data_t *cb_data;

    ui_setup_display();

    begin_hash_scan( widget_draw_cbs, &iter );
    while ( next_hash_entry( iter, NULL, (hash_entry_t*)&cb_data ) ) {
	((widget_draw_cb_t)cb_data->cb)( cb_data->widget );
	check_assertion( !is_mode_change_pending(),
			 "widget draw callback changed the mode" );
    }
    end_hash_scan( iter );

    ui_draw_cursor();
}
Exemple #3
0
/*! 
  Calls all registered mouse motion callbacks 
  \arg \c  table the table storing callback data
  \arg \c  x x coordinate of mouse
  \arg \c  y y coordinate of mouse

  \return  None
  \author  jfpatry
  \date    Created:  2000-09-16
  \date    Modified: 2000-09-16
*/
static void trigger_mouse_motion_cbs( hash_table_t table, 
				      int x, int y )
{
    hash_search_t iter;
    ui_callback_data_t *cb_data;

    begin_hash_scan( table, &iter );
    while ( next_hash_entry( iter, NULL, (hash_entry_t*)&cb_data ) ) {
	((mouse_motion_event_cb_t)cb_data->cb)( 
	    cb_data->widget, x, y );

	if ( is_mode_change_pending() ) {
	    /* Callback just changed the mode; stop handling events
	       for this mode. */
	    break;
	}
    }
    end_hash_scan( iter );
}
Exemple #4
0
void
UIManager::motionEvent( int x, int y )
{
    if ( is_mode_change_pending() ) {
		// Don't process events until mode change occurs 
		return;
    }

    // Reverse y coordinate
    y = getparam_y_resolution() - y;
	
	std::list<pp::Widget*>::iterator it;
	
	for(it=widgets.begin();it!=widgets.end();it++){
		(*it)->mouseMotion(x,y);
	}
	
    pp::Vec2d oldPos = cursorPos;
    cursorPos = pp::Vec2d(x,y);

    if ( oldPos.x != x || oldPos.y != y ) {
		// Update UI snow 
		if ( getparam_ui_snow() ) {
			if ( rightMouseButtonDown ) {
				make_ui_snow( cursorPos );
				reset_ui_snow_cursor_pos( cursorPos );
			} else if ( middleMouseButtonDown ) {
				make_ui_snow( cursorPos );
				push_ui_snow( cursorPos );
			} else {
				push_ui_snow( cursorPos );
			}
		}

		// Need to redraw cursor
		setDirty();
		checkDirty();
    }
}
Exemple #5
0
/*! 
  callback for mouse motion events

  \return  None
  \author  jfpatry
  \date    Created:  2000-09-16
  \date    Modified: 2000-09-16
*/
void ui_event_motion_func( int x, int y )
{
    point2d_t old_pos;

    if ( is_mode_change_pending() ) {
	/* Don't process events until mode change occurs */
	return;
    }

    /* Reverse y coordinate */
    y = getparam_y_resolution() - y;

    trigger_mouse_motion_cbs( mouse_motion_cbs, x, y );

    old_pos = cursor_pos;
    cursor_pos = make_point2d( x, y );

    if ( old_pos.x != x || old_pos.y != y ) {
	/* Update UI snow */
	if ( getparam_ui_snow() ) {
	    if ( right_mouse_button_down ) {
		make_ui_snow( cursor_pos );
		reset_ui_snow_cursor_pos( cursor_pos );
	    } else if ( middle_mouse_button_down ) {
		make_ui_snow( cursor_pos );
		push_ui_snow( cursor_pos );
	    } else {
		push_ui_snow( cursor_pos );
	    }
	}

	/* Need to redraw cursor */
	ui_set_dirty();
	ui_check_dirty();
    }
}
Exemple #6
0
void 
UIManager::mouseEvent( int button, int state, int x, int y )
{
    if ( is_mode_change_pending() ) {
		// Don't process events until mode change occurs 
		return;
    }

    // Reverse y coordinate 
    y = getparam_y_resolution() - y;
	
	
	std::list<pp::Widget*>::iterator it;
	
	if ( state == SDL_PRESSED ) {
		for(it=widgets.begin();it!=widgets.end();it++){
			(*it)->mouseDown(button,x,y);
		}
	} else {
		for(it=widgets.begin();it!=widgets.end();it++){
			(*it)->mouseUp(button,x,y);
		}
	}

    if ( button == SDL_BUTTON_LEFT ) {
		leftMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }
    if ( button == SDL_BUTTON_MIDDLE ) {
		middleMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }
    if ( button == SDL_BUTTON_RIGHT ) {
		rightMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }

    checkDirty();
}