diff options
| author | Eugene Sandulenko | 2010-06-15 10:48:39 +0000 |
|---|---|---|
| committer | Eugene Sandulenko | 2010-06-15 10:48:39 +0000 |
| commit | dc040aa8671797853b0b1f9add3320c6e1f22c33 (patch) | |
| tree | 5b8382613d784495f128a79573dc5cda07b29fa5 /gui | |
| parent | 3fafa07ab0aeb65fedad159fb0cf345cc8f5f278 (diff) | |
| download | scummvm-rg350-dc040aa8671797853b0b1f9add3320c6e1f22c33.tar.gz scummvm-rg350-dc040aa8671797853b0b1f9add3320c6e1f22c33.tar.bz2 scummvm-rg350-dc040aa8671797853b0b1f9add3320c6e1f22c33.zip | |
GUI: Implement radiobuttons.
Implement radiobuttons in GUI. Also closes FR #2821529:
"GUI: volume and subtitles speed sliders".
Subtitle toggle button is replaced by three radiobuttons grouped
by a single group.
Updated translations and themes.
svn-id: r49767
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/ThemeEngine.cpp | 30 | ||||
| -rw-r--r-- | gui/ThemeEngine.h | 7 | ||||
| -rw-r--r-- | gui/options.cpp | 78 | ||||
| -rw-r--r-- | gui/options.h | 5 | ||||
| -rw-r--r-- | gui/themes/default.inc | 127 | ||||
| -rw-r--r-- | gui/themes/scummclassic.zip | bin | 52484 -> 54695 bytes | |||
| -rw-r--r-- | gui/themes/scummclassic/classic_gfx.stx | 63 | ||||
| -rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 25 | ||||
| -rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 37 | ||||
| -rw-r--r-- | gui/themes/scummmodern.zip | bin | 158475 -> 162132 bytes | |||
| -rwxr-xr-x | gui/themes/scummmodern/radiobutton.bmp | bin | 0 -> 774 bytes | |||
| -rwxr-xr-x | gui/themes/scummmodern/radiobutton_empty.bmp | bin | 0 -> 774 bytes | |||
| -rw-r--r-- | gui/themes/scummmodern/scummmodern_gfx.stx | 38 | ||||
| -rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 28 | ||||
| -rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 35 | ||||
| -rw-r--r-- | gui/widget.cpp | 68 | ||||
| -rw-r--r-- | gui/widget.h | 50 |
17 files changed, 509 insertions, 82 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 03e21153a5..5bde44d792 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -190,6 +190,10 @@ static const DrawDataInfo kDrawDataDefaults[] = { {kDDCheckboxDisabled, "checkbox_disabled", true, kDDNone}, {kDDCheckboxSelected, "checkbox_selected", false, kDDCheckboxDefault}, + {kDDRadiobuttonDefault, "radiobutton_default", true, kDDNone}, + {kDDRadiobuttonDisabled, "radiobutton_disabled", true, kDDNone}, + {kDDRadiobuttonSelected, "radiobutton_selected", false, kDDRadiobuttonDefault}, + {kDDTabActive, "tab_active", false, kDDTabInactive}, {kDDTabInactive, "tab_inactive", true, kDDNone}, {kDDTabBackground, "tab_background", true, kDDNone}, @@ -885,6 +889,32 @@ void ThemeEngine::drawCheckbox(const Common::Rect &r, const Common::String &str, queueDDText(getTextData(dd), getTextColor(dd), r2, str, false, false, _widgets[kDDCheckboxDefault]->_textAlignH, _widgets[dd]->_textAlignV); } +void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state) { + if (!ready()) + return; + + Common::Rect r2 = r; + DrawData dd = kDDRadiobuttonDefault; + + if (checked) + dd = kDDRadiobuttonSelected; + + if (state == kStateDisabled) + dd = kDDRadiobuttonDisabled; + + const int checkBoxSize = MIN((int)r.height(), getFontHeight()); + + r2.bottom = r2.top + checkBoxSize; + r2.right = r2.left + checkBoxSize; + + queueDD(dd, r2); + + r2.left = r2.right + checkBoxSize; + r2.right = r.right; + + queueDDText(getTextData(dd), getTextColor(dd), r2, str, false, false, _widgets[kDDRadiobuttonDefault]->_textAlignH, _widgets[dd]->_textAlignV); +} + void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state) { if (!ready()) return; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 2da1c3a014..2ef6fe3781 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -82,6 +82,10 @@ enum DrawData { kDDCheckboxDisabled, kDDCheckboxSelected, + kDDRadiobuttonDefault, + kDDRadiobuttonDisabled, + kDDRadiobuttonSelected, + kDDTabActive, kDDTabInactive, kDDTabBackground, @@ -312,6 +316,9 @@ public: void drawCheckbox(const Common::Rect &r, const Common::String &str, bool checked, WidgetStateInfo state = kStateEnabled); + void drawRadiobutton(const Common::Rect &r, const Common::String &str, + bool checked, WidgetStateInfo state = kStateEnabled); + void drawTab(const Common::Rect &r, int tabHeight, int tabWidth, const Common::Array<Common::String> &tabs, int active, uint16 hints, int titleVPad, WidgetStateInfo state = kStateEnabled); diff --git a/gui/options.cpp b/gui/options.cpp index be83624254..e9be2834a4 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -62,6 +62,12 @@ enum { kChooseThemeCmd = 'chtf' }; +enum { + kSubtitlesSpeech, + kSubtitlesSubs, + kSubtitlesBoth +}; + #ifdef SMALL_SCREEN_DEVICE enum { kChooseKeyMappingCmd = 'chma' @@ -85,18 +91,6 @@ OptionsDialog::OptionsDialog(const Common::String &domain, const Common::String init(); } -const char *OptionsDialog::_subModeDesc[] = { - _s("Speech Only"), - _s("Speech and Subtitles"), - _s("Subtitles Only") -}; - -const char *OptionsDialog::_lowresSubModeDesc[] = { - _s("Speech Only"), - _s("Speech & Subs"), - _s("Subtitles Only") -}; - void OptionsDialog::init() { _enableGraphicSettings = false; _gfxPopUp = 0; @@ -123,7 +117,9 @@ void OptionsDialog::init() { _speechVolumeLabel = 0; _muteCheckbox = 0; _subToggleDesc = 0; - _subToggleButton = 0; + _subToggleSubOnly = 0; + _subToggleSpeechOnly = 0; + _subToggleSubBoth = 0; _subSpeedDesc = 0; _subSpeedSlider = 0; _subSpeedLabel = 0; @@ -264,11 +260,12 @@ void OptionsDialog::open() { } // Subtitle options - if (_subToggleButton) { - int speed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); + if (_subToggleGroup) { + int speed; + int sliderMaxValue = _subSpeedSlider->getMaxValue(); _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute", _domain)); - _subToggleButton->setLabel(_(_subModeDesc[_subMode])); + _subToggleGroup->setValue(_subMode); // Engines that reuse the subtitle speed widget set their own max value. // Scale the config value accordingly (see addSubtitleControls) @@ -393,21 +390,21 @@ void OptionsDialog::close() { } // Subtitle options - if (_subToggleButton) { + if (_subToggleGroup) { if (_enableSubtitleSettings) { bool subtitles, speech_mute; int talkspeed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); switch (_subMode) { - case 0: + case kSubtitlesSpeech: subtitles = speech_mute = false; break; - case 1: + case kSubtitlesBoth: subtitles = true; speech_mute = false; break; - case 2: + case kSubtitlesSubs: default: subtitles = speech_mute = true; break; @@ -460,18 +457,6 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data // 'true' because if control is disabled then event do not pass setVolumeSettingsState(true); break; - case kSubtitleToggle: - if (_subMode < 2) - _subMode++; - else - _subMode = 0; - - _subToggleButton->setLabel(g_system->getOverlayWidth() > 320 ? _(_subModeDesc[_subMode]) : _(_lowresSubModeDesc[_subMode])); - _subToggleButton->draw(); - _subSpeedDesc->draw(); - _subSpeedSlider->draw(); - _subSpeedLabel->draw(); - break; case kSubtitleSpeedChanged: _subSpeedLabel->setValue(_subSpeedSlider->getValue()); _subSpeedLabel->draw(); @@ -576,7 +561,7 @@ void OptionsDialog::setSubtitleSettingsState(bool enabled) { if ((_guioptions & Common::GUIO_NOSUBTITLES) || (_guioptions & Common::GUIO_NOSPEECH)) ena = false; - _subToggleButton->setEnabled(ena); + _subToggleGroup->setEnabled(ena); _subToggleDesc->setEnabled(ena); ena = enabled; @@ -685,7 +670,20 @@ void OptionsDialog::addMIDIControls(GuiObject *boss, const Common::String &prefi void OptionsDialog::addSubtitleControls(GuiObject *boss, const Common::String &prefix, int maxSliderVal) { _subToggleDesc = new StaticTextWidget(boss, prefix + "subToggleDesc", _("Text and Speech:")); - _subToggleButton = new ButtonWidget(boss, prefix + "subToggleButton", "", kSubtitleToggle); + + if (g_system->getOverlayWidth() > 320) { + _subToggleGroup = new RadiobuttonGroup(boss, kSubtitleToggle); + + _subToggleSpeechOnly = new RadiobuttonWidget(boss, prefix + "subToggleSpeechOnly", _subToggleGroup, kSubtitlesSpeech, _("Speech")); + _subToggleSubOnly = new RadiobuttonWidget(boss, prefix + "subToggleSubOnly", _subToggleGroup, kSubtitlesSubs, _("Subtitles")); + _subToggleSubBoth = new RadiobuttonWidget(boss, prefix + "subToggleSubBoth", _subToggleGroup, kSubtitlesBoth, _("Both")); + } else { + _subToggleGroup = new RadiobuttonGroup(boss, kSubtitleToggle); + + _subToggleSpeechOnly = new RadiobuttonWidget(boss, prefix + "subToggleSpeechOnly", _subToggleGroup, kSubtitlesSpeech, _("Spch")); + _subToggleSubOnly = new RadiobuttonWidget(boss, prefix + "subToggleSubOnly", _subToggleGroup, kSubtitlesSubs, _("Subs")); + _subToggleSubBoth = new RadiobuttonWidget(boss, prefix + "subToggleSubBoth", _subToggleGroup, kSubtitlesBoth, _("Both")); + } // Subtitle speed _subSpeedDesc = new StaticTextWidget(boss, prefix + "subSubtitleSpeedDesc", _("Subtitle speed:")); @@ -729,19 +727,19 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, const Common::String &pre int OptionsDialog::getSubtitleMode(bool subtitles, bool speech_mute) { if (_guioptions & Common::GUIO_NOSUBTITLES) - return 0; // Speech only + return kSubtitlesSpeech; // Speech only if (_guioptions & Common::GUIO_NOSPEECH) - return 2; // Subtitles only + return kSubtitlesSubs; // Subtitles only if (!subtitles && !speech_mute) // Speech only - return 0; + return kSubtitlesSpeech; else if (subtitles && !speech_mute) // Speech and subtitles - return 1; + return kSubtitlesBoth; else if (subtitles && speech_mute) // Subtitles only - return 2; + return kSubtitlesSubs; else warning("Wrong configuration: Both subtitles and speech are off. Assuming subtitles only"); - return 2; + return kSubtitlesSubs; } void OptionsDialog::reflowLayout() { diff --git a/gui/options.h b/gui/options.h index de25bfc998..48282a7fd7 100644 --- a/gui/options.h +++ b/gui/options.h @@ -121,7 +121,10 @@ private: int getSubtitleMode(bool subtitles, bool speech_mute); bool _enableSubtitleSettings; StaticTextWidget *_subToggleDesc; - ButtonWidget *_subToggleButton; + RadiobuttonGroup *_subToggleGroup; + RadiobuttonWidget *_subToggleSubOnly; + RadiobuttonWidget *_subToggleSpeechOnly; + RadiobuttonWidget *_subToggleSubBoth; int _subMode; static const char *_subModeDesc[]; static const char *_lowresSubModeDesc[]; diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 93897a7d88..9d1cabf7f0 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -349,6 +349,63 @@ "fill='none' " "/> " "</drawdata> " +"<drawdata id='radiobutton_default' cache='false'> " +"<text font='text_default' " +"text_color='color_normal' " +"vertical_align='center' " +"horizontal_align='left' " +"/> " +"<drawstep func='circle' " +"width='7' " +"height='7' " +"radius='7' " +"fill='background' " +"bg_color='darkgrey' " +"xpos='0' " +"ypos='0' " +"/> " +"</drawdata> " +"<drawdata id='radiobutton_selected' cache='false'> " +"<text font='text_default' " +"text_color='color_normal' " +"vertical_align='center' " +"horizontal_align='left' " +"/> " +"<drawstep func='circle' " +"width='7' " +"height='7' " +"radius='7' " +"fg_color='darkgrey' " +"fill='none' " +"xpos='0' " +"ypos='0' " +"/> " +"<drawstep func='circle' " +"width='7' " +"height='7' " +"radius='5' " +"fg_color='green' " +"fill='foreground' " +"xpos='2' " +"ypos='2' " +"/> " +"</drawdata> " +"<drawdata id='radiobutton_disabled' cache='false'> " +"<text font='text_default' " +"text_color='color_normal_disabled' " +"vertical_align='center' " +"horizontal_align='left' " +"/> " +"<drawstep func='circle' " +"width='7' " +"height='7' " +"radius='7' " +"bg_color='lightgrey' " +"fill='background' " +"xpos='0' " +"ypos='0' " +"/> " +"</drawdata> " "<drawdata id='widget_default' cache='false'> " "<drawstep func='bevelsq' " "bevel='2' " @@ -390,6 +447,9 @@ "<widget name='Checkbox' " "size='-1,14' " "/> " +"<widget name='Radiobutton' " +"size='-1,Globals.Line.Height' " +"/> " "<widget name='ListWidget' " "padding='5,0,8,0' " "/> " @@ -560,9 +620,14 @@ "<widget name='subToggleDesc' " "type='OptionsLabel' " "/> " -"<widget name='subToggleButton' " -"width='150' " -"height='Globals.Slider.Height' " +"<widget name='subToggleSpeechOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubBoth' " +"type='Radiobutton' " "/> " "</layout> " "<layout type='horizontal' padding='0,0,0,0' spacing='10'> " @@ -721,6 +786,14 @@ "type='PopUp' " "/> " "</layout> " +"<layout type='horizontal' padding='0,0,0,0' spacing='10' center='true'> " +"<widget name='GuiLanguagePopupDesc' " +"type='OptionsLabel' " +"/> " +"<widget name='GuiLanguagePopup' " +"type='PopUp' " +"/> " +"</layout> " "<widget name='KeysButton' " "type='Button' " "/> " @@ -957,9 +1030,14 @@ "<widget name='subToggleDesc' " "type='OptionsLabel' " "/> " -"<widget name='subToggleButton' " -"width='158' " -"height='Globals.Slider.Height' " +"<widget name='subToggleSpeechOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubBoth' " +"type='Radiobutton' " "/> " "</layout> " "<layout type='horizontal' padding='0,0,0,0' spacing='10'> " @@ -1116,6 +1194,9 @@ "<widget name='Checkbox' " "size='-1,Globals.Line.Height' " "/> " +"<widget name='Radiobutton' " +"size='-1,Globals.Line.Height' " +"/> " "<widget name='ListWidget' " "padding='5,0,0,0' " "/> " @@ -1281,13 +1362,18 @@ "type='PopUp' " "/> " "</layout> " -"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'> " +"<layout type='horizontal' padding='0,0,0,0' spacing='3' center='true'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " "/> " -"<widget name='subToggleButton' " -"width='128' " -"height='Globals.Slider.Height' " +"<widget name='subToggleSpeechOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubBoth' " +"type='Radiobutton' " "/> " "</layout> " "<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'> " @@ -1449,6 +1535,14 @@ "type='PopUp' " "/> " "</layout> " +"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'> " +"<widget name='GuiLanguagePopupDesc' " +"type='OptionsLabel' " +"/> " +"<widget name='GuiLanguagePopup' " +"type='PopUp' " +"/> " +"</layout> " "<widget name='KeysButton' " "type='Button' " "/> " @@ -1687,13 +1781,18 @@ "/> " "</layout> " "<space size='4' /> " -"<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'> " +"<layout type='horizontal' padding='0,0,0,0' spacing='1' center='true'> " "<widget name='subToggleDesc' " "type='OptionsLabel' " "/> " -"<widget name='subToggleButton' " -"width='128' " -"height='Globals.Slider.Height' " +"<widget name='subToggleSpeechOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubOnly' " +"type='Radiobutton' " +"/> " +"<widget name='subToggleSubBoth' " +"type='Radiobutton' " "/> " "</layout> " "<layout type='horizontal' padding='0,0,0,0' spacing='6' center='true'> " diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 1a4481376d..bff76afd91 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_gfx.stx b/gui/themes/scummclassic/classic_gfx.stx index cc6d7d471f..e107c1f04d 100644 --- a/gui/themes/scummclassic/classic_gfx.stx +++ b/gui/themes/scummclassic/classic_gfx.stx @@ -418,6 +418,69 @@ /> </drawdata> + <!-- Idle radiobutton --> + <drawdata id = 'radiobutton_default' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'circle' + width = '7' + height = '7' + radius = '7' + fill = 'background' + bg_color = 'darkgrey' + xpos = '0' + ypos = '0' + /> + </drawdata> + + <!-- Selected radiobutton --> + <drawdata id = 'radiobutton_selected' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'circle' + width = '7' + height = '7' + radius = '7' + fg_color = 'darkgrey' + fill = 'none' + xpos = '0' + ypos = '0' + /> + <drawstep func = 'circle' + width = '7' + height = '7' + radius = '5' + fg_color = 'green' + fill = 'foreground' + xpos = '2' + ypos = '2' + /> + </drawdata> + + <!-- Disabled radiobutton --> + <drawdata id = 'radiobutton_disabled' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal_disabled' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'circle' + width = '7' + height = '7' + radius = '7' + bg_color = 'lightgrey' + fill = 'background' + xpos = '0' + ypos = '0' + /> + </drawdata> + <drawdata id = 'widget_default' cache = 'false'> <drawstep func = 'bevelsq' bevel = '2' diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index b7b07f8845..0faf909862 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -66,6 +66,9 @@ <widget name = 'Checkbox' size = '-1, 14' /> + <widget name = 'Radiobutton' + size = '-1, Globals.Line.Height' + /> <widget name = 'ListWidget' padding = '5, 0, 8, 0' /> @@ -241,9 +244,14 @@ <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '150' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> @@ -661,9 +669,14 @@ <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '158' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 8a0180db3c..3573e56a79 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -63,6 +63,9 @@ <widget name = 'Checkbox' size = '-1, Globals.Line.Height' /> + <widget name = 'Radiobutton' + size = '-1, Globals.Line.Height' + /> <widget name = 'ListWidget' padding = '5, 0, 0, 0' /> @@ -235,13 +238,18 @@ type = 'PopUp' /> </layout> - <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '3' center = 'true'> <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '128' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> @@ -407,6 +415,14 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <widget name = 'GuiLanguagePopupDesc' + type = 'OptionsLabel' + /> + <widget name = 'GuiLanguagePopup' + type = 'PopUp' + /> + </layout> <widget name='KeysButton' type='Button' /> @@ -655,13 +671,18 @@ /> </layout> <space size = '4' /> - <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '1' center = 'true'> <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '128' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 64e9a633ff..a301e25f14 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/radiobutton.bmp b/gui/themes/scummmodern/radiobutton.bmp Binary files differnew file mode 100755 index 0000000000..d3ba468321 --- /dev/null +++ b/gui/themes/scummmodern/radiobutton.bmp diff --git a/gui/themes/scummmodern/radiobutton_empty.bmp b/gui/themes/scummmodern/radiobutton_empty.bmp Binary files differnew file mode 100755 index 0000000000..06b9f9bb70 --- /dev/null +++ b/gui/themes/scummmodern/radiobutton_empty.bmp diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx index 05316b516f..13f9cd2196 100644 --- a/gui/themes/scummmodern/scummmodern_gfx.stx +++ b/gui/themes/scummmodern/scummmodern_gfx.stx @@ -98,6 +98,8 @@ <bitmap filename = 'cursor_small.bmp'/> <bitmap filename = 'checkbox.bmp'/> <bitmap filename = 'checkbox_empty.bmp'/> + <bitmap filename = 'radiobutton.bmp'/> + <bitmap filename = 'radiobutton_empty.bmp'/> <bitmap filename = 'logo_small.bmp'/> <bitmap filename = 'search.bmp'/> </bitmaps> @@ -595,6 +597,42 @@ /> </drawdata> + <!-- Idle radiobutton --> + <drawdata id = 'radiobutton_default' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'bitmap' + file = 'radiobutton_empty.bmp' + /> + </drawdata> + + <!-- Selected radiobutton --> + <drawdata id = 'radiobutton_selected' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'bitmap' + file = 'radiobutton.bmp' + /> + </drawdata> + + <!-- Disabled radiobutton --> + <drawdata id = 'radiobutton_disabled' cache = 'false'> + <text font = 'text_default' + text_color = 'color_normal_disabled' + vertical_align = 'center' + horizontal_align = 'left' + /> + <drawstep func = 'bitmap' + file = 'radiobutton_empty.bmp' + /> + </drawdata> + <!-- Background of the list widget (the games list and the list in the choosers) --> <!-- TODO: Have separate options for the games list (with gradient background) and the list in the choosers (without gradient) --> <drawdata id = 'widget_default' cache = 'false'> diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 699d59b0be..787696dc34 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -70,6 +70,9 @@ <widget name = 'Checkbox' size = '-1, Globals.Line.Height' /> + <widget name = 'Radiobutton' + size = '-1, Globals.Line.Height' + /> <widget name = 'ListWidget' padding = '5, 0, 8, 0' /> @@ -254,9 +257,14 @@ <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '150' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> @@ -674,9 +682,17 @@ <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '158' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + width = '50' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + width = '50' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' + width = '50' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 1c2f83a3b7..9b811f5a48 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -61,6 +61,9 @@ <widget name = 'Checkbox' size = '-1, Globals.Line.Height' /> + <widget name = 'Radiobutton' + size = '-1, Globals.Line.Height' + /> <widget name = 'ListWidget' padding = '5, 0, 8, 0' /> @@ -233,13 +236,18 @@ type = 'PopUp' /> </layout> - <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '3' center = 'true'> <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '128' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> @@ -403,6 +411,14 @@ type = 'PopUp' /> </layout> + <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> + <widget name = 'GuiLanguagePopupDesc' + type = 'OptionsLabel' + /> + <widget name = 'GuiLanguagePopup' + type = 'PopUp' + /> + </layout> <widget name='KeysButton' type='Button' /> @@ -655,9 +671,14 @@ <widget name = 'subToggleDesc' type = 'OptionsLabel' /> - <widget name = 'subToggleButton' - width = '128' - height = 'Globals.Slider.Height' + <widget name = 'subToggleSpeechOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubOnly' + type = 'Radiobutton' + /> + <widget name = 'subToggleSubBoth' + type = 'Radiobutton' /> </layout> <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'> diff --git a/gui/widget.cpp b/gui/widget.cpp index c47c6099ba..1958ffe398 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -335,6 +335,74 @@ void CheckboxWidget::drawWidget() { } #pragma mark - +RadiobuttonGroup::RadiobuttonGroup(GuiObject *boss, uint32 cmd) : CommandSender(boss) { + _value = -1; + _cmd = cmd; +} + +void RadiobuttonGroup::setValue(int value) { + Common::Array<RadiobuttonWidget *>::iterator button = _buttons.begin(); + while (button != _buttons.end()) { + (*button)->setState((*button)->getValue() == value, false); + + button++; + } + + _value = value; + + sendCommand(_cmd, _value); +} + +void RadiobuttonGroup::setEnabled(bool ena) { + Common::Array<RadiobuttonWidget *>::iterator button = _buttons.begin(); + while (button != _buttons.end()) { + (*button)->setEnabled(ena); + + button++; + } +} + +#pragma mark - + +RadiobuttonWidget::RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey) + : ButtonWidget(boss, x, y, w, h, label, 0, hotkey), _state(false), _value(value), _group(group) { + setFlags(WIDGET_ENABLED); + _type = kRadiobuttonWidget; + _group->addButton(this); +} + +RadiobuttonWidget::RadiobuttonWidget(GuiObject *boss, const Common::String &name, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey) + : ButtonWidget(boss, name, label, 0, hotkey), _state(false), _value(value), _group(group) { + setFlags(WIDGET_ENABLED); + _type = kRadiobuttonWidget; + _group->addButton(this); +} + +void RadiobuttonWidget::handleMouseUp(int x, int y, int button, int clickCount) { + if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) { + toggleState(); + } +} + +void RadiobuttonWidget::setState(bool state, bool setGroup) { + if (setGroup) { + _group->setValue(_value); + return; + } + + if (_state != state) { + _state = state; + //_flags ^= WIDGET_INV_BORDER; + draw(); + } + sendCommand(_cmd, _state); +} + +void RadiobuttonWidget::drawWidget() { + g_gui.theme()->drawRadiobutton(Common::Rect(_x, _y, _x+_w, _y+_h), _label, _state, Widget::_state); +} + +#pragma mark - SliderWidget::SliderWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd) : Widget(boss, x, y, w, h), CommandSender(boss), diff --git a/gui/widget.h b/gui/widget.h index 3bbc565bbe..0b075c19db 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -62,6 +62,7 @@ enum { kEditTextWidget = 'EDIT', kButtonWidget = 'BTTN', kCheckboxWidget = 'CHKB', + kRadiobuttonWidget = 'RDBT', kSliderWidget = 'SLDE', kListWidget = 'LIST', kScrollBarWidget = 'SCRB', @@ -213,6 +214,55 @@ protected: void drawWidget(); }; +class RadiobuttonWidget; + +class RadiobuttonGroup : public CommandSender { +public: + RadiobuttonGroup(GuiObject *boss, uint32 cmd = 0); + ~RadiobuttonGroup() {} + + void addButton(RadiobuttonWidget *button) { _buttons.push_back(button); } + Common::Array<RadiobuttonWidget *> getButtonList() const { return _buttons; } + + void setValue(int state); + int getValue() const { return _value; } + + void setEnabled(bool ena); + + void setCmd(uint32 cmd) { _cmd = cmd; } + uint32 getCmd() const { return _cmd; } + +protected: + Common::Array<RadiobuttonWidget *> _buttons; + int _value; + uint32 _cmd; +}; + +/* RadiobuttonWidget */ +class RadiobuttonWidget : public ButtonWidget { +protected: + bool _state; + int _value; + +public: + RadiobuttonWidget(GuiObject *boss, int x, int y, int w, int h, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey = 0); + RadiobuttonWidget(GuiObject *boss, const Common::String &name, RadiobuttonGroup *group, int value, const Common::String &label, uint8 hotkey = 0); + + void handleMouseUp(int x, int y, int button, int clickCount); + virtual void handleMouseEntered(int button) { setFlags(WIDGET_HILITED); draw(); } + virtual void handleMouseLeft(int button) { clearFlags(WIDGET_HILITED); draw(); } + + void setState(bool state, bool setGroup = true); + void toggleState() { setState(!_state); } + bool getState() const { return _state; } + int getValue() const { return _value; } + +protected: + void drawWidget(); + + RadiobuttonGroup *_group; +}; + /* SliderWidget */ class SliderWidget : public Widget, public CommandSender { protected: |
