2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIDialogSettings.h"
22 #include "guilib/GUIEditControl.h"
23 #include "guilib/GUISpinControlEx.h"
24 #include "guilib/GUIRadioButtonControl.h"
25 #include "guilib/GUISettingsSliderControl.h"
26 #include "guilib/GUIImage.h"
27 #include "guilib/GUIControlGroupList.h"
28 #include "guilib/LocalizeStrings.h"
29 #include "utils/log.h"
30 #include "guilib/GUIKeyboardFactory.h"
32 #define CONTROL_GROUP_LIST 5
33 #define CONTROL_SETTINGS_LABEL 2
34 #define CONTROL_NONE_AVAILABLE 3
35 #define CONTROL_DEFAULT_BUTTON 7
36 #define CONTROL_DEFAULT_RADIOBUTTON 8
37 #define CONTROL_DEFAULT_SPIN 9
38 #define CONTROL_DEFAULT_SLIDER 10
39 #define CONTROL_DEFAULT_SEPARATOR 11
40 #define CONTROL_DEFAULT_EDIT 12
41 #define CONTROL_DEFAULT_EDIT_NUM 13
42 #define CONTROL_OKAY_BUTTON 28
43 #define CONTROL_CANCEL_BUTTON 29
44 #define CONTROL_START 30
45 #define CONTROL_PAGE 60
49 CGUIDialogSettings::CGUIDialogSettings(int id, const char *xmlFile)
50 : CGUIDialog(id, xmlFile)
52 m_pOriginalEdit = NULL;
53 m_pOriginalEditNum = NULL;
54 m_pOriginalSpin = NULL;
55 m_pOriginalRadioButton = NULL;
56 m_pOriginalSettingsButton = NULL;
57 m_pOriginalSlider = NULL;
58 m_pOriginalSeparator = NULL;
59 m_usePopupSliders = false;
60 m_loadType = KEEP_IN_MEMORY;
63 CGUIDialogSettings::~CGUIDialogSettings(void)
67 bool CGUIDialogSettings::OnMessage(CGUIMessage &message)
69 switch (message.GetMessage())
73 unsigned int iControl = message.GetSenderId();
74 if (iControl >= CONTROL_OKAY_BUTTON && iControl < CONTROL_PAGE)
79 case GUI_MSG_WINDOW_DEINIT:
81 CGUIDialog::OnMessage(message);
88 return CGUIDialog::OnMessage(message);
91 void CGUIDialogSettings::SetupPage()
93 // cleanup first, if necessary
95 m_pOriginalEdit = (CGUIEditControl*)GetControl(CONTROL_DEFAULT_EDIT);
96 m_pOriginalEditNum = (CGUIEditControl*)GetControl(CONTROL_DEFAULT_EDIT_NUM);
97 m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
98 m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
99 m_pOriginalSettingsButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
100 m_pOriginalSlider = (CGUISettingsSliderControl *)GetControl(CONTROL_DEFAULT_SLIDER);
101 m_pOriginalSeparator = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
102 if (m_pOriginalEdit) m_pOriginalEdit->SetVisible(false);
103 if (m_pOriginalEditNum) m_pOriginalEditNum->SetVisible(false);
104 if (m_pOriginalSpin) m_pOriginalSpin->SetVisible(false);
105 if (m_pOriginalRadioButton) m_pOriginalRadioButton->SetVisible(false);
106 if (m_pOriginalSettingsButton) m_pOriginalSettingsButton->SetVisible(false);
107 if (m_pOriginalSlider) m_pOriginalSlider->SetVisible(false);
108 if (m_pOriginalSeparator) m_pOriginalSeparator->SetVisible(false);
110 // update our settings label
111 if (GetID() == WINDOW_DIALOG_PVR_TIMER_SETTING)
113 SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, g_localizeStrings.Get(19057));
117 SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, g_localizeStrings.Get(13395 + GetID() - WINDOW_DIALOG_VIDEO_OSD_SETTINGS));
120 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
124 if (!m_settings.size())
125 { // no settings available
126 SET_CONTROL_VISIBLE(CONTROL_NONE_AVAILABLE);
131 SET_CONTROL_HIDDEN(CONTROL_NONE_AVAILABLE);
134 // create our controls
135 for (unsigned int i = 0; i < m_settings.size(); i++)
137 SettingInfo &setting = m_settings.at(i);
138 AddSetting(setting, group->GetWidth(), CONTROL_START + i);
142 void CGUIDialogSettings::EnableSettings(unsigned int id, bool enabled)
144 for (unsigned int i = 0; i < m_settings.size(); i++)
146 if (m_settings[i].id != id)
148 m_settings[i].enabled = enabled;
151 CONTROL_ENABLE(i + CONTROL_START);
155 CONTROL_DISABLE(i + CONTROL_START);
159 CLog::Log(LOGWARNING, "%s - Invalid setting specified", __FUNCTION__);
162 void CGUIDialogSettings::UpdateSetting(unsigned int id)
164 unsigned int settingNum = (unsigned int)-1;
165 for (unsigned int i = 0; i < m_settings.size(); i++)
167 if (m_settings[i].id == id)
173 if(settingNum == (unsigned int)-1)
176 SettingInfo &setting = m_settings.at(settingNum);
177 unsigned int controlID = settingNum + CONTROL_START;
178 if (setting.type == SettingInfo::SPIN)
180 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(controlID);
181 if (pControl && setting.data) pControl->SetValue(*(int *)setting.data);
183 else if (setting.type == SettingInfo::CHECK)
185 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(controlID);
186 if (pControl && setting.data) pControl->SetSelected(*(bool *)setting.data);
188 else if (setting.type == SettingInfo::CHECK_UCHAR)
190 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(controlID);
191 if (pControl && setting.data) pControl->SetSelected(*(unsigned char*)setting.data ? true : false);
193 else if (setting.type == SettingInfo::SLIDER)
195 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(controlID);
196 if (pControl && setting.data)
198 float value = *(float *)setting.data;
199 pControl->SetFloatValue(value);
200 if (setting.formatFunction.standard) pControl->SetTextValue(setting.formatFunction.standard(value, setting.interval));
203 else if (setting.type == SettingInfo::BUTTON_DIALOG)
205 SET_CONTROL_LABEL(controlID,setting.name);
206 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(controlID);
207 if (pControl && setting.data) pControl->SetLabel2(*(CStdString *)setting.data);
209 else if (setting.type == SettingInfo::EDIT)
211 SET_CONTROL_LABEL(controlID, setting.name);
212 if (setting.data) SET_CONTROL_LABEL2(controlID, string(*(CStdString *)setting.data));
214 else if (setting.type == SettingInfo::EDIT_NUM)
216 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(controlID);
217 if (pControl && setting.data) {
219 strIndex.Format("%i", *(int *)setting.data);
220 pControl->SetLabel2(strIndex);
223 else if (setting.type == SettingInfo::STRING)
225 SET_CONTROL_LABEL(controlID, setting.name);
226 string strNewValue = string(*(CStdString *)setting.data);
227 if (strNewValue.empty())
229 SET_CONTROL_LABEL2(controlID, strNewValue);
231 else if (setting.type == SettingInfo::RANGE)
233 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(controlID);
234 float** value = (float **)setting.data;
235 if (pControl && setting.data)
237 pControl->SetFloatValue(*(value[0]), CGUISliderControl::RangeSelectorLower);
238 pControl->SetFloatValue(*(value[1]), CGUISliderControl::RangeSelectorUpper);
239 if (setting.formatFunction.range) pControl->SetTextValue(setting.formatFunction.range(*(value[0]), *(value[1]), setting.interval));
245 CONTROL_ENABLE(controlID);
249 CONTROL_DISABLE(controlID);
253 bool CGUIDialogSettings::OnBack(int actionID)
256 return CGUIDialog::OnBack(actionID);
259 void CGUIDialogSettings::OnClick(int iID)
261 if (iID == CONTROL_OKAY_BUTTON)
267 if (iID == CONTROL_CANCEL_BUTTON)
273 unsigned int settingNum = iID - CONTROL_START;
274 if (settingNum >= m_settings.size()) return;
275 SettingInfo &setting = m_settings.at(settingNum);
276 if (setting.type == SettingInfo::SPIN)
278 CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(iID);
279 if (setting.data) *(int *)setting.data = pControl->GetValue();
281 else if (setting.type == SettingInfo::BUTTON_DIALOG)
283 CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(iID);
284 if (setting.data) *(CStdString *)setting.data = pControl->GetLabel2();
286 else if (setting.type == SettingInfo::EDIT)
288 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(iID);
289 if (setting.data) *(CStdString *)setting.data = pControl->GetLabel2();
291 else if (setting.type == SettingInfo::EDIT_NUM)
293 CGUIEditControl *pControl = (CGUIEditControl *)GetControl(iID);
295 CStdString strIndex = pControl->GetLabel2();
296 *(int *)setting.data = atol(strIndex.c_str());
299 else if (setting.type == SettingInfo::CHECK)
301 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(iID);
302 if (setting.data) *(bool *)setting.data = pControl->IsSelected();
304 else if (setting.type == SettingInfo::CHECK_UCHAR)
306 CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(iID);
307 if (setting.data) *(unsigned char*)setting.data = pControl->IsSelected() ? 1 : 0;
309 else if (setting.type == SettingInfo::SLIDER)
311 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(iID);
312 if (setting.data) *(float *)setting.data = pControl->GetFloatValue();
313 if (setting.formatFunction.standard) pControl->SetTextValue(setting.formatFunction.standard(pControl->GetFloatValue(), setting.interval));
315 else if (setting.type == SettingInfo::BUTTON && m_usePopupSliders && setting.data)
316 { // we're using popup sliders
317 CGUIDialogSlider::ShowAndGetInput(setting.name, *(float *)setting.data, setting.min, setting.interval, setting.max, this, &setting);
318 if (setting.formatFunction.standard)
319 SET_CONTROL_LABEL2(iID, setting.formatFunction.standard(*(float *)setting.data, setting.interval));
321 else if (setting.type == SettingInfo::STRING)
323 CGUIKeyboardFactory::ShowAndGetInput(*(CStdString *) setting.data, true);
324 string strNewValue = string(*(CStdString *)setting.data);
325 if (strNewValue.empty())
327 SET_CONTROL_LABEL2(iID, strNewValue);
329 else if (setting.type == SettingInfo::RANGE)
331 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl *)GetControl(iID);
334 *((float **)setting.data)[0] = pControl->GetFloatValue(CGUISliderControl::RangeSelectorLower);
335 *((float **)setting.data)[1] = pControl->GetFloatValue(CGUISliderControl::RangeSelectorUpper);
337 if (setting.formatFunction.range)
338 pControl->SetTextValue(setting.formatFunction.range(pControl->GetFloatValue(CGUISliderControl::RangeSelectorLower),
339 pControl->GetFloatValue(CGUISliderControl::RangeSelectorUpper),
342 OnSettingChanged(setting);
345 void CGUIDialogSettings::FreeControls()
347 // just clear our group list
348 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
351 group->FreeResources();
356 void CGUIDialogSettings::AddSetting(SettingInfo &setting, float width, int iControlID)
358 CGUIControl *pControl = NULL;
359 if (setting.type == SettingInfo::BUTTON_DIALOG && m_pOriginalSettingsButton)
361 pControl = new CGUIButtonControl(*m_pOriginalSettingsButton);
362 if (!pControl) return ;
363 ((CGUIButtonControl *)pControl)->SetLabel(setting.name);
364 pControl->SetWidth(width);
365 if (setting.data) ((CGUIButtonControl *)pControl)->SetLabel2(*(CStdString *)setting.data);
367 else if (setting.type == SettingInfo::BUTTON && m_pOriginalSettingsButton)
369 pControl = new CGUIButtonControl(*m_pOriginalSettingsButton);
370 if (!pControl) return ;
371 ((CGUIButtonControl *)pControl)->SetLabel(setting.name);
372 if (setting.formatFunction.standard)
373 ((CGUIButtonControl *)pControl)->SetLabel2(setting.formatFunction.standard(*(float *)setting.data, setting.interval));
374 pControl->SetWidth(width);
376 else if (setting.type == SettingInfo::EDIT && m_pOriginalEdit)
378 pControl = new CGUIEditControl(*m_pOriginalEdit);
379 if (!pControl) return ;
380 ((CGUIEditControl *)pControl)->SetLabel(setting.name);
381 pControl->SetWidth(width);
382 if (setting.data) ((CGUIEditControl *)pControl)->SetLabel2(*(CStdString *)setting.data);
384 else if (setting.type == SettingInfo::EDIT_NUM && m_pOriginalEditNum)
386 pControl = new CGUIEditControl(*m_pOriginalEditNum);
387 if (!pControl) return ;
388 ((CGUIEditControl *)pControl)->SetLabel(setting.name);
389 pControl->SetWidth(width);
390 ((CGUIEditControl *)pControl)->SetInputType(CGUIEditControl::INPUT_TYPE_NUMBER, 0);
393 strIndex.Format("%i", *(int *)setting.data);
394 ((CGUIEditControl *)pControl)->SetLabel2(strIndex);
397 else if (setting.type == SettingInfo::SEPARATOR && m_pOriginalSeparator)
399 pControl = new CGUIImage(*m_pOriginalSeparator);
400 if (!pControl) return ;
401 pControl->SetWidth(width);
403 else if (setting.type == SettingInfo::CHECK || setting.type == SettingInfo::CHECK_UCHAR)
405 if (!m_pOriginalRadioButton) return;
406 pControl = new CGUIRadioButtonControl(*m_pOriginalRadioButton);
407 if (!pControl) return ;
408 ((CGUIRadioButtonControl *)pControl)->SetLabel(setting.name);
409 pControl->SetWidth(width);
410 if (setting.data) ((CGUIRadioButtonControl *)pControl)->SetSelected(*(bool *)setting.data == 1);
412 else if (setting.type == SettingInfo::SPIN && setting.entry.size() > 0 && m_pOriginalSpin)
414 pControl = new CGUISpinControlEx(*m_pOriginalSpin);
415 if (!pControl) return ;
416 pControl->SetWidth(width);
417 ((CGUISpinControlEx *)pControl)->SetText(setting.name);
418 pControl->SetWidth(width);
419 for (unsigned int i = 0; i < setting.entry.size(); i++)
420 ((CGUISpinControlEx *)pControl)->AddLabel(setting.entry[i].second, setting.entry[i].first);
421 if (setting.data) ((CGUISpinControlEx *)pControl)->SetValue(*(int *)setting.data);
423 else if (setting.type == SettingInfo::SLIDER)
425 if (!m_pOriginalSlider) return;
426 pControl = new CGUISettingsSliderControl(*m_pOriginalSlider);
427 if (!pControl) return ;
428 pControl->SetWidth(width);
429 ((CGUISettingsSliderControl *)pControl)->SetText(setting.name);
430 if (setting.formatFunction.standard)
431 ((CGUISettingsSliderControl *)pControl)->SetTextValue(setting.formatFunction.standard(*(float *)setting.data, setting.interval));
432 ((CGUISettingsSliderControl *)pControl)->SetType(SPIN_CONTROL_TYPE_FLOAT);
433 ((CGUISettingsSliderControl *)pControl)->SetFloatRange(setting.min, setting.max);
434 ((CGUISettingsSliderControl *)pControl)->SetFloatInterval(setting.interval);
435 if (setting.data) ((CGUISettingsSliderControl *)pControl)->SetFloatValue(*(float *)setting.data);
437 else if (setting.type == SettingInfo::STRING && m_pOriginalSettingsButton)
439 pControl = new CGUIButtonControl(*m_pOriginalSettingsButton);
440 if (!pControl) return ;
441 ((CGUIButtonControl *)pControl)->SetLabel(setting.name);
442 string strValue = string(*(CStdString *)setting.data);
443 if (strValue.empty())
445 ((CGUIButtonControl *)pControl)->SetLabel2(strValue);
446 pControl->SetWidth(width);
448 else if (setting.type == SettingInfo::RANGE)
450 if (!m_pOriginalSlider) return;
451 pControl = new CGUISettingsSliderControl(*m_pOriginalSlider);
452 if (!pControl) return ;
453 pControl->SetWidth(width);
454 ((CGUISettingsSliderControl *)pControl)->SetText(setting.name);
455 if (setting.formatFunction.range)
456 ((CGUISettingsSliderControl *)pControl)->SetTextValue(setting.formatFunction.range(*((float **)setting.data)[0], *((float **)setting.data)[1], setting.interval));
457 ((CGUISettingsSliderControl *)pControl)->SetType(SPIN_CONTROL_TYPE_FLOAT);
458 ((CGUISettingsSliderControl *)pControl)->SetRangeSelection(true);
459 ((CGUISettingsSliderControl *)pControl)->SetFloatRange(setting.min, setting.max);
460 ((CGUISettingsSliderControl *)pControl)->SetFloatInterval(setting.interval);
463 ((CGUISettingsSliderControl *)pControl)->SetFloatValue(*((float **)setting.data)[0], CGUISliderControl::RangeSelectorLower);
464 ((CGUISettingsSliderControl *)pControl)->SetFloatValue(*((float **)setting.data)[1], CGUISliderControl::RangeSelectorUpper);
467 if (!pControl) return;
469 pControl->SetID(iControlID);
470 pControl->SetVisible(true);
471 pControl->SetEnabled(setting.enabled);
472 CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST);
475 pControl->AllocResources();
476 group->AddControl(pControl);
482 void CGUIDialogSettings::AddEdit(unsigned int id, int label, CStdString *str, bool enabled)
486 setting.name = g_localizeStrings.Get(label);
487 setting.type = SettingInfo::EDIT;
488 setting.enabled = enabled;
490 m_settings.push_back(setting);
493 void CGUIDialogSettings::AddNumEdit(unsigned int id, int label, int *current, bool enabled)
497 setting.name = g_localizeStrings.Get(label);
498 setting.type = SettingInfo::EDIT_NUM;
499 setting.enabled = enabled;
500 setting.data = current;
501 m_settings.push_back(setting);
504 void CGUIDialogSettings::AddButton(unsigned int id, int label, float *current, float min, float interval, float max, FORMATFUNCTION function)
508 setting.name = g_localizeStrings.Get(label);
509 setting.type = SettingInfo::BUTTON;
510 setting.data = current;
513 setting.interval = interval;
514 setting.formatFunction.standard = function;
515 m_settings.push_back(setting);
518 void CGUIDialogSettings::AddButton(unsigned int id, int label, CStdString *str, bool bOn)
522 setting.name = g_localizeStrings.Get(label);
523 setting.type = SettingInfo::BUTTON_DIALOG;
524 setting.enabled = bOn;
526 m_settings.push_back(setting);
529 void CGUIDialogSettings::AddString(unsigned int id, int label, CStdString *current)
533 setting.name = g_localizeStrings.Get(label);
534 setting.type = SettingInfo::STRING;
535 setting.data = current;
536 setting.enabled = true;
537 m_settings.push_back(setting);
540 void CGUIDialogSettings::AddBool(unsigned int id, int label, bool *on, bool enabled)
544 setting.name = g_localizeStrings.Get(label);
545 setting.type = SettingInfo::CHECK;
547 setting.enabled = enabled;
548 m_settings.push_back(setting);
551 void CGUIDialogSettings::AddSpin(unsigned int id, int label, int *current, unsigned int max, const SETTINGSTRINGS &entries)
555 setting.name = g_localizeStrings.Get(label);
556 setting.type = SettingInfo::SPIN;
557 setting.data = current;
558 for (unsigned int i = 0; i < max; i++)
559 setting.entry.push_back(make_pair(i, entries[i]));
560 m_settings.push_back(setting);
563 void CGUIDialogSettings::AddSpin(unsigned int id, int label, int *current, unsigned int max, const int *entries)
567 setting.name = g_localizeStrings.Get(label);
568 setting.type = SettingInfo::SPIN;
569 setting.data = current;
570 for (unsigned int i = 0; i < max; i++)
571 setting.entry.push_back(make_pair(i, g_localizeStrings.Get(entries[i])));
572 m_settings.push_back(setting);
575 void CGUIDialogSettings::AddSpin(unsigned int id, int label, int *current, unsigned int min, unsigned int max, const char* minLabel)
579 setting.name = g_localizeStrings.Get(label);
580 setting.type = SettingInfo::SPIN;
581 setting.data = current;
582 for (unsigned int i = min; i <= max; i++)
585 if (i == min && minLabel)
588 format.Format("%i", i);
589 setting.entry.push_back(make_pair(i, format));
591 m_settings.push_back(setting);
594 void CGUIDialogSettings::AddSpin(unsigned int id, int label, int *current, vector<pair<int, CStdString> > &values)
598 setting.name = g_localizeStrings.Get(label);
599 setting.type = SettingInfo::SPIN;
600 setting.data = current;
601 setting.entry = values;
602 if (values.size() <= 1)
603 setting.enabled = false;
604 m_settings.push_back(setting);
607 void CGUIDialogSettings::AddSpin(unsigned int id, int label, int *current, vector<pair<int, int> > &values)
609 vector<pair<int, CStdString> > entries;
610 for(unsigned i = 0; i < values.size(); i++)
611 entries.push_back(make_pair(values[i].first, g_localizeStrings.Get(values[i].second)));
612 AddSpin(id, label, current, entries);
615 void CGUIDialogSettings::AddSlider(unsigned int id, int label, float *current, float min, float interval, float max, FORMATFUNCTION function, bool allowPopup /* = true*/)
617 if (m_usePopupSliders && allowPopup)
619 AddButton(id, label, current, min, interval, max, function);
624 setting.name = g_localizeStrings.Get(label);
625 setting.type = SettingInfo::SLIDER;
627 setting.interval = interval;
629 setting.data = current;
630 setting.formatFunction.standard = function;
631 m_settings.push_back(setting);
634 void CGUIDialogSettings::AddRangeSlider(unsigned int id, int label, float *currentLower, float* currentUpper, float min, float interval, float max, RANGEFORMATFUNCTION function)
638 setting.name = g_localizeStrings.Get(label);
639 setting.type = SettingInfo::RANGE;
641 setting.interval = interval;
644 float** data = new float*[2];
645 data[0] = currentLower;
646 data[1] = currentUpper;
649 setting.formatFunction.range = function;
650 m_settings.push_back(setting);
653 void CGUIDialogSettings::AddSeparator(unsigned int id)
657 setting.type = SettingInfo::SEPARATOR;
659 m_settings.push_back(setting);
662 void CGUIDialogSettings::OnInitWindow()
665 SetInitialVisibility();
667 // set the default focus control
668 m_lastControlID = CONTROL_START;
670 for (unsigned int i = 0; i < m_settings.size(); i++)
672 if (m_settings.at(i).enabled)
674 m_lastControlID = CONTROL_START + i;
678 CGUIDialog::OnInitWindow();
681 void CGUIDialogSettings::OnSliderChange(void *data, CGUISliderControl *slider)
683 if (!data || !slider)
686 SettingInfo *setting = (SettingInfo *)data;
687 if (setting->type == SettingInfo::SLIDER || (setting->type == SettingInfo::BUTTON && m_usePopupSliders && !slider->GetRangeSelection()))
689 *(float *)setting->data = slider->GetFloatValue();
690 OnSettingChanged(*setting);
691 if (setting->formatFunction.standard)
692 slider->SetTextValue(setting->formatFunction.standard(slider->GetFloatValue(), setting->interval));
694 else if (setting->type == SettingInfo::RANGE || (setting->type == SettingInfo::BUTTON && m_usePopupSliders && slider->GetRangeSelection()))
696 *((float **)setting->data)[0] = slider->GetFloatValue(CGUISliderControl::RangeSelectorLower);
697 *((float **)setting->data)[1] = slider->GetFloatValue(CGUISliderControl::RangeSelectorUpper);
698 OnSettingChanged(*setting);
699 if (setting->formatFunction.range)
700 slider->SetTextValue(setting->formatFunction.range(slider->GetFloatValue(CGUISliderControl::RangeSelectorLower), slider->GetFloatValue(CGUISliderControl::RangeSelectorUpper), setting->interval));