Some small tweaks

This commit is contained in:
Maschell 2017-10-31 17:18:42 +01:00
parent 9c4efe8b71
commit 2db871522d
10 changed files with 60 additions and 54 deletions

View File

@ -19,6 +19,7 @@
#include "FreeTypeGX.h"
#include "GameBgImage.h"
#include "GridBackground.h"
#include "GuiButton.h"
#include "GuiCheckBox.h"
#include "GuiController.h"

View File

@ -21,9 +21,9 @@
* Constructor for the GuiCheckBox class.
*/
GuiCheckBox::GuiCheckBox(bool checked, f32 width,f32 height)
GuiCheckBox::GuiCheckBox(GuiImage * background, bool checked, f32 width,f32 height)
: GuiToggle(checked,width,height){
setImageBackground(background);
}
/**
@ -36,7 +36,6 @@ GuiCheckBox::~GuiCheckBox(){
void GuiCheckBox::setImageBackground(GuiImage* img){
backgroundImg = img;
if(img){ img->setParent(this); }
setImage(img);
}
void GuiCheckBox::setImageSelected(GuiImage* img){

View File

@ -26,7 +26,7 @@ class GuiCheckBox : public GuiToggle{
public:
//!Constructor
//!\param checked Checked
GuiCheckBox(bool checked, f32 width = 0.0f,f32 height= 0.0f);
GuiCheckBox(GuiImage * background, bool checked, f32 width = 0.0f,f32 height= 0.0f);
//!Destructor
virtual ~GuiCheckBox();

View File

@ -24,7 +24,7 @@
#include "GuiScrollbar.h"
#include "resources/Resources.h"
Scrollbar::Scrollbar(s32 h)
GuiScrollbar::GuiScrollbar(s32 h)
: touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
{
@ -35,7 +35,7 @@ Scrollbar::Scrollbar(s32 h)
ScrollSpeed = 15;
ScrollState = 0;
listChanged.connect(this, &Scrollbar::setScrollboxPosition);
listChanged.connect(this, &GuiScrollbar::setScrollboxPosition);
btnSoundClick = Resources::GetSound("button_click.mp3");
scrollbarLine = Resources::GetImageData("scrollbarLine.png");
@ -67,7 +67,7 @@ Scrollbar::Scrollbar(s32 h)
arrowUpBtn->setTrigger(&wpadTouchTrigger, 1);
arrowUpBtn->setSoundClick(btnSoundClick);
arrowUpBtn->setEffectGrow();
arrowUpBtn->clicked.connect(this, &Scrollbar::OnUpButtonClick);
arrowUpBtn->clicked.connect(this, &GuiScrollbar::OnUpButtonClick);
arrowDownBtn = new GuiButton(arrowDownImg->getWidth(), arrowDownImg->getHeight());
arrowDownBtn->setParent(this);
@ -78,7 +78,7 @@ Scrollbar::Scrollbar(s32 h)
arrowDownBtn->setTrigger(&wpadTouchTrigger, 1);
arrowDownBtn->setSoundClick(btnSoundClick);
arrowDownBtn->setEffectGrow();
arrowDownBtn->clicked.connect(this, &Scrollbar::OnDownButtonClick);
arrowDownBtn->clicked.connect(this, &GuiScrollbar::OnDownButtonClick);
scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->getWidth(), height);
scrollbarBoxBtn->setParent(this);
@ -89,10 +89,10 @@ Scrollbar::Scrollbar(s32 h)
scrollbarBoxBtn->setTrigger(&touchTrigger, 0);
scrollbarBoxBtn->setTrigger(&wpadTouchTrigger, 1);
scrollbarBoxBtn->setEffectGrow();
scrollbarBoxBtn->held.connect(this, &Scrollbar::OnBoxButtonHold);
scrollbarBoxBtn->held.connect(this, &GuiScrollbar::OnBoxButtonHold);
}
Scrollbar::~Scrollbar()
GuiScrollbar::~GuiScrollbar()
{
Resources::RemoveSound(btnSoundClick);
Resources::RemoveImageData(scrollbarLine);
@ -111,7 +111,7 @@ Scrollbar::~Scrollbar()
delete scrollbarBoxImg;
}
void Scrollbar::ScrollOneUp()
void GuiScrollbar::ScrollOneUp()
{
if(SelItem == 0 && SelInd > 0)
{
@ -124,7 +124,7 @@ void Scrollbar::ScrollOneUp()
}
}
void Scrollbar::ScrollOneDown()
void GuiScrollbar::ScrollOneDown()
{
if(SelInd+SelItem + 1 < EntrieCount)
{
@ -140,7 +140,7 @@ void Scrollbar::ScrollOneDown()
}
}
void Scrollbar::OnUpButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
void GuiScrollbar::OnUpButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
if(ScrollState < ScrollSpeed)
return;
@ -151,7 +151,7 @@ void Scrollbar::OnUpButtonClick(GuiButton *button, const GuiController *controll
listChanged(SelItem, SelInd);
}
void Scrollbar::OnDownButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
void GuiScrollbar::OnDownButtonClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
if(ScrollState < ScrollSpeed)
return;
@ -162,7 +162,7 @@ void Scrollbar::OnDownButtonClick(GuiButton *button, const GuiController *contro
listChanged(SelItem, SelInd);
}
void Scrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
void GuiScrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
if(EntrieCount == 0){
return;
@ -207,7 +207,7 @@ void Scrollbar::OnBoxButtonHold(GuiButton *button, const GuiController *controll
listChanged(SelItem, SelInd);
}
void Scrollbar::SetPageSize(s32 size)
void GuiScrollbar::SetPageSize(s32 size)
{
if(PageSize == size)
return;
@ -216,7 +216,7 @@ void Scrollbar::SetPageSize(s32 size)
listChanged(SelItem, SelInd);
}
void Scrollbar::SetSelectedItem(s32 pos)
void GuiScrollbar::SetSelectedItem(s32 pos)
{
if(SelItem == pos)
return;
@ -225,7 +225,7 @@ void Scrollbar::SetSelectedItem(s32 pos)
listChanged(SelItem, SelInd);
}
void Scrollbar::SetSelectedIndex(s32 pos)
void GuiScrollbar::SetSelectedIndex(s32 pos)
{
if(SelInd == pos)
return;
@ -234,7 +234,7 @@ void Scrollbar::SetSelectedIndex(s32 pos)
listChanged(SelItem, SelInd);
}
void Scrollbar::SetEntrieCount(s32 cnt)
void GuiScrollbar::SetEntrieCount(s32 cnt)
{
if(EntrieCount == cnt)
return;
@ -243,7 +243,7 @@ void Scrollbar::SetEntrieCount(s32 cnt)
listChanged(SelItem, SelInd);
}
void Scrollbar::setScrollboxPosition(s32 SelItem, s32 SelInd)
void GuiScrollbar::setScrollboxPosition(s32 SelItem, s32 SelInd)
{
s32 position = MaxHeight-(MaxHeight-MinHeight)*(SelInd+SelItem)/(EntrieCount-1);
@ -255,7 +255,7 @@ void Scrollbar::setScrollboxPosition(s32 SelItem, s32 SelInd)
scrollbarBoxBtn->setPosition(0, position);
}
void Scrollbar::draw(CVideo * video)
void GuiScrollbar::draw(CVideo * video)
{
scrollbarLineImg->draw(video);
arrowUpBtn->draw(video);
@ -265,7 +265,7 @@ void Scrollbar::draw(CVideo * video)
updateEffects();
}
void Scrollbar::update(GuiController * t)
void GuiScrollbar::update(GuiController * t)
{
if(this->isStateSet(STATE_DISABLED))
return;

View File

@ -27,11 +27,11 @@
#include "gui/GuiElement.h"
#include "gui/GuiButton.h"
class Scrollbar : public GuiElement, public sigslot::has_slots<>
class GuiScrollbar : public GuiElement, public sigslot::has_slots<>
{
public:
Scrollbar(s32 height);
virtual ~Scrollbar();
GuiScrollbar(s32 height);
virtual ~GuiScrollbar();
void ScrollOneUp();
void ScrollOneDown();
s32 GetSelectedItem() { return SelItem; }

View File

@ -16,17 +16,20 @@
****************************************************************************/
#include <vector>
#include <string>
#include <utils/StringTools.h>
#include <utils/logger.h>
#include "GuiSelectBox.h"
#include "GuiImage.h"
#include "GuiTrigger.h"
#include "GuiImageData.h"
#include "utils/StringTools.h"
/**
* Constructor for the GuiCheckBox class.
*/
GuiSelectBox::GuiSelectBox(std::string caption,GuiFrame *parent)
: GuiFrame(0,0,parent)
GuiSelectBox::GuiSelectBox(GuiImage * background,std::string caption,f32 width,f32 height,GuiFrame *parent)
: GuiFrame(width,height,parent)
,selected(0)
,captionText(caption)
,topValueButton(0,0)
@ -38,6 +41,7 @@ GuiSelectBox::GuiSelectBox(std::string caption,GuiFrame *parent)
,buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true)
,DPADButtons(0,0)
{
setImageTopBackground(background);
showValues = false;
bChanged = false;
bSelectedChanged = false;
@ -67,6 +71,11 @@ GuiSelectBox::GuiSelectBox(std::string caption,GuiFrame *parent)
bChanged = true;
}
void GuiSelectBox::setSize(f32 width,f32 height){
GuiFrame::setSize(width,height);
topValueButton.setSize(width,height);
}
void GuiSelectBox::OnValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger){
for(u32 i = 0; i < valueButtons.size(); ++i){
if(valueButtons[i].valueButton == button){
@ -237,11 +246,17 @@ void GuiSelectBox::OnValueCloseEffectFinish(GuiElement *element)
}
f32 GuiSelectBox::getTopValueHeight() {
return topBackgroundImg == NULL ? 0 : topBackgroundImg->getHeight();
if(topBackgroundImg == NULL){
return 0.0f;
}
return topBackgroundImg->getHeight();
}
f32 GuiSelectBox::getTopValueWidth() {
return topBackgroundImg == NULL ? 0 : topBackgroundImg->getWidth();
if(topBackgroundImg == NULL){
return 0.0f;
}
return topBackgroundImg->getWidth();
}
f32 GuiSelectBox::getHeight(){

View File

@ -26,7 +26,7 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>{
public:
//!Constructor
//!\param checked Checked
GuiSelectBox(std::string caption,GuiFrame *parent = 0);
GuiSelectBox(GuiImage * background, std::string caption,f32 width = 0.0f, f32 height = 0.0f,GuiFrame *parent = 0);
//!Destructor
virtual ~GuiSelectBox();
@ -35,10 +35,6 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>{
void setImageTopBackground(GuiImage * img){
topBackgroundImg = img;
if(img != NULL){
setSize(img->getWidth(),img->getHeight());
topValueButton.setSize(img->getWidth(),img->getHeight());
}
topValueButton.setImage(img);
}
@ -69,6 +65,7 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>{
void setState(s32 s, s32 c = -1);
virtual void setSize(f32 width, f32 height);
virtual f32 getTopValueHeight();
virtual f32 getTopValueWidth();
@ -94,13 +91,13 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>{
bool opened;
std::string captionText;
GuiFrame valuesFrame;
GuiImage* topBackgroundImg;
GuiImage* topHighlightedImg;
GuiImage* topBackgroundImg = NULL;
GuiImage* topHighlightedImg = NULL;
GuiButton topValueButton;
GuiImageData * valueImageData;
GuiImageData * valueSelectedImageData;
GuiImageData * valueHighlightedImageData;
GuiImageData * valueImageData = NULL;
GuiImageData * valueSelectedImageData = NULL;
GuiImageData * valueHighlightedImageData = NULL;
GuiText topValueText;
GuiTrigger touchTrigger;

View File

@ -22,9 +22,9 @@
* Constructor for the GuiSwitch class.
*/
GuiSwitch::GuiSwitch(bool checked,f32 w, f32 h)
GuiSwitch::GuiSwitch(GuiImage * background,bool checked,f32 w, f32 h)
: GuiToggle(checked,w,h){
setImageBackground(background);
}
/**
* Destructor for the GuiSwitch class.
@ -35,10 +35,7 @@ GuiSwitch::~GuiSwitch(){
void GuiSwitch::setImageBackground(GuiImage* img){
backgroundImg = img;
if(img){
img->setParent(this);
}
if(img){ img->setParent(this); }
setImage(img);
}

View File

@ -26,7 +26,7 @@ class GuiSwitch : public GuiToggle{
public:
//!Constructor
//!\param checked Checked
GuiSwitch(bool checked,f32 w = 0.0f, f32 h = 0.0f);
GuiSwitch(GuiImage * background, bool checked, f32 w = 0.0f, f32 h = 0.0f);
//!Destructor
virtual ~GuiSwitch();
@ -37,13 +37,12 @@ class GuiSwitch : public GuiToggle{
void setImageOff(GuiImage* img);
void setImageHighlighted(GuiImage* img);
protected:
GuiImage * backgroundImg;
GuiImage * onImg;
GuiImage * offImg;
GuiImage * highlightedImg;
GuiImage * backgroundImg = NULL;
GuiImage * onImg = NULL;
GuiImage * offImg = NULL;
GuiImage * highlightedImg = NULL;
void draw(CVideo * v);
};

View File

@ -7,7 +7,6 @@
#include <fs/FSUtils.h>
#include "gui/GuiImageAsync.h"
#include "gui/GuiSound.h"
#include "utils/logger.h"
Resources * Resources::instance = NULL;
@ -65,7 +64,6 @@ bool Resources::LoadFiles(const char * path)
const u8 * Resources::GetFile(const char * filename)
{
DEBUG_FUNCTION_LINE(".\n");
ResourceFile * ResourceList = getResourceList();
if(ResourceList == NULL) return NULL;