mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-02-19 15:51:32 +01:00
relloadableScrollingText now centered with xOrigin and yOrigin, spaces in reloadableScrollingText, reloadableScrollingText now has the power to force screen renderings
Signed-off-by: Vincent-FK <vincent.buso@funkey-project.com>
This commit is contained in:
parent
909b7a4dbd
commit
37e0a0a31d
@ -144,6 +144,11 @@ bool Component::isIdle()
|
|||||||
return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle");
|
return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Component::mustRender()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Component::isMenuScrolling()
|
bool Component::isMenuScrolling()
|
||||||
{
|
{
|
||||||
return (!currentTweenComplete_ && animationType_ == "menuScroll");
|
return (!currentTweenComplete_ && animationType_ == "menuScroll");
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public:
|
|||||||
virtual void allocateGraphicsMemory();
|
virtual void allocateGraphicsMemory();
|
||||||
virtual void deInitializeFonts();
|
virtual void deInitializeFonts();
|
||||||
virtual void initializeFonts();
|
virtual void initializeFonts();
|
||||||
|
virtual bool mustRender();
|
||||||
void triggerEvent(std::string event, int menuIndex = -1);
|
void triggerEvent(std::string event, int menuIndex = -1);
|
||||||
void setPlaylist(std::string name );
|
void setPlaylist(std::string name );
|
||||||
void setNewItemSelected();
|
void setNewItemSelected();
|
||||||
|
|||||||
@ -464,6 +464,7 @@ void ReloadableScrollingText::draw( )
|
|||||||
//SDL_Texture *t = font->getTexture( );
|
//SDL_Texture *t = font->getTexture( );
|
||||||
SDL_Surface *t = font->getTexture( );
|
SDL_Surface *t = font->getTexture( );
|
||||||
|
|
||||||
|
float imageHeight = 0;
|
||||||
float imageWidth = 0;
|
float imageWidth = 0;
|
||||||
float imageMaxWidth = 0;
|
float imageMaxWidth = 0;
|
||||||
float imageMaxHeight = 0;
|
float imageMaxHeight = 0;
|
||||||
@ -484,12 +485,59 @@ void ReloadableScrollingText::draw( )
|
|||||||
imageMaxHeight = baseViewInfo.MaxHeight;
|
imageMaxHeight = baseViewInfo.MaxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imageHeight = (float)font->getHeight( );
|
||||||
|
|
||||||
//float scale = (float)baseViewInfo.FontSize / (float)font->getHeight( ) / scaleY_;
|
//float scale = (float)baseViewInfo.FontSize / (float)font->getHeight( ) / scaleY_;
|
||||||
//TODO, modify for scaling - for now, no scaling in effect
|
//TODO, modify for scaling - for now, no scaling in effect
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
|
|
||||||
|
|
||||||
|
// determine image width from 1st line
|
||||||
|
for ( unsigned int i = 0; i < text_[0].size( ); ++i )
|
||||||
|
{
|
||||||
|
Font::GlyphInfo glyph;
|
||||||
|
if ( font->getRect( text_[0][i], glyph ) )
|
||||||
|
{
|
||||||
|
if ( glyph.minX < 0 )
|
||||||
|
{
|
||||||
|
imageWidth += glyph.minX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (imageWidth + glyph.advance)*scale > imageMaxWidth )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
imageWidth += glyph.advance;
|
||||||
|
|
||||||
|
/*printf("textData_[%d]=%c, glyph.advance= %f - %d\n", i, textData_[i], glyph.advance, glyph.advance);
|
||||||
|
printf("imageWidth=%f \n", imageWidth);*/
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
/*std::stringstream ss;
|
||||||
|
ss << "Could not find Glyph info for char: " << textData_[i];
|
||||||
|
Logger::write(Logger::ZONE_WARNING, "Text", ss.str());*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float oldWidth = baseViewInfo.Width;
|
||||||
|
float oldHeight = baseViewInfo.Height;
|
||||||
|
float oldImageWidth = baseViewInfo.ImageHeight;
|
||||||
|
float oldImageHeight = baseViewInfo.ImageWidth;
|
||||||
|
|
||||||
|
baseViewInfo.Width = imageWidth*scale;
|
||||||
|
baseViewInfo.Height = baseViewInfo.FontSize;
|
||||||
|
baseViewInfo.ImageWidth = imageWidth;
|
||||||
|
baseViewInfo.ImageHeight = imageHeight;
|
||||||
|
|
||||||
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
||||||
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
||||||
|
//printf("IN SCROLLABLE_TEXT - xOrigin=%f, yOrigin=%f, imageWidth=%f\n", xOrigin, yOrigin, imageWidth);
|
||||||
|
|
||||||
|
baseViewInfo.Width = oldWidth;
|
||||||
|
baseViewInfo.Height = oldHeight;
|
||||||
|
baseViewInfo.ImageWidth = oldImageWidth;
|
||||||
|
baseViewInfo.ImageHeight = oldImageHeight;
|
||||||
|
|
||||||
|
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
|
|
||||||
@ -518,12 +566,14 @@ void ReloadableScrollingText::draw( )
|
|||||||
|
|
||||||
Font::GlyphInfo glyph;
|
Font::GlyphInfo glyph;
|
||||||
|
|
||||||
|
//printf("text_[%d][%d] = %c, 0x%02X\n", l, i, text_[l][i], text_[l][i]);
|
||||||
|
|
||||||
//if (font->getRect( text_[l][i], glyph) && glyph.rect.h > 0)
|
//if (font->getRect( text_[l][i], glyph) && glyph.rect.h > 0)
|
||||||
if (font->getRect( text_[l][i], glyph))
|
if (font->getRect( text_[l][i], glyph))
|
||||||
{
|
{
|
||||||
SDL_Rect charRect = glyph.rect;
|
SDL_Rect charRect = glyph.rect;
|
||||||
rect.h = static_cast<int>( charRect.h * scale * scaleY_ );
|
rect.h = static_cast<int>( charRect.h * scale * scaleY_ );
|
||||||
rect.w = static_cast<int>( charRect.w * scale * scaleX_ );
|
rect.w = static_cast<int>( charRect.w?charRect.w:glyph.advance * scale * scaleX_ );
|
||||||
rect.y = static_cast<int>( yOrigin );
|
rect.y = static_cast<int>( yOrigin );
|
||||||
|
|
||||||
/*if (font->getAscent( ) < glyph.maxY)
|
/*if (font->getAscent( ) < glyph.maxY)
|
||||||
@ -558,6 +608,9 @@ void ReloadableScrollingText::draw( )
|
|||||||
{
|
{
|
||||||
rect.x = static_cast<int>( xOrigin ) + static_cast<int>( imageMaxWidth ) + 10; // Stop handling the rest of the string
|
rect.x = static_cast<int>( xOrigin ) + static_cast<int>( imageMaxWidth ) + 10; // Stop handling the rest of the string
|
||||||
}
|
}
|
||||||
|
/*else{
|
||||||
|
rect.x += glyph.advance * scale * scaleX_;
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
position += glyph.advance * scale * scaleX_;
|
position += glyph.advance * scale * scaleX_;
|
||||||
|
|
||||||
@ -800,3 +853,15 @@ void ReloadableScrollingText::draw( )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReloadableScrollingText::mustRender( )
|
||||||
|
{
|
||||||
|
if ( Component::mustRender( ) ) return true;
|
||||||
|
|
||||||
|
if (!text_.empty( ) && waitEndTime_ <= 0.0f && baseViewInfo.Alpha > 0.0f)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ public:
|
|||||||
virtual ~ReloadableScrollingText( );
|
virtual ~ReloadableScrollingText( );
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
void draw( );
|
void draw( );
|
||||||
|
bool mustRender( );
|
||||||
void allocateGraphicsMemory( );
|
void allocateGraphicsMemory( );
|
||||||
void freeGraphicsMemory( );
|
void freeGraphicsMemory( );
|
||||||
void deInitializeFonts();
|
void deInitializeFonts();
|
||||||
|
|||||||
@ -128,7 +128,6 @@ void Text::draw( )
|
|||||||
ss << "Could not find Glyph info for char: " << textData_[i];
|
ss << "Could not find Glyph info for char: " << textData_[i];
|
||||||
Logger::write(Logger::ZONE_WARNING, "Text", ss.str());*/
|
Logger::write(Logger::ZONE_WARNING, "Text", ss.str());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float oldWidth = baseViewInfo.Width;
|
float oldWidth = baseViewInfo.Width;
|
||||||
@ -144,6 +143,8 @@ void Text::draw( )
|
|||||||
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
||||||
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
||||||
|
|
||||||
|
//printf("IN TEXT %s - xOrigin=%f, yOrigin=%f\n",textData_.c_str(), xOrigin, yOrigin);
|
||||||
|
|
||||||
baseViewInfo.Width = oldWidth;
|
baseViewInfo.Width = oldWidth;
|
||||||
baseViewInfo.Height = oldHeight;
|
baseViewInfo.Height = oldHeight;
|
||||||
baseViewInfo.ImageWidth = oldImageWidth;
|
baseViewInfo.ImageWidth = oldImageWidth;
|
||||||
|
|||||||
@ -275,6 +275,19 @@ bool Page::isIdle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Page::mustRender()
|
||||||
|
{
|
||||||
|
bool render = false;
|
||||||
|
|
||||||
|
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
||||||
|
{
|
||||||
|
render = (*it)->mustRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
return render;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Page::isGraphicsIdle()
|
bool Page::isGraphicsIdle()
|
||||||
{
|
{
|
||||||
bool idle = true;
|
bool idle = true;
|
||||||
@ -1043,9 +1056,9 @@ void Page::update(float dt)
|
|||||||
|
|
||||||
if(textStatusComponent_)
|
if(textStatusComponent_)
|
||||||
{
|
{
|
||||||
std::string status;
|
std::string status;
|
||||||
config_.setProperty("status", status);
|
config_.setProperty("status", status);
|
||||||
textStatusComponent_->setText(status);
|
textStatusComponent_->setText(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
||||||
|
|||||||
@ -80,6 +80,7 @@ public:
|
|||||||
void setScrollOffsetIndex(unsigned int i);
|
void setScrollOffsetIndex(unsigned int i);
|
||||||
unsigned int getScrollOffsetIndex();
|
unsigned int getScrollOffsetIndex();
|
||||||
bool isIdle();
|
bool isIdle();
|
||||||
|
bool mustRender();
|
||||||
bool isGraphicsIdle();
|
bool isGraphicsIdle();
|
||||||
bool isMenuIdle();
|
bool isMenuIdle();
|
||||||
void setStatusTextComponent(Text *t);
|
void setStatusTextComponent(Text *t);
|
||||||
|
|||||||
@ -739,6 +739,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
|||||||
{
|
{
|
||||||
c->setMenuScrollReload(true);
|
c->setMenuScrollReload(true);
|
||||||
}
|
}
|
||||||
|
c->allocateGraphicsMemory( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -991,8 +991,9 @@ void RetroFE::run( )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------- Check if previous update of page needed to be rendered -------
|
// ------- Check if previous update of page needed to be rendered -------
|
||||||
if(!currentPage_->isIdle( ) || splashMode){
|
if(!currentPage_->isIdle( ) || currentPage_->mustRender( ) || splashMode){
|
||||||
forceRender(true);
|
//printf("Not idle\n");
|
||||||
|
forceRender(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force refresh variables
|
// Force refresh variables
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user