Ejemplo n.º 1
0
CSettingList* CGUIDialogSettingsManualBase::AddRange(CSettingGroup *group, const std::string &id, int label, int level, float valueLower, float valueUpper, float minimum,
                                                     float step, float maximum, const std::string &format, int formatLabel, int valueFormatLabel,
                                                     const std::string &valueFormatString, bool delayed, bool visible, int help)
{
  if (group == NULL || id.empty() || label < 0 ||
      GetSetting(id) != NULL)
    return NULL;

  CSettingNumber *settingDefinition = new CSettingNumber(id, m_settingsManager);
  if (settingDefinition == NULL)
    return NULL;
  
  settingDefinition->SetMinimum(minimum);
  settingDefinition->SetStep(step);
  settingDefinition->SetMaximum(maximum);

  CSettingList *setting = new CSettingList(id, settingDefinition, label, m_settingsManager);
  if (setting == NULL)
  {
    delete settingDefinition;
    return NULL;
  }

  std::vector<CVariant> valueList;
  valueList.push_back(valueLower);
  valueList.push_back(valueUpper);
  SettingPtrList settingValues;
  if (!CSettingUtils::ValuesToList(setting, valueList, settingValues))
  {
    delete settingDefinition;
    delete setting;
    return NULL;
  }
  // setting the default will also set the actual value on an unchanged setting
  setting->SetDefault(settingValues);
  
  setting->SetControl(GetRangeControl(format, delayed, formatLabel, valueFormatLabel, valueFormatString));
  setting->SetMinimumItems(2);
  setting->SetMaximumItems(2);

  setSettingDetails(setting, level, visible, help);

  group->AddSetting(setting);
  return setting;
}
Ejemplo n.º 2
0
CSettingNumber* CGUIDialogSettingsManualBase::AddSlider(CSettingGroup *group, const std::string &id, int label, int level, float value, const std::string &formatString,
                                                        float minimum, float step, float maximum, int heading /* = -1 */, bool usePopup /* = false */,
                                                        bool delayed /* = false */, bool visible /* = true */, int help /* = -1 */)
{
  if (group == NULL || id.empty() || label < 0 ||
      GetSetting(id) != NULL)
    return NULL;

  CSettingNumber *setting = new CSettingNumber(id, label, value, m_settingsManager);
  if (setting == NULL)
    return NULL;

  setting->SetControl(GetSliderControl("number", delayed, heading, usePopup, -1, formatString));
  setting->SetMinimum(minimum);
  setting->SetStep(step);
  setting->SetMaximum(maximum);
  setSettingDetails(setting, level, visible, help);

  group->AddSetting(setting);
  return setting;
}