void CGUIControlSpinExSetting::FillControl()
{
  m_pSpin->Clear();

  switch (m_pSetting->GetControl().GetFormat())
  {
    case SettingControlFormatNumber:
    {
      CSettingNumber *pSettingNumber = (CSettingNumber *)m_pSetting;
      m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT);
      m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum());
      m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep());

      m_pSpin->SetFloatValue((float)pSettingNumber->GetValue());
      break;
    }

    case SettingControlFormatInteger:
    {
      m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT);
      FillIntegerSettingControl();
      break;
    }

    case SettingControlFormatString:
    {
      m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT);

      if (m_pSetting->GetType() == SettingTypeInteger)
        FillIntegerSettingControl();
      else if (m_pSetting->GetType() == SettingTypeString)
      {
        CSettingString *pSettingString = (CSettingString *)m_pSetting;
        if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic)
        {
          DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions();
          for (std::vector< std::pair<std::string, std::string> >::const_iterator option = options.begin(); option != options.end(); ++option)
            m_pSpin->AddLabel(option->first, option->second);

          m_pSpin->SetStringValue(pSettingString->GetValue());
        }
      }
      break;
    }

    default:
      break;
  }
}
Beispiel #2
0
void CGUIControlSpinExSetting::FillControl()
{
  if (m_pSpin == NULL)
    return;

  m_pSpin->Clear();

  const std::string &controlFormat = m_pSetting->GetControl()->GetFormat();
  if (controlFormat == "number")
  {
    CSettingNumber *pSettingNumber = (CSettingNumber *)m_pSetting;
    m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT);
    m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum());
    m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep());

    m_pSpin->SetFloatValue((float)pSettingNumber->GetValue());
  }
  else if (controlFormat == "integer")
  {
    m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT);
    FillIntegerSettingControl();
  }
  else if (controlFormat == "string")
  {
    m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT);

    if (m_pSetting->GetType() == SettingTypeInteger)
      FillIntegerSettingControl();
    else if (m_pSetting->GetType() == SettingTypeString)
    {
      DynamicStringSettingOptions options;
      std::set<std::string> selectedValues;
      // get the string options
      if (!GetStringOptions(m_pSetting, options, selectedValues) || selectedValues.size() != 1)
        return;

      // add them to the spinner
      for (const auto& option : options)
        m_pSpin->AddLabel(option.first, option.second);

      // and set the current value
      m_pSpin->SetStringValue(*selectedValues.begin());
    }
  }
}
Beispiel #3
0
CGUIControlSliderSetting::CGUIControlSliderSetting(CGUISettingsSliderControl *pSlider, int id, CSetting *pSetting)
  : CGUIControlBaseSetting(id, pSetting)
{
  m_pSlider = pSlider;
  if (m_pSlider == NULL)
    return;

  m_pSlider->SetID(id);
  
  switch (m_pSetting->GetType())
  {
    case SettingTypeInteger:
    {
      CSettingInt *settingInt = static_cast<CSettingInt*>(m_pSetting);
      if (m_pSetting->GetControl()->GetFormat() == "percentage")
        m_pSlider->SetType(SLIDER_CONTROL_TYPE_PERCENTAGE);
      else
      {
        m_pSlider->SetType(SLIDER_CONTROL_TYPE_INT);
        m_pSlider->SetRange(settingInt->GetMinimum(), settingInt->GetMaximum());
      }
      m_pSlider->SetIntInterval(settingInt->GetStep());
      break;
    }

    case SettingTypeNumber:
    {
      CSettingNumber *settingNumber = static_cast<CSettingNumber*>(m_pSetting);
      m_pSlider->SetType(SLIDER_CONTROL_TYPE_FLOAT);
      m_pSlider->SetFloatRange((float)settingNumber->GetMinimum(), (float)settingNumber->GetMaximum());
      m_pSlider->SetFloatInterval((float)settingNumber->GetStep());
      break;
    }

    default:
      break;
  }

  Update();
}
Beispiel #4
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);
}
Beispiel #5
0
bool CGUIControlButtonSetting::OnClick()
{
  if (m_pButton == NULL)
    return false;
  
  const ISettingControl *control = m_pSetting->GetControl();
  const std::string &controlType = control->GetType();
  const std::string &controlFormat = control->GetFormat();
  if (controlType == "button")
  {
    const CSettingControlButton *buttonControl = static_cast<const CSettingControlButton*>(control);
    if (controlFormat == "addon")
    {
      // prompt for the addon
      CSettingAddon *setting = (CSettingAddon *)m_pSetting;
      std::string addonID = setting->GetValue();
      if (CGUIWindowAddonBrowser::SelectAddonID(setting->GetAddonType(), addonID, setting->AllowEmpty(),
                                                buttonControl->ShowAddonDetails(), buttonControl->ShowInstalledAddons(),
                                                buttonControl->ShowInstallableAddons(), buttonControl->ShowMoreAddons()) != 1)
        return false;

      SetValid(setting->SetValue(addonID));
    }
    else if (controlFormat == "path")
      SetValid(GetPath((CSettingPath *)m_pSetting));
    else if (controlFormat == "action")
    {
      // simply call the OnSettingAction callback and whoever knows what to
      // do can do so (based on the setting's identification
      CSettingAction *pSettingAction = (CSettingAction *)m_pSetting;
      pSettingAction->OnSettingAction(pSettingAction);
      SetValid(true);
    }
  }
  else if (controlType == "slider")
  {
    float value, min, step, max;
    if (m_pSetting->GetType() == SettingTypeInteger)
    {
      CSettingInt *settingInt = static_cast<CSettingInt*>(m_pSetting);
      value = (float)settingInt->GetValue();
      min = (float)settingInt->GetMinimum();
      step = (float)settingInt->GetStep();
      max = (float)settingInt->GetMaximum();
    }
    else if (m_pSetting->GetType() == SettingTypeNumber)
    {
      CSettingNumber *settingNumber = static_cast<CSettingNumber*>(m_pSetting);
      value = (float)settingNumber->GetValue();
      min = (float)settingNumber->GetMinimum();
      step = (float)settingNumber->GetStep();
      max = (float)settingNumber->GetMaximum();
    }
    else
      return false;

    const CSettingControlSlider *sliderControl = static_cast<const CSettingControlSlider*>(control);
    CGUIDialogSlider::ShowAndGetInput(g_localizeStrings.Get(sliderControl->GetHeading()), value, min, step, max, this, NULL);
    SetValid(true);
  }

  return IsValid();
}
void CGUIDialogPeripheralSettings::CreateSettings()
{
  m_bIsInitialising = true;
  m_usePopupSliders = g_SkinInfo->HasSkinFile("DialogSlider.xml");

  if (m_item)
  {
    CPeripheral *peripheral = g_peripherals.GetByPath(m_item->GetPath());
    if (peripheral)
    {
      vector<CSetting *> settings = peripheral->GetSettings();
      for (size_t iPtr = 0; iPtr < settings.size(); iPtr++)
      {
        CSetting *setting = settings[iPtr];
        if (!setting->IsVisible())
        {
          CLog::Log(LOGDEBUG, "%s - invisible", __FUNCTION__);
          continue;
        }

        switch(setting->GetType())
        {
        case SettingTypeBool:
          {
            CSettingBool *boolSetting = (CSettingBool *) setting;
            if (boolSetting)
            {
              m_boolSettings.insert(make_pair(CStdString(boolSetting->GetId()), boolSetting->GetValue()));
              AddBool(m_settingId++, boolSetting->GetLabel(), &m_boolSettings[boolSetting->GetId()], true);
            }
          }
          break;
        case SettingTypeInteger:
          {
            CSettingInt *intSetting = (CSettingInt *) setting;
            if (intSetting)
            {
              if (intSetting->GetControl()->GetFormat() == "integer")
              {
                m_intSettings.insert(make_pair(CStdString(intSetting->GetId()), (float) intSetting->GetValue()));
                AddSlider(m_settingId++, intSetting->GetLabel(), &m_intSettings[intSetting->GetId()], (float)intSetting->GetMinimum(), (float)intSetting->GetStep(), (float)intSetting->GetMaximum(), CGUIDialogVideoSettings::FormatInteger, false);
              }
              else if (intSetting->GetControl()->GetFormat() == "string")
              {
                m_intTextSettings.insert(make_pair(CStdString(intSetting->GetId()), intSetting->GetValue()));
                vector<pair<int, int> > entries;
                StaticIntegerSettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin();
                while (entriesItr != intSetting->GetOptions().end())
                {
                  entries.push_back(make_pair(entriesItr->first, entriesItr->second));
                  ++entriesItr;
                }
                AddSpin(m_settingId++, intSetting->GetLabel(), &m_intTextSettings[intSetting->GetId()], entries);
              }
            }
          }
          break;
        case SettingTypeNumber:
          {
            CSettingNumber *floatSetting = (CSettingNumber *) setting;
            if (floatSetting)
            {
              m_floatSettings.insert(make_pair(CStdString(floatSetting->GetId()), (float)floatSetting->GetValue()));
              AddSlider(m_settingId++, floatSetting->GetLabel(), &m_floatSettings[floatSetting->GetId()], (float)floatSetting->GetMinimum(), (float)floatSetting->GetStep(), (float)floatSetting->GetMaximum(), CGUIDialogVideoSettings::FormatFloat, false);
            }
          }
          break;
        case SettingTypeString:
          {
            CSettingString *stringSetting = (CSettingString *) setting;
            if (stringSetting)
            {
              m_stringSettings.insert(make_pair(CStdString(stringSetting->GetId()), stringSetting->GetValue()));
              AddString(m_settingId++, stringSetting->GetLabel(), &m_stringSettings[stringSetting->GetId()]);
            }
          }
          break;
        default:
          //TODO add more types if needed
          CLog::Log(LOGDEBUG, "%s - unknown type", __FUNCTION__);
          break;
        }
      }
    }
    else
    {
      CLog::Log(LOGDEBUG, "%s - no peripheral", __FUNCTION__);
    }
  }

  m_bIsInitialising = false;
}