Exemple #1
0
int    GLUI_Spinner::mouse_down_handler( int local_x, int local_y )
{
  this->state = find_arrow( local_x, local_y );
  GLUI_Master.glui_setIdleFuncIfNecessary();

  /*  printf( "spinner: mouse down  : %d/%d   arrow:%d\n", local_x, local_y,
      find_arrow( local_x, local_y ));
      */

  if ( state != GLUI_SPINNER_STATE_UP AND state != GLUI_SPINNER_STATE_DOWN )
    return true;

  reset_growth();
  redraw();  

  /*** ints and floats behave a bit differently.  When you click on
    an int spinner, you expect the value to immediately go up by 1, whereas
    for a float it'll go up only by a fractional amount.  Therefore, we
    go ahead and increment by one for int spinners ***/
  if ( data_type == GLUI_SPINNER_INT ) {
    if ( state == GLUI_SPINNER_STATE_UP )
      edittext->set_float_val( edittext->float_val + 1.0 );
    else if ( state == GLUI_SPINNER_STATE_DOWN )
      edittext->set_float_val( edittext->float_val - .9 );
  }
  
  do_click();  
  
  return false;
}
Exemple #2
0
int    GLUI_Scrollbar::mouse_held_down_handler( int local_x, int local_y,
                                                bool new_inside)
{
  int new_state;
  if ( state == GLUI_SCROLL_STATE_NONE )
    return false;

  /*  printf("spinner: mouse held: %d/%d    inside: %d\n",local_x,local_y,
      new_inside);
  */

  if ( state == GLUI_SCROLL_STATE_SCROLL) {   /* dragging? */
    do_drag( local_x-x_abs, local_y-y_abs );
  }
  else {                                      /* not dragging */
    new_state = find_arrow( local_x, local_y );

    if ( new_state == state ) {
      /** Still in same arrow **/
      do_click();
    }
  }
  redraw();

  return false;
}
Exemple #3
0
int    GLUI_Spinner::mouse_held_down_handler( int local_x, int local_y,
                          int new_inside)
{
  int new_state;

  if ( state == GLUI_SPINNER_STATE_NONE )
    return false;

  /*  printf("spinner: mouse held: %d/%d    inside: %d\n",local_x,local_y,
      new_inside);
      */

  if ( state == GLUI_SPINNER_STATE_BOTH ) {   /* dragging? */
    do_drag( local_x, local_y );
  }
  else {                                      /* not dragging */
    new_state = find_arrow( local_x, local_y );
    
    if ( new_state == state ) {
      /** Still in same arrow **/
      do_click();
    }
    else {
      if ( new_inside OR 1) {
    /** The state changed, but we're still inside - that
      means we moved off the arrow: begin dragging **/
    state = GLUI_SPINNER_STATE_BOTH;
      }
      else {
    /*** Here check y of mouse position to determine whether to 
      drag ***/

    /* ... */
      }
    }

    /*** We switched to up/down dragging ***/
    if ( state == GLUI_SPINNER_STATE_BOTH ) {
      glutSetCursor( GLUT_CURSOR_UP_DOWN );
      last_x = local_x;
      last_y = local_y;

      /** If the spinner has limits, we reset the growth value, since
    reset_growth() will compute a new growth value for dragging
    vs. clicking.  If the spinner has no limits, then we just let the
    growth remain at whatever the user has incremented it up to **/
      if ( edittext->has_limits != GLUI_LIMIT_NONE )
    reset_growth();
    }

    if ( can_draw() )
      draw_arrows();
  }

  return false;
}
Exemple #4
0
/**
 * Find an arrow in the inventory and after that in the right type
 * container (quiver).
 * @param op Object to check.
 * @param type Ammunition type (bolts, arrows, etc).
 * @return Pointer to the found object, NULL if not found. */
object *find_arrow(object *op, const char *type)
{
	object *tmp = NULL;

	for (op = op->inv; op; op = op->below)
	{
		if (!tmp && op->type == CONTAINER && op->race == type && QUERY_FLAG(op, FLAG_APPLIED))
		{
			tmp = find_arrow(op, type);
		}
		else if (op->type == ARROW && op->race == type)
		{
			return op;
		}
	}

	return tmp;
}
Exemple #5
0
int    GLUI_Scrollbar::mouse_down_handler( int local_x, int local_y )
{
  last_update_time=GLUI_Time()-1.0;
  this->state = find_arrow( local_x, local_y );
  GLUI_Master.glui_setIdleFuncIfNecessary();

  /*  printf( "spinner: mouse down  : %d/%d   arrow:%d\n", local_x, local_y,
      find_arrow( local_x, local_y ));
      */

  if ( state != GLUI_SCROLL_STATE_UP AND state != GLUI_SCROLL_STATE_DOWN)
    return true;

  reset_growth();

  /*** ints and floats behave a bit differently.  When you click on
    an int spinner, you expect the value to immediately go up by 1, whereas
    for a float it'll go up only by a fractional amount.  Therefore, we
    go ahead and increment by one for int spinners ***/
#if 1
  if ( data_type == GLUI_SCROLL_INT ) {
    // Allow for possibility of reversed limits
    int lo = std::min(int_min,int_max);
    int hi = std::max(int_min,int_max);
    int increase = int_min < int_max ? 1 : -1;
    int new_val = int_val;
    if ( state == GLUI_SCROLL_STATE_UP ) {
      new_val += increase;
    } else if ( state == GLUI_SCROLL_STATE_DOWN ) {
      new_val -= increase;
    }
    if (new_val >= lo && new_val <= hi && new_val!=int_val) {
      set_int_val(new_val);
      do_callbacks();
    }
  }
#endif
  do_click();
  redraw();

  return false;
}