Example #1
0
void QDial::mouseMoveEvent( QMouseEvent * e )
{
    if ( !d->mousePressed )
	return;
    if ( !d->tracking || (e->state() & LeftButton) == 0 )
	return;
    d->doNotEmit = TRUE;
    setValue( valueFromPoint( e->pos() ) );
    emit dialMoved( value() );
    d->doNotEmit = FALSE;
}
bool QDial::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: valueChanged((int)static_QUType_int.get(_o+1)); break;
    case 1: dialPressed(); break;
    case 2: dialMoved((int)static_QUType_int.get(_o+1)); break;
    case 3: dialReleased(); break;
    default:
	return QWidget::qt_emit(_id,_o);
    }
    return TRUE;
}
Example #3
0
void UI_Flywheel::wheel_rotate(void)
{
  int h, cumulative_pixels=0;

  double circum;


  t2->start(100);

  h = height();

  circum = (M_PI * (double)h);

  if(use_move_events && (!spinning))
  {
    wheel_position += (((M_PI * 2.0) / (circum / (double)mouse_delta_y)) + (M_PI * 2.0));

    while(wheel_position >= (M_PI * 2.0))
    {
      wheel_position -= (M_PI * 2.0);
    }

    while(wheel_position < 0.0)
    {
      wheel_position += (M_PI * 2.0);
    }

    cumulative_pixels = mouse_delta_y;
  }

  if(spinning)
  {
    if(dial_speed)
    {
      wheel_position += ((M_PI * 2.0) / (circum / ((double)dial_speed / 25.0)));

      cumulative_pixels = (double)dial_speed / 25.0;

      while(wheel_position >= (M_PI * 2.0))
      {
        wheel_position -= (M_PI * 2.0);
      }

      while(wheel_position < 0.0)
      {
        wheel_position += (M_PI * 2.0);
      }

      if(holdoff)
      {
        holdoff--;
      }
      else
      {
        if(dial_speed > 0)
        {
          dial_speed -= 25;

          if(dial_speed < 0)
          {
            dial_speed = 0;
          }
        }
        else
        {
          dial_speed += 25;

          if(dial_speed > 0)
          {
            dial_speed = 0;
          }
        }

        if((dial_speed < 500) && (dial_speed > -500))
        {
          if((dial_speed < 125) && (dial_speed > -125))
          {
            holdoff = 6;
          }
          else
          {
            holdoff = 3;
          }
        }
      }
    }

    if(dial_speed == 0)
    {
      t1->stop();

      spinning = 0;
    }
  }

  update();

  emit dialMoved(cumulative_pixels);
}