Example #1
0
void CGUIControlButtonSetting::OnSliderChange(void *data, CGUISliderControl *slider)
{
  if (slider == NULL)
    return;

  std::string strText;
  switch (m_pSetting->GetType())
  {
    case SettingTypeInteger:
    {
      CSettingInt *settingInt = static_cast<CSettingInt*>(m_pSetting);
      if (settingInt->SetValue(slider->GetIntValue()))
        strText = CGUIControlSliderSetting::GetText(static_cast<const CSettingControlSlider*>(m_pSetting->GetControl()),
          settingInt->GetValue(), settingInt->GetMinimum(), settingInt->GetStep(), settingInt->GetMaximum());
      break;
    }

    case SettingTypeNumber:
    {
      CSettingNumber *settingNumber = static_cast<CSettingNumber*>(m_pSetting);
      if (settingNumber->SetValue(static_cast<double>(slider->GetFloatValue())))
        strText = CGUIControlSliderSetting::GetText(static_cast<const CSettingControlSlider*>(m_pSetting->GetControl()),
          settingNumber->GetValue(), settingNumber->GetMinimum(), settingNumber->GetStep(), settingNumber->GetMaximum());
      break;
    }
    
    default:
      break;
  }

  if (!strText.empty())
    slider->SetTextValue(strText);
}
Example #2
0
bool CPeripheral::SetSetting(const CStdString &strKey, float fValue)
{
  bool bChanged(false);
  map<CStdString, CSetting *>::iterator it = m_settings.find(strKey);
  if (it != m_settings.end() && (*it).second->GetType() == SettingTypeNumber)
  {
      CSettingNumber *floatSetting = (CSettingNumber *) (*it).second;
    if (floatSetting)
    {
      bChanged = floatSetting->GetValue() != fValue;
      floatSetting->SetValue(fValue);
      if (bChanged && m_bInitialised)
        m_changedSettings.insert(strKey);
    }
  }
  return bChanged;
}