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 a debug grid in views
This commit is contained in:
@@ -422,6 +422,7 @@ cFont *cDisplayMenuRootView::GetTextAreaFont(void) {
|
||||
void cDisplayMenuRootView::Render(void) {
|
||||
if (!view)
|
||||
return;
|
||||
view->DrawDebugGrid();
|
||||
if (!view->DrawBackground()) {
|
||||
defaultBackgroundDrawn = true;
|
||||
DrawBackground();
|
||||
|
56
views/view.c
56
views/view.c
@@ -5,7 +5,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->GetNumPixmaps()) {
|
||||
cView::cView(cTemplateView *tmplView) : cPixmapContainer(tmplView->DrawGebugGrid() ? tmplView->GetNumPixmaps() + 1 : tmplView->GetNumPixmaps()) {
|
||||
this->tmplView = tmplView;
|
||||
tvScaled = tmplView->GetScalingWindow(scalingWindow);
|
||||
if (tvScaled) {
|
||||
@@ -42,6 +42,12 @@ cView::~cView() {
|
||||
}
|
||||
}
|
||||
|
||||
void cView::DrawDebugGrid(void) {
|
||||
if (tmplView && tmplView->DrawGebugGrid()) {
|
||||
DoDrawDebugGrid();
|
||||
}
|
||||
}
|
||||
|
||||
void cView::Init(void) {
|
||||
viewInit = true;
|
||||
scrolling = false;
|
||||
@@ -483,6 +489,54 @@ void cView::DebugTokens(string viewElement, map<string,string> *stringTokens, ma
|
||||
* Private Functions
|
||||
*****************************************************************/
|
||||
|
||||
void cView::DoDrawDebugGrid(void) {
|
||||
int stepsX = tmplView->DebugGridX();
|
||||
int stepsY = tmplView->DebugGridY();
|
||||
cRect osdSize = tmplView->GetOsdSize();
|
||||
tColor col = tmplView->DebugGridColor();
|
||||
tColor colFont = tmplView->DebugGridFontColor();
|
||||
|
||||
cRect size(0, 0, osdSize.Width(), osdSize.Height());
|
||||
//use last pixmap as grid pixmap
|
||||
int numGridPixmap = NumPixmaps() - 1;
|
||||
CreatePixmap(numGridPixmap, 7, size);
|
||||
|
||||
int width = size.Width();
|
||||
int height = size.Height();
|
||||
float stepWidthX = (double)width / (double)stepsX;
|
||||
float stepWidthY = (double)height / (double)stepsY;
|
||||
int fontSize = height / stepsY / 5;
|
||||
|
||||
for (int i = 0; i <= stepsX; i++) {
|
||||
int x = (float)i * stepWidthX;
|
||||
if (i==stepsX)
|
||||
x = x-1;
|
||||
cRect line(x, 0, 1, height);
|
||||
DrawRectangle(numGridPixmap, line, col);
|
||||
if (i==stepsX)
|
||||
continue;
|
||||
float percent = (float)i / (float)stepsX * 100.0;
|
||||
cPoint textPosPerc(x+2, 2);
|
||||
cPoint textPosAbs(x+2, fontSize + 4);
|
||||
DrawText(numGridPixmap, textPosPerc, *cString::sprintf("%.1f%%", percent), colFont, 0x00000000, "vdrOsd", fontSize);
|
||||
DrawText(numGridPixmap, textPosAbs, *cString::sprintf("%dpx", x), colFont, 0x00000000, "vdrOsd", fontSize);
|
||||
}
|
||||
for (int i = 0; i <= stepsY; i++) {
|
||||
int y = (float)i * stepWidthY;
|
||||
if (i==stepsY)
|
||||
y = y-1;
|
||||
cRect line(0, y, width, 1);
|
||||
DrawRectangle(numGridPixmap, line, col);
|
||||
if (i==0 || i==stepsY)
|
||||
continue;
|
||||
float percent = (float)i / (float)stepsY * 100.0;
|
||||
cPoint textPosPerc(2, y + 2);
|
||||
cPoint textPosAbs(2, y + fontSize + 4);
|
||||
DrawText(numGridPixmap, textPosPerc, *cString::sprintf("%.1f%%", percent), colFont, 0x00000000, "vdrOsd", fontSize);
|
||||
DrawText(numGridPixmap, textPosAbs, *cString::sprintf("%dpx", y), colFont, 0x00000000, "vdrOsd", fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
void cView::DoFill(int num, cTemplateFunction *func) {
|
||||
tColor col = func->GetColorParameter(ptColor);
|
||||
Fill(num, col);
|
||||
|
@@ -13,6 +13,7 @@ class cViewElement;
|
||||
class cView : public cPixmapContainer {
|
||||
private:
|
||||
void Init(void);
|
||||
void DoDrawDebugGrid(void);
|
||||
void DoFill(int num, cTemplateFunction *func);
|
||||
void DoDrawText(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
|
||||
void DoDrawTextVertical(int num, cTemplateFunction *func, int x0 = 0, int y0 = 0);
|
||||
@@ -61,6 +62,7 @@ public:
|
||||
cView(cTemplateView *tmplView);
|
||||
cView(cTemplateViewElement *tmplViewElement);
|
||||
cView(cTemplateViewTab *tmplTab);
|
||||
void DrawDebugGrid(void);
|
||||
virtual ~cView();
|
||||
virtual void Stop(void);
|
||||
};
|
||||
|
Reference in New Issue
Block a user