mirror of
https://projects.vdr-developer.org/git/vdr-plugin-skindesigner.git
synced 2023-10-19 15:58:31 +00:00
added possibility to draw vertical text bottomum and topdown
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "cairoimage.h"
|
||||
#include "../libtemplate/templatefunction.h"
|
||||
|
||||
cCairoImage::cCairoImage(void) {
|
||||
surface = NULL;
|
||||
@@ -21,18 +22,26 @@ void cCairoImage::InitCairoImage(int width, int height) {
|
||||
cairo_set_antialias(cr, CAIRO_ANTIALIAS_SUBPIXEL);
|
||||
}
|
||||
|
||||
void cCairoImage::DrawTextVertical(string text, tColor color, string font, int size) {
|
||||
void cCairoImage::DrawTextVertical(string text, tColor color, string font, int size, int direction) {
|
||||
|
||||
int imgHeight = GetTextWidth(text, font, size);
|
||||
InitCairoImage(size * 1.2, imgHeight);
|
||||
|
||||
SetColor(color);
|
||||
cairo_move_to (cr, size, imgHeight);
|
||||
cairo_font_weight_t fontWeight = CAIRO_FONT_WEIGHT_NORMAL;
|
||||
cairo_font_slant_t fontSlant = CAIRO_FONT_SLANT_NORMAL;
|
||||
cairo_select_font_face (cr, font.c_str(), fontSlant, fontWeight);
|
||||
cairo_set_font_size (cr, size);
|
||||
cairo_rotate(cr, 3*M_PI/2);
|
||||
int x = size;
|
||||
int y = imgHeight;
|
||||
double rotate = 3*M_PI/2;
|
||||
if (direction == diTopDown) {
|
||||
rotate = M_PI/2;
|
||||
x = size*0.3;
|
||||
y = 0;
|
||||
}
|
||||
cairo_move_to (cr, x, y);
|
||||
cairo_rotate(cr, rotate);
|
||||
cairo_show_text (cr, text.c_str());
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ public:
|
||||
cCairoImage(void);
|
||||
virtual ~cCairoImage();
|
||||
void InitCairoImage(int width, int height);
|
||||
void DrawTextVertical(string text, tColor color, string font, int size);
|
||||
void DrawTextVertical(string text, tColor color, string font, int size, int direction);
|
||||
cImage *GetImage(void);
|
||||
};
|
||||
#endif //__CAIROIMAGE_H
|
@@ -332,17 +332,17 @@ cImage *cImageCache::GetSkinpart(string name, int width, int height) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cImage *cImageCache::GetVerticalText(string text, tColor color, string font, int size) {
|
||||
cImage *cImageCache::GetVerticalText(string text, tColor color, string font, int size, int direction) {
|
||||
cMutexLock MutexLock(&mutex);
|
||||
stringstream buf;
|
||||
buf << text << "_" << size;
|
||||
buf << text << "_" << size << "_" << direction;
|
||||
string imgName = buf.str();
|
||||
map<string, cImage*>::iterator hit = cairoImageCache.find(imgName);
|
||||
if (hit != cairoImageCache.end()) {
|
||||
return (cImage*)hit->second;
|
||||
} else {
|
||||
cCairoImage c;
|
||||
c.DrawTextVertical(text, color, font, size);
|
||||
c.DrawTextVertical(text, color, font, size, direction);
|
||||
cImage *image = c.GetImage();
|
||||
cairoImageCache.insert(pair<string, cImage*>(imgName, image));
|
||||
hit = cairoImageCache.find(imgName);
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
void CacheSkinpart(string path, int width, int height);
|
||||
cImage *GetSkinpart(string name, int width, int height);
|
||||
//cairo special images
|
||||
cImage *GetVerticalText(string text, tColor color, string font, int size);
|
||||
cImage *GetVerticalText(string text, tColor color, string font, int size, int direction);
|
||||
//helpers
|
||||
void Clear(void);
|
||||
void Debug(bool full);
|
||||
|
Reference in New Issue
Block a user