mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-17 16:59:17 +01:00
Added mutex/mutexlock to synchronize the GuiThreads and the MainThread, again clockfont edited (bearing of "1")
This commit is contained in:
parent
c223287548
commit
1768998644
Binary file not shown.
@ -374,6 +374,11 @@ class GuiElement
|
||||
virtual void Draw();
|
||||
virtual void DrawTooltip();
|
||||
protected:
|
||||
void Lock();
|
||||
void Unlock();
|
||||
mutex_t mutex;
|
||||
friend class SimpleLock;
|
||||
|
||||
//int position2; //! B Scrollbariable
|
||||
bool visible; //!< Visibility of the element. If false, Draw() is skipped
|
||||
int focus; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
|
||||
@ -409,6 +414,15 @@ class GuiElement
|
||||
GuiElement * parentElement; //!< Parent element
|
||||
UpdateCallback updateCB; //!< Callback function to call when this element is updated
|
||||
};
|
||||
class SimpleLock
|
||||
{
|
||||
public:
|
||||
SimpleLock(GuiElement *e);
|
||||
~SimpleLock();
|
||||
private:
|
||||
GuiElement *element;
|
||||
};
|
||||
#define LOCK(e) SimpleLock LOCK(e)
|
||||
|
||||
//!Allows GuiElements to be grouped together into a "window"
|
||||
class GuiWindow : public GuiElement
|
||||
@ -622,7 +636,11 @@ class GuiText : public GuiElement
|
||||
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
|
||||
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
|
||||
void SetAlignment(int hor, int vert);
|
||||
//!Sets the font
|
||||
//!\param f Font
|
||||
void SetFont(FreeTypeGX *f);
|
||||
//!Get the Horizontal Size of Text
|
||||
int GetTextWidth();
|
||||
//!Constantly called to draw the text
|
||||
void Draw();
|
||||
protected:
|
||||
@ -634,6 +652,32 @@ class GuiText : public GuiElement
|
||||
FreeTypeGX *font;
|
||||
};
|
||||
|
||||
//!Display, manage, and manipulate tooltips in the GUI.
|
||||
class GuiTooltip : public GuiElement
|
||||
{
|
||||
public:
|
||||
//!Constructor
|
||||
//!\param t Text
|
||||
GuiTooltip(const char *t);
|
||||
|
||||
//!Destructor
|
||||
~ GuiTooltip();
|
||||
|
||||
//!Sets the text of the GuiTooltip element
|
||||
//!\param t Text
|
||||
void SetText(const char * t);
|
||||
//!Constantly called to draw the GuiButton
|
||||
void Draw();
|
||||
|
||||
protected:
|
||||
static GuiImageData tooltipStd;
|
||||
static GuiImageData tooltipMedium;
|
||||
static GuiImageData tooltipLarge;
|
||||
GuiImage image; //!< Tooltip
|
||||
GuiText *text;
|
||||
};
|
||||
|
||||
|
||||
//!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)
|
||||
class GuiButton : public GuiElement
|
||||
{
|
||||
@ -698,6 +742,10 @@ class GuiButton : public GuiElement
|
||||
//!Sets the button's Tooltip on over
|
||||
//!\param i Pointer to GuiImage object, t Pointer to GuiText, x & y Positioning
|
||||
void SetToolTip(GuiImage* i, GuiText * t, int x, int y);
|
||||
//!Constantly called to draw the GuiButtons ToolTip
|
||||
//!Sets the button's Tooltip on over
|
||||
//!\param i Pointer to GuiImage object, t Pointer to GuiText, x & y Positioning
|
||||
void SetToolTip(GuiElement* tt, int x, int y, int h=ALIGN_RIGHT, int v=ALIGN_TOP);
|
||||
//!Constantly called to draw the GuiButton
|
||||
void Draw();
|
||||
void DrawTooltip();
|
||||
@ -717,6 +765,7 @@ class GuiButton : public GuiElement
|
||||
GuiImage * iconClick; //!< Button icon for STATE_CLICKED
|
||||
GuiImage * toolTip; //!< Tooltip for STATE_SELECTED
|
||||
GuiText * toolTipTxt;//!< Tooltip Text
|
||||
GuiElement *toolTip2;
|
||||
time_t time1, time2;//!< Tooltip timeconstants
|
||||
GuiText * label[3]; //!< Label(s) to display (default)
|
||||
GuiText * labelOver[3]; //!< Label(s) to display for STATE_SELECTED
|
||||
|
@ -29,6 +29,7 @@ GuiButton::GuiButton(int w, int h)
|
||||
iconHold = NULL;
|
||||
iconClick = NULL;
|
||||
toolTip = NULL;
|
||||
toolTip2 = NULL;
|
||||
toolTipTxt = NULL;
|
||||
|
||||
for(int i=0; i < 3; i++)
|
||||
@ -56,80 +57,96 @@ GuiButton::~GuiButton()
|
||||
|
||||
void GuiButton::SetImage(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
image = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetImageOver(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
imageOver = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetImageHold(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
imageHold = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetImageClick(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
imageClick = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetIcon(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
icon = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetIconOver(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
iconOver = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetIconHold(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
iconHold = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetIconClick(GuiImage* img)
|
||||
{
|
||||
LOCK(this);
|
||||
iconClick = img;
|
||||
if(img) img->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetLabel(GuiText* txt, int n)
|
||||
{
|
||||
LOCK(this);
|
||||
label[n] = txt;
|
||||
if(txt) txt->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetLabelOver(GuiText* txt, int n)
|
||||
{
|
||||
LOCK(this);
|
||||
labelOver[n] = txt;
|
||||
if(txt) txt->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetLabelHold(GuiText* txt, int n)
|
||||
{
|
||||
LOCK(this);
|
||||
labelHold[n] = txt;
|
||||
if(txt) txt->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetLabelClick(GuiText* txt, int n)
|
||||
{
|
||||
LOCK(this);
|
||||
labelClick[n] = txt;
|
||||
if(txt) txt->SetParent(this);
|
||||
}
|
||||
void GuiButton::SetSoundOver(GuiSound * snd)
|
||||
{
|
||||
LOCK(this);
|
||||
soundOver = snd;
|
||||
}
|
||||
void GuiButton::SetSoundHold(GuiSound * snd)
|
||||
{
|
||||
LOCK(this);
|
||||
soundHold = snd;
|
||||
}
|
||||
void GuiButton::SetSoundClick(GuiSound * snd)
|
||||
{
|
||||
LOCK(this);
|
||||
soundClick = snd;
|
||||
}
|
||||
|
||||
//No delay for now
|
||||
void GuiButton::SetToolTip(GuiImage* img, GuiText * txt, int x, int y)
|
||||
{
|
||||
LOCK(this);
|
||||
if(img)
|
||||
{
|
||||
|
||||
@ -145,11 +162,24 @@ void GuiButton::SetToolTip(GuiImage* img, GuiText * txt, int x, int y)
|
||||
|
||||
}
|
||||
}
|
||||
void GuiButton::SetToolTip(GuiElement* tt, int x, int y, int h_align, int v_align)
|
||||
{
|
||||
LOCK(this);
|
||||
if(tt)
|
||||
{
|
||||
toolTip2 = tt;
|
||||
toolTip2->SetParent(this);
|
||||
toolTip2->SetAlignment(h_align, v_align);
|
||||
toolTip2->SetPosition(x,y);
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Draw the button on screen
|
||||
*/
|
||||
void GuiButton::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -176,7 +206,8 @@ void GuiButton::Draw()
|
||||
}
|
||||
void GuiButton::DrawTooltip()
|
||||
{
|
||||
if(state == STATE_SELECTED && toolTip)
|
||||
LOCK(this);
|
||||
if(state == STATE_SELECTED && (toolTip || toolTip2))
|
||||
{
|
||||
if (time2 == 0)
|
||||
time(&time2);
|
||||
@ -184,29 +215,34 @@ void GuiButton::DrawTooltip()
|
||||
time(&time1);
|
||||
|
||||
if (difftime(time1, time2) >= 2) {
|
||||
toolTip->Draw();
|
||||
if(toolTip) toolTip->Draw();
|
||||
if(toolTip2) toolTip2->Draw();
|
||||
if (toolTipTxt)
|
||||
{
|
||||
toolTipTxt->Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
time2 = 0;
|
||||
}
|
||||
void GuiButton::ScrollIsOn(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
scrollison = f;
|
||||
}
|
||||
|
||||
void GuiButton::Update(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(state == STATE_CLICKED || state == STATE_DISABLED || !t)
|
||||
return;
|
||||
else if(parentElement && parentElement->GetState() == STATE_DISABLED)
|
||||
return;
|
||||
|
||||
if(state != STATE_SELECTED && toolTip) {
|
||||
time2 = 0;
|
||||
}
|
||||
// if(state != STATE_SELECTED && toolTip) {
|
||||
// time2 = 0;
|
||||
// }
|
||||
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
@ -190,12 +190,14 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
|
||||
|
||||
void GuiCustomOptionBrowser::SetCol2Position(int x)
|
||||
{
|
||||
LOCK(this);
|
||||
for(int i = 0; i < size; i++)
|
||||
optionVal[i]->SetPosition(x,0);
|
||||
}
|
||||
|
||||
void GuiCustomOptionBrowser::SetFocus(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
focus = f;
|
||||
|
||||
for(int i = 0; i < size; i++)
|
||||
@ -207,6 +209,7 @@ void GuiCustomOptionBrowser::SetFocus(int f)
|
||||
|
||||
void GuiCustomOptionBrowser::ResetState()
|
||||
{
|
||||
LOCK(this);
|
||||
if(state != STATE_DISABLED)
|
||||
{
|
||||
state = STATE_DEFAULT;
|
||||
@ -272,6 +275,7 @@ int GuiCustomOptionBrowser::FindMenuItem(int currentItem, int direction)
|
||||
*/
|
||||
void GuiCustomOptionBrowser::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -300,7 +304,9 @@ void GuiCustomOptionBrowser::Draw()
|
||||
}
|
||||
|
||||
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
|
||||
{ int next, prev, lang = options->length;
|
||||
{
|
||||
LOCK(this);
|
||||
int next, prev, lang = options->length;
|
||||
|
||||
if(state == STATE_DISABLED || !t)
|
||||
return;
|
||||
|
@ -55,6 +55,8 @@ GuiElement::GuiElement()
|
||||
// default alignment - align to top left
|
||||
alignmentVert = ALIGN_TOP;
|
||||
alignmentHor = ALIGN_LEFT;
|
||||
LWP_MutexInit(&mutex, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,10 +64,12 @@ GuiElement::GuiElement()
|
||||
*/
|
||||
GuiElement::~GuiElement()
|
||||
{
|
||||
LWP_MutexDestroy(mutex);
|
||||
}
|
||||
|
||||
void GuiElement::SetParent(GuiElement * e)
|
||||
{
|
||||
LOCK(this);
|
||||
parentElement = e;
|
||||
}
|
||||
/**
|
||||
@ -140,6 +144,7 @@ int GuiElement::GetTop()
|
||||
|
||||
void GuiElement::SetMinX(int x)
|
||||
{
|
||||
LOCK(this);
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
@ -150,6 +155,7 @@ int GuiElement::GetMinX()
|
||||
|
||||
void GuiElement::SetMaxX(int x)
|
||||
{
|
||||
LOCK(this);
|
||||
xmax = x;
|
||||
}
|
||||
|
||||
@ -160,6 +166,7 @@ int GuiElement::GetMaxX()
|
||||
|
||||
void GuiElement::SetMinY(int y)
|
||||
{
|
||||
LOCK(this);
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
@ -170,6 +177,7 @@ int GuiElement::GetMinY()
|
||||
|
||||
void GuiElement::SetMaxY(int y)
|
||||
{
|
||||
LOCK(this);
|
||||
ymax = y;
|
||||
}
|
||||
|
||||
@ -207,6 +215,7 @@ int GuiElement::GetHeight()
|
||||
*/
|
||||
void GuiElement::SetSize(int w, int h)
|
||||
{
|
||||
LOCK(this);
|
||||
|
||||
width = w;
|
||||
height = h;
|
||||
@ -229,11 +238,13 @@ bool GuiElement::IsVisible()
|
||||
*/
|
||||
void GuiElement::SetVisible(bool v)
|
||||
{
|
||||
LOCK(this);
|
||||
visible = v;
|
||||
}
|
||||
|
||||
void GuiElement::SetAlpha(int a)
|
||||
{
|
||||
LOCK(this);
|
||||
alpha = a;
|
||||
}
|
||||
|
||||
@ -254,6 +265,7 @@ int GuiElement::GetAlpha()
|
||||
|
||||
void GuiElement::SetScale(float s)
|
||||
{
|
||||
LOCK(this);
|
||||
scale = s;
|
||||
}
|
||||
|
||||
@ -279,12 +291,14 @@ int GuiElement::GetStateChan()
|
||||
|
||||
void GuiElement::SetState(int s, int c)
|
||||
{
|
||||
LOCK(this);
|
||||
state = s;
|
||||
stateChan = c;
|
||||
}
|
||||
|
||||
void GuiElement::ResetState()
|
||||
{
|
||||
LOCK(this);
|
||||
if(state != STATE_DISABLED)
|
||||
{
|
||||
state = STATE_DEFAULT;
|
||||
@ -294,16 +308,19 @@ void GuiElement::ResetState()
|
||||
|
||||
void GuiElement::SetClickable(bool c)
|
||||
{
|
||||
LOCK(this);
|
||||
clickable = c;
|
||||
}
|
||||
|
||||
void GuiElement::SetSelectable(bool s)
|
||||
{
|
||||
LOCK(this);
|
||||
selectable = s;
|
||||
}
|
||||
|
||||
void GuiElement::SetHoldable(bool d)
|
||||
{
|
||||
LOCK(this);
|
||||
holdable = d;
|
||||
}
|
||||
|
||||
@ -335,6 +352,7 @@ bool GuiElement::IsHoldable()
|
||||
|
||||
void GuiElement::SetFocus(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
focus = f;
|
||||
}
|
||||
|
||||
@ -345,6 +363,7 @@ int GuiElement::IsFocused()
|
||||
|
||||
void GuiElement::SetTrigger(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(!trigger[0])
|
||||
trigger[0] = t;
|
||||
else if(!trigger[1])
|
||||
@ -363,6 +382,7 @@ void GuiElement::SetTrigger(GuiTrigger * t)
|
||||
|
||||
void GuiElement::SetTrigger(u8 i, GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
trigger[i] = t;
|
||||
}
|
||||
|
||||
@ -373,6 +393,7 @@ bool GuiElement::Rumble()
|
||||
|
||||
void GuiElement::SetRumble(bool r)
|
||||
{
|
||||
LOCK(this);
|
||||
rumble = r;
|
||||
}
|
||||
|
||||
@ -383,6 +404,7 @@ int GuiElement::GetEffect()
|
||||
|
||||
void GuiElement::SetEffect(int eff, int amount, int target)
|
||||
{
|
||||
LOCK(this);
|
||||
if(eff & EFFECT_SLIDE_IN)
|
||||
{
|
||||
// these calculations overcompensate a little
|
||||
@ -411,6 +433,7 @@ void GuiElement::SetEffect(int eff, int amount, int target)
|
||||
|
||||
void GuiElement::SetEffectOnOver(int eff, int amount, int target)
|
||||
{
|
||||
LOCK(this);
|
||||
effectsOver |= eff;
|
||||
effectAmountOver = amount;
|
||||
effectTargetOver = target;
|
||||
@ -423,6 +446,7 @@ void GuiElement::SetEffectGrow()
|
||||
|
||||
void GuiElement::UpdateEffects()
|
||||
{
|
||||
LOCK(this);
|
||||
if(effects & (EFFECT_SLIDE_IN | EFFECT_SLIDE_OUT))
|
||||
{
|
||||
if(effects & EFFECT_SLIDE_IN)
|
||||
@ -530,23 +554,27 @@ void GuiElement::UpdateEffects()
|
||||
|
||||
void GuiElement::Update(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(updateCB)
|
||||
updateCB(this);
|
||||
}
|
||||
|
||||
void GuiElement::SetUpdateCallback(UpdateCallback u)
|
||||
{
|
||||
LOCK(this);
|
||||
updateCB = u;
|
||||
}
|
||||
|
||||
void GuiElement::SetPosition(int xoff, int yoff)
|
||||
{
|
||||
LOCK(this);
|
||||
xoffset = xoff;
|
||||
yoffset = yoff;
|
||||
}
|
||||
|
||||
void GuiElement::SetAlignment(int hor, int vert)
|
||||
{
|
||||
LOCK(this);
|
||||
alignmentHor = hor;
|
||||
alignmentVert = vert;
|
||||
}
|
||||
@ -582,3 +610,21 @@ bool GuiElement::IsInside(int x, int y)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
void GuiElement::Lock()
|
||||
{
|
||||
LWP_MutexLock(mutex);
|
||||
}
|
||||
void GuiElement::Unlock()
|
||||
{
|
||||
LWP_MutexUnlock(mutex);
|
||||
}
|
||||
|
||||
|
||||
SimpleLock::SimpleLock(GuiElement *e) : element(e)
|
||||
{
|
||||
element->Lock();
|
||||
}
|
||||
SimpleLock::~SimpleLock()
|
||||
{
|
||||
element->Unlock();
|
||||
}
|
||||
|
@ -192,6 +192,7 @@ GuiGameBrowser::~GuiGameBrowser()
|
||||
|
||||
void GuiGameBrowser::SetFocus(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
focus = f;
|
||||
|
||||
for(int i=0; i<pagesize; i++)
|
||||
@ -203,6 +204,7 @@ void GuiGameBrowser::SetFocus(int f)
|
||||
|
||||
void GuiGameBrowser::ResetState()
|
||||
{
|
||||
LOCK(this);
|
||||
if(state != STATE_DISABLED)
|
||||
{
|
||||
state = STATE_DEFAULT;
|
||||
@ -273,6 +275,7 @@ int GuiGameBrowser::FindMenuItem(int currentItem, int direction)
|
||||
*/
|
||||
void GuiGameBrowser::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -302,6 +305,7 @@ void GuiGameBrowser::Draw()
|
||||
|
||||
void GuiGameBrowser::Update(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(state == STATE_DISABLED || !t)
|
||||
return;
|
||||
|
||||
|
@ -92,6 +92,9 @@ u8 * GuiImage::GetImage()
|
||||
|
||||
void GuiImage::SetImage(GuiImageData * img)
|
||||
{
|
||||
LOCK(this);
|
||||
if(imgType == IMAGE_COLOR && image)
|
||||
free(image);
|
||||
image = img->GetImage();
|
||||
width = img->GetWidth();
|
||||
height = img->GetHeight();
|
||||
@ -100,6 +103,9 @@ void GuiImage::SetImage(GuiImageData * img)
|
||||
|
||||
void GuiImage::SetImage(u8 * img, int w, int h)
|
||||
{
|
||||
LOCK(this);
|
||||
if(imgType == IMAGE_COLOR && image)
|
||||
free(image);
|
||||
image = img;
|
||||
width = w;
|
||||
height = h;
|
||||
@ -108,16 +114,19 @@ void GuiImage::SetImage(u8 * img, int w, int h)
|
||||
|
||||
void GuiImage::SetAngle(float a)
|
||||
{
|
||||
LOCK(this);
|
||||
imageangle = a;
|
||||
}
|
||||
|
||||
void GuiImage::SetTile(int t)
|
||||
{
|
||||
LOCK(this);
|
||||
tile = t;
|
||||
}
|
||||
|
||||
void GuiImage::SetWidescreen(short w)
|
||||
{
|
||||
LOCK(this);
|
||||
widescreen = w;
|
||||
}
|
||||
|
||||
@ -137,6 +146,7 @@ GXColor GuiImage::GetPixel(int x, int y)
|
||||
|
||||
void GuiImage::SetPixel(int x, int y, GXColor color)
|
||||
{
|
||||
LOCK(this);
|
||||
if(!image || this->GetWidth() <= 0 || x < 0 || y < 0)
|
||||
return;
|
||||
|
||||
@ -149,11 +159,13 @@ void GuiImage::SetPixel(int x, int y, GXColor color)
|
||||
|
||||
void GuiImage::SetStripe(int s)
|
||||
{
|
||||
LOCK(this);
|
||||
stripe = s;
|
||||
}
|
||||
|
||||
void GuiImage::ColorStripe(int shift)
|
||||
{
|
||||
LOCK(this);
|
||||
int x, y;
|
||||
GXColor color;
|
||||
int alt = 0;
|
||||
@ -211,6 +223,7 @@ void GuiImage::ColorStripe(int shift)
|
||||
*/
|
||||
void GuiImage::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!image || !this->IsVisible() || tile == 0)
|
||||
return;
|
||||
|
||||
|
@ -242,6 +242,7 @@ GuiKeyboard::~GuiKeyboard()
|
||||
|
||||
void GuiKeyboard::Update(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement))
|
||||
return;
|
||||
|
||||
|
@ -289,12 +289,14 @@ GuiOptionBrowser::~GuiOptionBrowser()
|
||||
|
||||
void GuiOptionBrowser::SetCol2Position(int x)
|
||||
{
|
||||
LOCK(this);
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
optionVal[i]->SetPosition(x,0);
|
||||
}
|
||||
|
||||
void GuiOptionBrowser::SetFocus(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
focus = f;
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
@ -306,6 +308,7 @@ void GuiOptionBrowser::SetFocus(int f)
|
||||
|
||||
void GuiOptionBrowser::ResetState()
|
||||
{
|
||||
LOCK(this);
|
||||
if(state != STATE_DISABLED)
|
||||
{
|
||||
state = STATE_DEFAULT;
|
||||
@ -372,6 +375,7 @@ int GuiOptionBrowser::FindMenuItem(int currentItem, int direction)
|
||||
*/
|
||||
void GuiOptionBrowser::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -400,7 +404,9 @@ void GuiOptionBrowser::Draw()
|
||||
}
|
||||
|
||||
void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
{ int next, prev, lang = options->length;
|
||||
{
|
||||
LOCK(this);
|
||||
int next, prev, lang = options->length;
|
||||
|
||||
//go to the last game selected
|
||||
if ((loaded == 0) && (startat>0))
|
||||
|
@ -72,9 +72,9 @@ GuiText::~GuiText()
|
||||
|
||||
void GuiText::SetText(const char * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(text)
|
||||
delete text;
|
||||
|
||||
text = NULL;
|
||||
|
||||
if(t)
|
||||
@ -93,27 +93,32 @@ void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v)
|
||||
|
||||
void GuiText::SetFontSize(int s)
|
||||
{
|
||||
LOCK(this);
|
||||
size = s;
|
||||
}
|
||||
|
||||
void GuiText::SetMaxWidth(int w)
|
||||
{
|
||||
LOCK(this);
|
||||
maxWidth = w;
|
||||
}
|
||||
|
||||
void GuiText::SetColor(GXColor c)
|
||||
{
|
||||
LOCK(this);
|
||||
color = c;
|
||||
alpha = c.a;
|
||||
}
|
||||
|
||||
void GuiText::SetStyle(u16 s)
|
||||
{
|
||||
LOCK(this);
|
||||
style = s;
|
||||
}
|
||||
|
||||
void GuiText::SetAlignment(int hor, int vert)
|
||||
{
|
||||
LOCK(this);
|
||||
style = 0;
|
||||
|
||||
switch(hor)
|
||||
@ -149,13 +154,30 @@ void GuiText::SetAlignment(int hor, int vert)
|
||||
*/
|
||||
void GuiText::SetFont(FreeTypeGX *f)
|
||||
{
|
||||
LOCK(this);
|
||||
font = f;
|
||||
}
|
||||
|
||||
int GuiText::GetTextWidth()
|
||||
{
|
||||
LOCK(this);
|
||||
int newSize = size*this->GetScale();
|
||||
|
||||
if(newSize != currentSize)
|
||||
{
|
||||
//fontSystem->changeSize(newSize);
|
||||
(font ? font : fontSystem)->changeSize(newSize);
|
||||
currentSize = newSize;
|
||||
}
|
||||
return (font ? font : fontSystem)->getWidth(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the text on screen
|
||||
*/
|
||||
void GuiText::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!text)
|
||||
return;
|
||||
|
||||
|
77
source/libwiigui/gui_tooltip.cpp
Normal file
77
source/libwiigui/gui_tooltip.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
* libwiigui
|
||||
*
|
||||
* Tantric 2009
|
||||
*
|
||||
* gui_tooltip.cpp
|
||||
*
|
||||
* GUI class definitions
|
||||
***************************************************************************/
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
GuiImageData GuiTooltip::tooltipStd(tooltip_png);
|
||||
GuiImageData GuiTooltip::tooltipMedium(tooltip_medium_png);
|
||||
GuiImageData GuiTooltip::tooltipLarge(tooltip_large_png);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the GuiTooltip class.
|
||||
*/
|
||||
GuiTooltip::GuiTooltip(const char *t)
|
||||
{
|
||||
text = NULL;
|
||||
image.SetParent(this);
|
||||
SetText(t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destructor for the GuiTooltip class.
|
||||
*/
|
||||
GuiTooltip::~GuiTooltip()
|
||||
{
|
||||
if(text) delete text;
|
||||
}
|
||||
|
||||
/* !Sets the text of the GuiTooltip element
|
||||
* !\param t Text
|
||||
*/
|
||||
void GuiTooltip::SetText(const char * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(text)
|
||||
{
|
||||
delete text;
|
||||
text = NULL;
|
||||
}
|
||||
int t_width = 24;
|
||||
if(t && (text = new GuiText(t, 22, (GXColor){0, 0, 0, 255})))
|
||||
{
|
||||
text->SetParent(this);
|
||||
t_width += text->GetTextWidth();
|
||||
}
|
||||
|
||||
if(t_width > tooltipMedium.GetWidth())
|
||||
image.SetImage(&tooltipLarge);
|
||||
else if(t_width > tooltipStd.GetWidth())
|
||||
image.SetImage(&tooltipMedium);
|
||||
else
|
||||
image.SetImage(&tooltipStd);
|
||||
image.SetPosition(0, 0);
|
||||
width = image.GetWidth();
|
||||
height = image.GetHeight();
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw the Tooltip on screen
|
||||
*/
|
||||
void GuiTooltip::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(!this->IsVisible()) return;
|
||||
|
||||
image.Draw();
|
||||
if(text) text->Draw();
|
||||
|
||||
this->UpdateEffects();
|
||||
}
|
@ -30,6 +30,7 @@ GuiWindow::~GuiWindow()
|
||||
|
||||
void GuiWindow::Append(GuiElement* e)
|
||||
{
|
||||
LOCK(this);
|
||||
if (e == NULL)
|
||||
return;
|
||||
|
||||
@ -40,6 +41,7 @@ void GuiWindow::Append(GuiElement* e)
|
||||
|
||||
void GuiWindow::Insert(GuiElement* e, u32 index)
|
||||
{
|
||||
LOCK(this);
|
||||
if (e == NULL || index > (_elements.size() - 1))
|
||||
return;
|
||||
|
||||
@ -50,6 +52,7 @@ void GuiWindow::Insert(GuiElement* e, u32 index)
|
||||
|
||||
void GuiWindow::Remove(GuiElement* e)
|
||||
{
|
||||
LOCK(this);
|
||||
if (e == NULL)
|
||||
return;
|
||||
|
||||
@ -65,6 +68,7 @@ void GuiWindow::Remove(GuiElement* e)
|
||||
|
||||
void GuiWindow::RemoveAll()
|
||||
{
|
||||
LOCK(this);
|
||||
_elements.clear();
|
||||
}
|
||||
|
||||
@ -82,6 +86,7 @@ u32 GuiWindow::GetSize()
|
||||
|
||||
void GuiWindow::Draw()
|
||||
{
|
||||
LOCK(this);
|
||||
if(_elements.size() == 0 || !this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -99,6 +104,7 @@ void GuiWindow::Draw()
|
||||
}
|
||||
void GuiWindow::DrawTooltip()
|
||||
{
|
||||
LOCK(this);
|
||||
if(_elements.size() == 0 || !this->IsVisible())
|
||||
return;
|
||||
|
||||
@ -110,6 +116,7 @@ void GuiWindow::DrawTooltip()
|
||||
}
|
||||
void GuiWindow::ResetState()
|
||||
{
|
||||
LOCK(this);
|
||||
if(state != STATE_DISABLED)
|
||||
state = STATE_DEFAULT;
|
||||
|
||||
@ -122,6 +129,7 @@ void GuiWindow::ResetState()
|
||||
|
||||
void GuiWindow::SetState(int s)
|
||||
{
|
||||
LOCK(this);
|
||||
state = s;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
@ -133,6 +141,7 @@ void GuiWindow::SetState(int s)
|
||||
|
||||
void GuiWindow::SetVisible(bool v)
|
||||
{
|
||||
LOCK(this);
|
||||
visible = v;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
@ -144,6 +153,7 @@ void GuiWindow::SetVisible(bool v)
|
||||
|
||||
void GuiWindow::SetFocus(int f)
|
||||
{
|
||||
LOCK(this);
|
||||
focus = f;
|
||||
|
||||
if(f == 1)
|
||||
@ -154,6 +164,7 @@ void GuiWindow::SetFocus(int f)
|
||||
|
||||
void GuiWindow::ChangeFocus(GuiElement* e)
|
||||
{
|
||||
LOCK(this);
|
||||
if(parentElement)
|
||||
return; // this is only intended for the main window
|
||||
|
||||
@ -168,6 +179,7 @@ void GuiWindow::ChangeFocus(GuiElement* e)
|
||||
|
||||
void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(parentElement)
|
||||
return; // this is only intended for the main window
|
||||
|
||||
@ -266,6 +278,7 @@ int GuiWindow::GetSelected()
|
||||
// there's probably a more clever way to do this, but this way works
|
||||
void GuiWindow::MoveSelectionHor(int dir)
|
||||
{
|
||||
LOCK(this);
|
||||
int found = -1;
|
||||
u16 left = 0;
|
||||
u16 top = 0;
|
||||
@ -335,6 +348,7 @@ void GuiWindow::MoveSelectionHor(int dir)
|
||||
|
||||
void GuiWindow::MoveSelectionVert(int dir)
|
||||
{
|
||||
LOCK(this);
|
||||
int found = -1;
|
||||
u16 left = 0;
|
||||
u16 top = 0;
|
||||
@ -386,6 +400,7 @@ void GuiWindow::MoveSelectionVert(int dir)
|
||||
|
||||
void GuiWindow::Update(GuiTrigger * t)
|
||||
{
|
||||
LOCK(this);
|
||||
if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement))
|
||||
return;
|
||||
|
||||
|
@ -2438,6 +2438,7 @@ static int MenuDiscList()
|
||||
GuiImageData ttsettings(tooltip_png);
|
||||
GuiImage ttsettingsImg(&ttsettings);
|
||||
ttsettingsImg.SetWidescreen(CFG.widescreen);
|
||||
GuiTooltip tt_settings("Settings");
|
||||
|
||||
GuiImage settingsBtnImg(&btnSettings);
|
||||
settingsBtnImg.SetWidescreen(CFG.widescreen); //added
|
||||
@ -2452,8 +2453,10 @@ static int MenuDiscList()
|
||||
settingsBtn.SetSoundClick(&btnClick);
|
||||
settingsBtn.SetTrigger(&trigA);
|
||||
settingsBtn.SetEffectGrow();
|
||||
// if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0)
|
||||
// settingsBtn.SetToolTip(&ttsettingsImg,&ttsettingsTxt,65,-30);
|
||||
if (Settings.tooltips == TooltipsOn && THEME.showToolTip != 0)
|
||||
settingsBtn.SetToolTip(&ttsettingsImg,&ttsettingsTxt,65,-30);
|
||||
settingsBtn.SetToolTip(&tt_settings,65,-30);
|
||||
|
||||
GuiText tthomeTxt("Back to HBC or Wii Menu", 22, (GXColor){0, 0, 0, 255}); //TOOLTIP DATA FOR HOME BUTTON
|
||||
GuiImageData tthome(tooltip_large_png);
|
||||
@ -2581,6 +2584,11 @@ static int MenuDiscList()
|
||||
gameBrowser.SetPosition(THEME.selection_x, THEME.selection_y);
|
||||
gameBrowser.SetAlignment(ALIGN_LEFT, ALIGN_CENTRE);
|
||||
|
||||
GuiText clockTimeBack("88:88", 40, (GXColor){138, 138, 138, 64});
|
||||
clockTimeBack.SetAlignment(THEME.clockAlign, ALIGN_BOTTOM);
|
||||
clockTimeBack.SetPosition(THEME.clock_x, THEME.clock_y);
|
||||
clockTimeBack.SetFont(fontClock);
|
||||
|
||||
GuiText clockTime(theTime, 40, (GXColor){138, 138, 138, 255});
|
||||
clockTime.SetAlignment(THEME.clockAlign, ALIGN_BOTTOM);
|
||||
clockTime.SetPosition(THEME.clock_x, THEME.clock_y);
|
||||
@ -2608,6 +2616,7 @@ static int MenuDiscList()
|
||||
|
||||
if(Settings.hddinfo == Clock)
|
||||
{
|
||||
w.Append(&clockTimeBack);
|
||||
w.Append(&clockTime);
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[],
|
||||
// guMtxConcat(m2,m1,m);
|
||||
guMtxConcat(m1,m2,m);
|
||||
|
||||
guMtxTransApply(m,m, xpos+width,ypos+height,0);
|
||||
guMtxTransApply(m,m, xpos+width+0.5,ypos+height+0.5,0);
|
||||
guMtxConcat (GXmodelView2D, m, mv);
|
||||
GX_LoadPosMtxImm (mv, GX_PNMTX0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user