Pre-resize fillparent

This commit is contained in:
2018-08-13 22:22:10 -04:00
parent 58fa6f0503
commit 353dc21750
95 changed files with 478 additions and 437 deletions
@@ -14,15 +14,15 @@ namespace TextTypeHelpers {
public:
cFontHolder( TTF_Font* font, const unsigned long int size );
~cFontHolder();
///Sets
///Gets
/// Sets
/// Gets
TTF_Font* getFont() const;
const unsigned long int getSize() const;
private:
TTF_Font* mp_font;// = nullptr
unsigned long int m_size;// = 16
TTF_Font* mp_font;/// = nullptr
unsigned long int m_size;/// = 16
};/// END CLASS DEFINITION cFontHolder
}/// END NAMESPACE DEFINITION TextTypeHelpers
#endif/// END IFNDEF _CFONTHOLDER_HPP_
@@ -24,8 +24,8 @@ cFont::~cFont()
UnloadFont();
}
///Functions
///Sets
/// Functions
/// Sets
void cFont::setDir( const cString& dir )
{
m_dir = dir;
@@ -50,7 +50,7 @@ void cFont::setSize( const unsigned long int size /*= 16*/ )
}
}
///Gets
/// Gets
const cString& cFont::getDir() const
{
return m_dir;
@@ -84,7 +84,23 @@ TTF_Font* cFont::getFont( const unsigned long int size )
return rtn;
}
//private:
bool cFont::operator == ( const cFont& rhs ) const
{
if ((this->m_dir == rhs.getDir()) && (this->m_fileName == rhs.getFileName()) && (this->getSize() == rhs.getSize()))
return true;
else
return false;
}
bool cFont::operator != ( const cFont& rhs ) const
{
if (*this == rhs)
return false;
else
return true;
}
/// private:
TTF_Font* cFont::LoadFont( const unsigned long int size )
{
TTF_Font* rtn = nullptr;
@@ -28,14 +28,14 @@ namespace TextTypeEngine {
class EXPORT_FROM_MYDLL cFont
{
public:
cFont(const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 );
cFont( const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 );
cFont( const cFont& copy );
~cFont();
///Functions
/// Functions
///Sets
/// Sets
/* Sets the Directory of the TTF file */
void setDir( const cString& dir );
/* Sets the Filename of the TTF file */
@@ -45,7 +45,7 @@ namespace TextTypeEngine {
/* Sets the size of the TTF. Default is 16 */
void setSize( const unsigned long int size = 16 );
///Gets
/// Gets
/* Gets the Directory of the TTF file */
const cString& getDir() const;
/* Gets the Filename of the TTF file */
@@ -56,6 +56,10 @@ namespace TextTypeEngine {
TTF_Font* getFont();
/* Gets the TTF_Font. */
TTF_Font* getFont( const unsigned long int size );
/// operators
bool operator == ( const cFont& rhs ) const;
bool operator != ( const cFont& rhs ) const;
private:
TTF_Font* LoadFont( const unsigned long int size );
@@ -66,9 +70,9 @@ namespace TextTypeEngine {
std::vector<TextTypeHelpers::cFontHolder*> m_fonts;
//cFontHolder m_fonts;
//cFont::cFontHolder m_fonts;
TextTypeHelpers::cFontHolder** mpp_default;
cString m_dir;// = ""
cString m_fileName;// = ""
TextTypeHelpers::cFontHolder** mpp_default;/// = nullptr
cString m_dir;/// = ""
cString m_fileName;/// = ""
};/// END CLASS DEFINITION cFont
}/// END NAMESPACE DEFINITION TextTypeEngine
@@ -43,7 +43,7 @@ cText::cText( const cText& copy )
cText::~cText()
{}
///Function
/// Function
void cText::White()
{
setColour(255, 255, 255);
@@ -69,18 +69,22 @@ void cText::Red()
setColour(255);
}
///Sets
/// Sets
void cText::setSize(const unsigned long int size /*= 8*/)
{
m_size = size;
if ((mpp_font != nullptr) && ((*mpp_font) != nullptr))
(*mpp_font)->setSize(size);
if (m_size != size) {
m_size = size;
if ((mpp_font != nullptr) && ((*mpp_font) != nullptr))
(*mpp_font)->setSize(size);
}
}
void cText::setFont( TextTypeEngine::cFont** font )
{
mpp_font = font;
Text();
if ((*mpp_font) != (*font)) {
mpp_font = font;
Text();
}
}
void cText::setText( const cString& text )
@@ -93,8 +97,10 @@ void cText::setText( const cString& text )
void cText::setColour( const SDL_Colour& colour )
{
m_colour = colour;
Text();
if ((colour.a != m_colour.a) || (colour.b != m_colour.b) || (colour.g != m_colour.g) || (colour.r != m_colour.r)){
m_colour = colour;
Text();
}
}
void cText::setColour( const unsigned long int red /*= 0*/, const unsigned long int green /*= 0*/, const unsigned long int blue /*= 0*/, unsigned long int alpha /*= 255*/ )
@@ -105,11 +111,13 @@ void cText::setColour( const unsigned long int red /*= 0*/, const unsigned long
void cText::setRender( const eRender& render /*= eRender::Solid*/ )
{
m_render = render;
Text();
if (m_render != render) {
m_render = render;
Text();
}
}
///Gets
/// Gets
const unsigned long int cText::getSize() const
{
unsigned long int rtn = m_size;
@@ -146,7 +154,7 @@ const cText::eRender& cText::getRender() const
return m_render;
}
//Private
/// private
void cText::Text()
{
if((mpp_font != nullptr) && (*mpp_font != nullptr)) {
@@ -169,7 +177,7 @@ void cText::Text()
} else {
SDL_Rect pos = { 0, 0, 0, 0 };
//m_size == 25;
SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, SDL_TEXTUREACCESS_TARGET);
SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, false, SDL_TEXTUREACCESS_TARGET);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
//int t = SDL_SetTextureColorMod(texture, 0, 255, 0);
@@ -38,7 +38,7 @@ namespace TextTypeEngine {
~cText();
///Function
/// Function
/* Change the colour of the text to White */
void White();
@@ -51,7 +51,7 @@ namespace TextTypeEngine {
/* Change the colour of the text to Red */
void Red();
///Sets
/// Sets
/* Sets the Size */
void setSize( const unsigned long int size = 8 );
void setFont( cFont** font );
@@ -64,7 +64,7 @@ namespace TextTypeEngine {
/* Sets the render of the text. Default is Solid */
void setRender( const eRender& render = eRender::Solid );
///Gets
/// Gets
/* Gets the Size */
const unsigned long int getSize() const;
cFont* getFont() const;
@@ -81,12 +81,12 @@ namespace TextTypeEngine {
void Text();
private:
TextTypeEngine::cFont** mpp_font;
cString m_text;// = ""
TextTypeEngine::cFont** mpp_font;/// = nullptr
cString m_text;/// = ""
unsigned long int m_size;// = 16
SDL_Colour m_colour;// = nullptr
eRender m_render;// = Solid
SDL_Colour m_colour;/// = nullptr
eRender m_render;/// = Solid
};/// END CLASS DEFINITION cText
}/// END NAMESPACE DEFINITION TextTypeEngine
#endif/// END IFNDEF _CTEXT_HPP_
@@ -8,7 +8,7 @@ using UtilityEngine::cUtility;
/*static*/ cTextType* cTextType::sp_inst = nullptr;
//private
/// private
cTextType::cTextType()
{
}
@@ -19,8 +19,8 @@ cTextType::~cTextType()
TTF_Quit();
}
//public:
///Functions
/// public:
/// Functions
/*static*/ cTextType& cTextType::Inst()
{
if (sp_inst == nullptr)
@@ -70,8 +70,8 @@ void cTextType::PrintVersion() const
cUtility::Inst().PrintVersion(cUtility::eTypeSDL::TTF);
}
///Sets
///Gets
/// Sets
/// Gets
const bool cTextType::IsInit() const
{
bool rtn = false;
@@ -17,7 +17,7 @@ namespace TextTypeEngine {
~cTextType();
public:
///Functions
/// Functions
static cTextType& Inst();
static void Delete();
@@ -28,13 +28,13 @@ namespace TextTypeEngine {
void PrintVersion() const;
///Sets
///Gets
/// Sets
/// Gets
/* Gets return true if Text was initialized */
const bool IsInit() const;
private:
static cTextType* sp_inst;// = nullptr
static cTextType* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cTextType
}/// END NAMESPACE DEFINITION TextTypeEngine
#endif/// END IFNDEF _CTEXTTYPE_HPP_