mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-01 11:38:52 +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");
|
||||
}
|
||||
|
||||
bool Component::mustRender()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Component::isMenuScrolling()
|
||||
{
|
||||
return (!currentTweenComplete_ && animationType_ == "menuScroll");
|
||||
|
||||
@ -33,6 +33,7 @@ public:
|
||||
virtual void allocateGraphicsMemory();
|
||||
virtual void deInitializeFonts();
|
||||
virtual void initializeFonts();
|
||||
virtual bool mustRender();
|
||||
void triggerEvent(std::string event, int menuIndex = -1);
|
||||
void setPlaylist(std::string name );
|
||||
void setNewItemSelected();
|
||||
|
||||
@ -464,6 +464,7 @@ void ReloadableScrollingText::draw( )
|
||||
//SDL_Texture *t = font->getTexture( );
|
||||
SDL_Surface *t = font->getTexture( );
|
||||
|
||||
float imageHeight = 0;
|
||||
float imageWidth = 0;
|
||||
float imageMaxWidth = 0;
|
||||
float imageMaxHeight = 0;
|
||||
@ -484,12 +485,59 @@ void ReloadableScrollingText::draw( )
|
||||
imageMaxHeight = baseViewInfo.MaxHeight;
|
||||
}
|
||||
|
||||
imageHeight = (float)font->getHeight( );
|
||||
|
||||
//float scale = (float)baseViewInfo.FontSize / (float)font->getHeight( ) / scaleY_;
|
||||
//TODO, modify for scaling - for now, no scaling in effect
|
||||
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 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;
|
||||
|
||||
@ -518,12 +566,14 @@ void ReloadableScrollingText::draw( )
|
||||
|
||||
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))
|
||||
{
|
||||
SDL_Rect charRect = glyph.rect;
|
||||
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 );
|
||||
|
||||
/*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
|
||||
}
|
||||
/*else{
|
||||
rect.x += 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( );
|
||||
void update(float dt);
|
||||
void draw( );
|
||||
bool mustRender( );
|
||||
void allocateGraphicsMemory( );
|
||||
void freeGraphicsMemory( );
|
||||
void deInitializeFonts();
|
||||
|
||||
@ -128,7 +128,6 @@ void Text::draw( )
|
||||
ss << "Could not find Glyph info for char: " << textData_[i];
|
||||
Logger::write(Logger::ZONE_WARNING, "Text", ss.str());*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float oldWidth = baseViewInfo.Width;
|
||||
@ -144,6 +143,8 @@ void Text::draw( )
|
||||
float xOrigin = baseViewInfo.XRelativeToOrigin( );
|
||||
float yOrigin = baseViewInfo.YRelativeToOrigin( );
|
||||
|
||||
//printf("IN TEXT %s - xOrigin=%f, yOrigin=%f\n",textData_.c_str(), xOrigin, yOrigin);
|
||||
|
||||
baseViewInfo.Width = oldWidth;
|
||||
baseViewInfo.Height = oldHeight;
|
||||
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 idle = true;
|
||||
@ -1043,9 +1056,9 @@ void Page::update(float dt)
|
||||
|
||||
if(textStatusComponent_)
|
||||
{
|
||||
std::string status;
|
||||
config_.setProperty("status", status);
|
||||
textStatusComponent_->setText(status);
|
||||
std::string status;
|
||||
config_.setProperty("status", status);
|
||||
textStatusComponent_->setText(status);
|
||||
}
|
||||
|
||||
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
|
||||
|
||||
@ -80,6 +80,7 @@ public:
|
||||
void setScrollOffsetIndex(unsigned int i);
|
||||
unsigned int getScrollOffsetIndex();
|
||||
bool isIdle();
|
||||
bool mustRender();
|
||||
bool isGraphicsIdle();
|
||||
bool isMenuIdle();
|
||||
void setStatusTextComponent(Text *t);
|
||||
|
||||
@ -739,6 +739,7 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
{
|
||||
c->setMenuScrollReload(true);
|
||||
}
|
||||
c->allocateGraphicsMemory( );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -991,8 +991,9 @@ void RetroFE::run( )
|
||||
}
|
||||
|
||||
// ------- Check if previous update of page needed to be rendered -------
|
||||
if(!currentPage_->isIdle( ) || splashMode){
|
||||
forceRender(true);
|
||||
if(!currentPage_->isIdle( ) || currentPage_->mustRender( ) || splashMode){
|
||||
//printf("Not idle\n");
|
||||
forceRender(true);
|
||||
}
|
||||
|
||||
// Force refresh variables
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user