Fixed the "hitbox" of the settings elements.

- Now the on/off toggles  "hitbox" corresponde to the icon.
This commit is contained in:
Maschell 2017-10-14 15:49:14 +02:00
parent f3d3a5835c
commit 3f1872437c
3 changed files with 12 additions and 21 deletions

View File

@ -21,8 +21,8 @@
* Constructor for the GuiSwitch class. * Constructor for the GuiSwitch class.
*/ */
GuiSwitch::GuiSwitch(bool checked,f32 switchscale) GuiSwitch::GuiSwitch(bool checked,f32 w, f32 h)
: GuiToggle(checked,90*switchscale,38*switchscale) : GuiToggle(checked,w,h)
,switchbase_imgdata(Resources::GetImageData("switchIconBase.png")) ,switchbase_imgdata(Resources::GetImageData("switchIconBase.png"))
,switchbase_img(switchbase_imgdata) ,switchbase_img(switchbase_imgdata)
,switchbase_highlighted_imgdata(Resources::GetImageData("switchIconBaseHighlighted.png")) ,switchbase_highlighted_imgdata(Resources::GetImageData("switchIconBaseHighlighted.png"))
@ -32,9 +32,9 @@ GuiSwitch::GuiSwitch(bool checked,f32 switchscale)
,switchOff_imgdata(Resources::GetImageData("switchIconOff.png")) ,switchOff_imgdata(Resources::GetImageData("switchIconOff.png"))
,switchOff_img(switchOff_imgdata) ,switchOff_img(switchOff_imgdata)
{ {
f32 scale = 0.0; f32 scale = 1.0;
if(switchbase_img.getHeight() > switchbase_img.getWidth()){ if(switchbase_img.getHeight() > switchbase_img.getWidth()){
scale = height*switchscale/switchbase_img.getHeight(); scale = height/switchbase_img.getHeight();
}else{ }else{
scale = width/switchbase_img.getWidth(); scale = width/switchbase_img.getWidth();
} }
@ -45,9 +45,11 @@ GuiSwitch::GuiSwitch(bool checked,f32 switchscale)
switchOff_img.setScale(scale); switchOff_img.setScale(scale);
switchOn_img.setParent(this); switchOn_img.setParent(this);
switchOn_img.setPosition((width/4.0),0); switchOn_img.setAlignment(ALIGN_RIGHT);
//switchOn_img.setPosition((width/4.0),0);
switchOff_img.setParent(this); switchOff_img.setParent(this);
switchOff_img.setPosition(-((width/4.0)),0); switchOff_img.setAlignment(ALIGN_LEFT);
//switchOff_img.setPosition(-((width/4.0)),0);
setImage(&switchbase_img); setImage(&switchbase_img);
setIconOver(&switchbase_highlighted_img); setIconOver(&switchbase_highlighted_img);
} }
@ -70,11 +72,3 @@ void GuiSwitch::draw(CVideo *v){
switchOff_img.draw(v); switchOff_img.draw(v);
} }
} }
f32 GuiSwitch::getHeight(){
return switchOn_img.getHeight();
}
f32 GuiSwitch::getWidth(){
return switchbase_img.getWidth();
}

View File

@ -27,13 +27,10 @@ class GuiSwitch : public GuiToggle
public: public:
//!Constructor //!Constructor
//!\param checked Checked //!\param checked Checked
GuiSwitch(bool checked,f32 switchscale = 1.0f); GuiSwitch(bool checked,f32 w, f32 h);
//!Destructor //!Destructor
virtual ~GuiSwitch(); virtual ~GuiSwitch();
f32 getHeight();
f32 getWidth();
protected: protected:
GuiImageData * switchbase_imgdata; GuiImageData * switchbase_imgdata;

View File

@ -25,9 +25,9 @@ ContentSettings::ContentSettings():ContentTemplate()
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH) , touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A) , wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
, languageSelectBox("",NULL) , languageSelectBox("",NULL)
, rumbleSwitch(CSettings::instance()->getValueAsBool(CSettings::RumbleActivated)) , rumbleSwitch(CSettings::instance()->getValueAsBool(CSettings::RumbleActivated),90.0f,38.0f)
, musicSwitch(CSettings::instance()->getValueAsBool(CSettings::MusicActivated)) , musicSwitch(CSettings::instance()->getValueAsBool(CSettings::MusicActivated),90.0f,38.0f)
, networkControllerSwitch(CSettings::instance()->getValueAsBool(CSettings::NetworkControllerActivated)) , networkControllerSwitch(CSettings::instance()->getValueAsBool(CSettings::NetworkControllerActivated),90.0f,38.0f)
, buttonClickSound(Resources::GetSound("settings_click_2.mp3")) , buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
{ {
headLine.setText(gettext("Settings")); headLine.setText(gettext("Settings"));