Example #1
0
void CGUISliderControl::Move(int iNumSteps)
{
  bool rangeSwap = false;
  switch (m_iType)
  {
  case SLIDER_CONTROL_TYPE_FLOAT:
    {
      float &value = m_floatValues[m_currentSelector];
      value += m_fInterval * iNumSteps;
      if (value < m_fStart) value = m_fStart;
      if (value > m_fEnd) value = m_fEnd;
      if (m_floatValues[0] > m_floatValues[1])
      {
        float valueLower = m_floatValues[0];
        m_floatValues[0] = m_floatValues[1];
        m_floatValues[1] = valueLower;
        rangeSwap = true;
      }
      break;
    }

  case SLIDER_CONTROL_TYPE_INT:
    {
      int &value = m_intValues[m_currentSelector];
      value += m_iInterval * iNumSteps;
      if (value < m_iStart) value = m_iStart;
      if (value > m_iEnd) value = m_iEnd;
      if (m_intValues[0] > m_intValues[1])
      {
        int valueLower = m_intValues[0];
        m_intValues[0] = m_intValues[1];
        m_intValues[1] = valueLower;
        rangeSwap = true;
      }
      break;
    }

  case SLIDER_CONTROL_TYPE_PERCENTAGE:
  default:
    {
      float &value = m_percentValues[m_currentSelector];
      value += m_iInterval * iNumSteps;
      if (value < 0) value = 0;
      if (value > 100) value = 100;
      if (m_percentValues[0] > m_percentValues[1])
      {
        float valueLower = m_percentValues[0];
        m_percentValues[0] = m_percentValues[1];
        m_percentValues[1] = valueLower;
        rangeSwap = true;
      }
      break;
    }
  }

  if (rangeSwap)
    SwitchRangeSelector();

  SendClick();
}
Example #2
0
bool CGUISliderControl::OnAction(const CAction &action)
{
  switch ( action.GetID() )
  {
  case ACTION_MOVE_LEFT:
    //case ACTION_OSD_SHOW_VALUE_MIN:
    Move(-1);
    return true;

  case ACTION_MOVE_RIGHT:
    //case ACTION_OSD_SHOW_VALUE_PLUS:
    Move(1);
    return true;

  case ACTION_SELECT_ITEM:
    // switch between the two sliders
    SwitchRangeSelector();
    return true;

  default:
    break;
  }

  return CGUIControl::OnAction(action);
}
Example #3
0
bool CGUISliderControl::OnAction(const CAction &action)
{
  switch ( action.GetID() )
  {
  case ACTION_MOVE_LEFT:
    if (IsActive() && m_orientation == HORIZONTAL)
    {
      Move(-1);
      return true;
    }
    break;

  case ACTION_MOVE_RIGHT:
    if (IsActive() && m_orientation == HORIZONTAL)
    {
      Move(1);
      return true;
    }
    break;

  case ACTION_MOVE_UP:
    if (IsActive() && m_orientation == VERTICAL)
    {
      Move(1);
      return true;
    }
    break;

  case ACTION_MOVE_DOWN:
    if (IsActive() && m_orientation == VERTICAL)
    {
      Move(-1);
      return true;
    }
    break;

  case ACTION_SELECT_ITEM:
    if (m_rangeSelection)
      SwitchRangeSelector();
    return true;

  default:
    break;
  }
  return CGUIControl::OnAction(action);
}