Implemented cOsd::SetOsdPosition() etc

This commit is contained in:
Klaus Schmidinger 2007-06-17 14:02:02 +02:00
parent da376c0603
commit 549a26af27
6 changed files with 66 additions and 37 deletions

View File

@ -1953,6 +1953,7 @@ Christoph Haubrich <christoph1.haubrich@arcor.de>
for reporting that the log message "deleting plugin: ..." is irritating when
calling "vdr --help"
for fixing cDevice::ToggleMute()
for suggestions that led to implementing cOsd::SetOsdPosition() etc.
Pekka Mauno <pekka.mauno@iki.fi>
for fixing cSchedule::GetFollowingEvent() in case there is currently no present

View File

@ -5255,3 +5255,8 @@ Video Disk Recorder Revision History
- The info.vdr file now also stores the name of the channel, and the new function
cRecordingInfo::ChannelName() returns this information if available (based on
a patch from Alexander Hans).
- The new function cOsd::SetOsdPosition() can be used to dynamically change the
position and size of the OSD (based on a request from Christoph Haubrich).
Plugins that implement skins should no longer use Setup.OSDWidth etc. directly,
but should rather use cOsd::OsdWidth() etc. instead.
Currently a change to the OSD position will only apply to newly opened OSDs.

14
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: osd.c 1.69 2007/06/10 12:16:36 kls Exp $
* $Id: osd.c 1.70 2007/06/17 13:54:34 kls Exp $
*/
#include "osd.h"
@ -642,6 +642,10 @@ const tIndex *cBitmap::Data(int x, int y)
// --- cOsd ------------------------------------------------------------------
int cOsd::osdLeft = 0;
int cOsd::osdTop = 0;
int cOsd::osdWidth = 0;
int cOsd::osdHeight = 0;
int cOsd::isOpen = 0;
cOsd::cOsd(int Left, int Top)
@ -664,6 +668,14 @@ cOsd::~cOsd()
isOpen--;
}
void cOsd::SetOsdPostion(int Left, int Top, int Width, int Height)
{
osdLeft = Left;
osdTop = Top;
osdWidth = Width;
osdHeight = Height;
}
void cOsd::SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
{
for (int i = 0; i < numBitmaps; i++)

13
osd.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: osd.h 1.54 2007/06/10 12:15:52 kls Exp $
* $Id: osd.h 1.55 2007/06/17 13:59:22 kls Exp $
*/
#ifndef __OSD_H
@ -13,6 +13,7 @@
#include <limits.h>
#include <stdio.h>
#include <stdint.h>
#include "config.h"
#include "font.h"
#define MAXNUMCOLORS 256
@ -245,6 +246,7 @@ struct tArea {
class cOsd {
friend class cOsdProvider;
private:
static int osdLeft, osdTop, osdWidth, osdHeight;
static int isOpen;
cBitmap *savedRegion;
cBitmap *bitmaps[MAXOSDAREAS];
@ -270,6 +272,15 @@ protected:
public:
virtual ~cOsd();
///< Shuts down the OSD.
static int OsdLeft(void) { return osdLeft ? osdLeft : Setup.OSDLeft; }
static int OsdTop(void) { return osdTop ? osdTop : Setup.OSDTop; }
static int OsdWidth(void) { return osdWidth ? osdWidth : Setup.OSDWidth; }
static int OsdHeight(void) { return osdHeight ? osdHeight : Setup.OSDHeight; }
static void SetOsdPostion(int Left, int Top, int Width, int Height);
///< Sets the position and size of the OSD to the given values.
///< This may be useful for plugins that determine the scaling of the
///< video image and need to scale the OSD accordingly to fit on the
///< screen.
static int IsOpen(void) { return isOpen; }
int Left(void) { return left; }
int Top(void) { return top; }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: skinclassic.c 1.16 2007/06/10 12:42:02 kls Exp $
* $Id: skinclassic.c 1.17 2007/06/17 13:53:09 kls Exp $
*/
#include "skinclassic.h"
@ -92,13 +92,13 @@ cSkinClassicDisplayChannel::cSkinClassicDisplayChannel(bool WithInfo)
const cFont *font = cFont::GetFont(fontOsd);
lineHeight = font->Height();
message = false;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + (Setup.ChannelInfoPos ? 0 : Setup.OSDHeight - Lines * lineHeight));
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + (Setup.ChannelInfoPos ? 0 : cOsd::OsdHeight() - Lines * lineHeight));
timeWidth = font->Width("00:00") + 4;
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, Lines * lineHeight - 1, 8 } };
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, Lines * lineHeight - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
else {
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, Lines * lineHeight - 1, 4 } };
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, Lines * lineHeight - 1, 4 } };
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
}
osd->DrawRectangle(0, 0, osd->Width() - 1, osd->Height() - 1, Theme.Color(clrBackground));
@ -187,14 +187,14 @@ cSkinClassicDisplayMenu::cSkinClassicDisplayMenu(void)
const cFont *font = cFont::GetFont(fontOsd);
lineHeight = font->Height();
x0 = 0;
x1 = Setup.OSDWidth;
x1 = cOsd::OsdWidth();
y0 = 0;
y1 = lineHeight;
y2 = y1 + lineHeight;
y5 = Setup.OSDHeight;
y5 = cOsd::OsdHeight();
y4 = y5 - lineHeight;
y3 = y4 - lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop());
tArea Areas[] = { { x0, y0, x1 - 1, y5 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -426,12 +426,12 @@ cSkinClassicDisplayReplay::cSkinClassicDisplayReplay(bool ModeOnly)
int lineHeight = font->Height();
lastCurrentWidth = 0;
x0 = 0;
x1 = Setup.OSDWidth;
x1 = cOsd::OsdWidth();
y0 = 0;
y1 = lineHeight;
y2 = 2 * lineHeight;
y3 = 3 * lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y3);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y3);
tArea Areas[] = { { x0, y0, x1 - 1, y3 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -526,12 +526,12 @@ cSkinClassicDisplayVolume::cSkinClassicDisplayVolume(void)
{
const cFont *font = cFont::GetFont(fontOsd);
int lineHeight = font->Height();
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - lineHeight);
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, lineHeight - 1, 8 } };
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - lineHeight);
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
else {
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, lineHeight - 1, 4 } };
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 4 } };
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
}
}
@ -591,7 +591,7 @@ cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumT
ItemsWidth = max(ItemsWidth, font->Width(Tracks[i]));
ItemsWidth += 10;
x0 = 0;
x1 = Setup.OSDWidth;
x1 = cOsd::OsdWidth();
int d = x1 - x0;
if (d > ItemsWidth) {
d = (d - ItemsWidth) & ~0x07; // must be multiple of 8
@ -600,7 +600,7 @@ cSkinClassicDisplayTracks::cSkinClassicDisplayTracks(const char *Title, int NumT
y0 = 0;
y1 = lineHeight;
y2 = y1 + NumTracks * lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y2);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y2);
tArea Areas[] = { { x0, y0, x1 - 1, y2 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -663,12 +663,12 @@ cSkinClassicDisplayMessage::cSkinClassicDisplayMessage(void)
{
const cFont *font = cFont::GetFont(fontOsd);
int lineHeight = font->Height();
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - lineHeight);
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, lineHeight - 1, 8 } };
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - lineHeight);
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
else {
tArea Areas[] = { { 0, 0, Setup.OSDWidth - 1, lineHeight - 1, 2 } };
tArea Areas[] = { { 0, 0, cOsd::OsdWidth() - 1, lineHeight - 1, 2 } };
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
}
}
@ -681,7 +681,7 @@ cSkinClassicDisplayMessage::~cSkinClassicDisplayMessage()
void cSkinClassicDisplayMessage::SetMessage(eMessageType Type, const char *Text)
{
const cFont *font = cFont::GetFont(fontOsd);
osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, Setup.OSDWidth, 0, taCenter);
osd->DrawText(0, 0, Text, Theme.Color(clrMessageStatusFg + 2 * Type), Theme.Color(clrMessageStatusBg + 2 * Type), font, cOsd::OsdWidth(), 0, taCenter);
}
void cSkinClassicDisplayMessage::Flush(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: skinsttng.c 1.20 2007/06/10 12:40:43 kls Exp $
* $Id: skinsttng.c 1.21 2007/06/17 13:51:56 kls Exp $
*/
// Star Trek: The Next Generation® is a registered trademark of Paramount Pictures
@ -163,7 +163,7 @@ cSkinSTTNGDisplayChannel::cSkinSTTNGDisplayChannel(bool WithInfo)
x1 = x0 + font->Width("00:00") + 4;
x2 = x1 + Roundness;
x3 = x2 + Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x5 = x6 - lineHeight / 2;
x4 = x5 - Gap;
@ -177,7 +177,7 @@ cSkinSTTNGDisplayChannel::cSkinSTTNGDisplayChannel(bool WithInfo)
y7 = y6 + cFont::GetFont(fontSml)->Height();
int yt = (y0 + y1) / 2;
int yb = (y6 + y7) / 2;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + (Setup.ChannelInfoPos ? 0 : Setup.OSDHeight - y7));
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + (Setup.ChannelInfoPos ? 0 : cOsd::OsdHeight() - y7));
tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -209,13 +209,13 @@ cSkinSTTNGDisplayChannel::cSkinSTTNGDisplayChannel(bool WithInfo)
x1 = lineHeight / 2;
x2 = lineHeight;
x3 = x2 + Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x5 = x6 - lineHeight / 2;
x4 = x5 - Gap;
y0 = 0;
y1 = lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + (Setup.ChannelInfoPos ? 0 : Setup.OSDHeight - y1));
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + (Setup.ChannelInfoPos ? 0 : cOsd::OsdHeight() - y1));
tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -374,7 +374,7 @@ cSkinSTTNGDisplayMenu::cSkinSTTNGDisplayMenu(void)
x1 = lineHeight / 2;
x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8
x2 = x3 - Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x4 = (x6 - lineHeight / 2 - Gap) & ~0x07; // must be multiple of 8
x5 = x4 + Gap;
@ -382,13 +382,13 @@ cSkinSTTNGDisplayMenu::cSkinSTTNGDisplayMenu(void)
y1 = lineHeight;
y2 = y1 + Roundness;
y3 = y2 + Gap;
y7 = Setup.OSDHeight;
y7 = cOsd::OsdHeight();
y6 = y7 - cFont::GetFont(fontSml)->Height();
y5 = y6 - Roundness;
y4 = y5 - Gap;
int yt = (y0 + y1) / 2;
int yb = (y6 + y7) / 2;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop());
tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -703,7 +703,7 @@ cSkinSTTNGDisplayReplay::cSkinSTTNGDisplayReplay(bool ModeOnly)
x1 = max(SymbolWidth, bm.Width());
x2 = x1 + Roundness;
x3 = x2 + Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x5 = x6 - lineHeight / 2;
x4 = x5 - Gap;
@ -717,7 +717,7 @@ cSkinSTTNGDisplayReplay::cSkinSTTNGDisplayReplay(bool ModeOnly)
y7 = y6 + font->Height();
int yt = (y0 + y1) / 2;
int yb = (y6 + y7) / 2;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y7);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y7);
tArea Areas[] = { { 0, 0, x7 - 1, y7 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -845,13 +845,13 @@ cSkinSTTNGDisplayVolume::cSkinSTTNGDisplayVolume(void)
x1 = lineHeight / 2;
x2 = lineHeight;
x3 = x2 + Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x5 = x6 - lineHeight / 2;
x4 = x5 - Gap;
y0 = 0;
y1 = lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y1);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y1);
tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -943,7 +943,7 @@ cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTrack
x1 = lineHeight / 2;
x3 = (x1 + Roundness + Gap + 7) & ~0x07; // must be multiple of 8
x2 = x3 - Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x4 = (x6 - lineHeight / 2 - Gap) & ~0x07; // must be multiple of 8
x5 = x4 + Gap;
@ -959,14 +959,14 @@ cSkinSTTNGDisplayTracks::cSkinSTTNGDisplayTracks(const char *Title, int NumTrack
y1 = lineHeight;
y2 = y1 + Roundness;
y3 = y2 + Gap;
// limit to Setup.OSDHeight? - what if height is too big???
// limit to cOsd::OsdHeight()? - what if height is too big???
y4 = y3 + NumTracks * lineHeight + 2 * Roundness;
y5 = y4 + Gap;
y6 = y5 + Roundness;
y7 = y6 + cFont::GetFont(fontSml)->Height();
int yt = (y0 + y1) / 2;
int yb = (y6 + y7) / 2;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y7);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y7);
tArea Areas[] = { { x0, y0, x7 - 1, y7 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));
@ -1087,13 +1087,13 @@ cSkinSTTNGDisplayMessage::cSkinSTTNGDisplayMessage(void)
x1 = lineHeight / 2;
x2 = lineHeight;
x3 = x2 + Gap;
x7 = Setup.OSDWidth;
x7 = cOsd::OsdWidth();
x6 = x7 - lineHeight / 2;
x5 = x6 - lineHeight / 2;
x4 = x5 - Gap;
y0 = 0;
y1 = lineHeight;
osd = cOsdProvider::NewOsd(Setup.OSDLeft, Setup.OSDTop + Setup.OSDHeight - y1);
osd = cOsdProvider::NewOsd(cOsd::OsdLeft(), cOsd::OsdTop() + cOsd::OsdHeight() - y1);
tArea Areas[] = { { x0, y0, x7 - 1, y1 - 1, 8 } };
if (Setup.AntiAlias && osd->CanHandleAreas(Areas, sizeof(Areas) / sizeof(tArea)) == oeOk)
osd->SetAreas(Areas, sizeof(Areas) / sizeof(tArea));