Exemplo n.º 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;
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
void    GLUI_Spinner::idle( void )
{
  if ( NOT needs_idle() )
    return;
  else
    do_click();
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
0
static void CALLBACK ClickProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
    HWND window = find_window();

    if (!window)
    {
        if (g_untildeath)
        {
            /* FIXME: The window / control might just be disabled and if
             * that's the case we should not exit yet. But I don't expect
             * --untildeath to be used at all anyway so fixing this can
             * wait until it becomes necessary.
             */
            status=RC_SUCCESS;
        }
        else
            cxlog("The window has disappeared!\n");
        return;
    }

    switch (g_action)
    {
    case ACTION_FIND:
        /* Nothing to do */
        break;
    case ACTION_LCLICK:
        cxlog("Sending left click\n");
        do_click(window, MOUSEEVENTF_LEFTDOWN, MOUSEEVENTF_LEFTUP);
        break;
    case ACTION_MCLICK:
        cxlog("Sending middle click\n");
        do_click(window, MOUSEEVENTF_MIDDLEDOWN, MOUSEEVENTF_MIDDLEUP);
        break;
    case ACTION_RCLICK:
        cxlog("Sending right click\n");
        do_click(window, MOUSEEVENTF_RIGHTDOWN, MOUSEEVENTF_RIGHTUP);
    default:
        fprintf(stderr, "error: unknown action %d\n", g_action);
        break;
    }
    if (!g_repeat)
        status=RC_SUCCESS;
}
Exemplo n.º 6
0
static void CALLBACK FindWindowProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
    HWND window = find_window();
    if (!window)
        return;

    cxlog("Found the window\n");
    if (g_delay)
    {
        cxlog("Waiting for a bit\n");
        KillTimer(NULL, timer_id);
        timer_id=SetTimer(NULL, 0, g_delay, DelayProc);
        do_click(window, 0,0);
    }
    else
    {
        DelayProc(NULL, 0, 0, 0);
    }
}
Exemplo n.º 7
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;
}
Exemplo n.º 8
0
    bool mouse_click_listener_base::process_event(const SDL_Event& event, bool claimed) {
        if(claimed) {
            click_count_ = 0;
            clicked_ = false;
            return claimed;
        }

        switch(event.type) {
        case SDL_MOUSEMOTION:
            pos_[0] = event.motion.x;
            pos_[1] = event.motion.y;
            state_ = event.motion.state;
            button_state_ = 0;
            mod_ = SDL_GetModState();
            break;
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
            pos_[0] = event.button.x;
            pos_[1] = event.button.y;
            state_ = SDL_GetMouseState(NULL,NULL);
            mod_ = SDL_GetModState();
            button_state_ = get_button_change_state(event.button.button);
            if(event.type == SDL_MOUSEBUTTONDOWN) {
                state_ |= button_state_;
            }
            break;
        default:
            return claimed;
        }
        
        /* this handles exiting from a click */
        if(!matches_target_state(state_)) {
            if(clicked_) {
                click_time_ = SDL_GetTicks();
                clicked_ = false;
                do_click(pos_[0], pos_[1], click_count_, state_, button_state_, mod_);
            }
            return claimed;
        }

        switch(event.type) {
        case SDL_MOUSEMOTION:
            /* next continuing in a click - claim motion events
               whilst clicking */
            if(clicked_) {
                claimed = true;
            }
            break;
        case SDL_MOUSEBUTTONDOWN:
            /* finally beginning a click */
            if(!clicked_ && matches_target_mod(mod_)) {
                /* to start a click, we must be in the target area */
                if(target_area_enabled() && !in_target_area(pos_[0], pos_[1])) {
                    break;
                }
                clicked_ = true;
                Uint32 curtime = SDL_GetTicks();
                if(click_count_ > 0 && 
                   curtime - click_time_ >= click_timeout_) {
                    click_count_ = 0;
                }
                click_count_++;
                claimed = true;
            }
            break;
        default:
            break;
        }
        
        return claimed;
    }