OTHER: Rewrote TimeDisplay

Positions and sizes of the numbers are now correct
NumberDisplay now unused -> removed
renamed file to lowercase and moved to subdir mainwindow
This commit is contained in:
Thomas Frauendorfer 2008-05-17 06:08:05 +02:00
parent bece172e92
commit fb264e8d0e
11 changed files with 119 additions and 277 deletions

5
TODO
View file

@ -1,8 +1,9 @@
Todo:
General:
+ Feature Requests and Bugs on tracker
+ Mainwindow
+ Balancebackgrounds are wrong
+ enable repeat button
+ enable random play (will have to wait for a randomplay service client)
* Playlist
+ Make displayed Information configurable

View file

@ -1,79 +0,0 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 XMMS2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "NumberDisplay.h"
#include "TimeDisplay.h"
#include "Skin.h"
#include <QPainter>
NumberDisplay::NumberDisplay (QWidget *parent, TimeDisplay *td,uint w, uint startpx) : PixWidget (parent)
{
m_td = td;
m_w = w;
m_startpx = startpx;
m_pixmap = QPixmap (m_w, 13);
setMinimumSize (m_w, 13);
setMaximumSize (m_w, 13);
setNumber (0,0);
}
void
NumberDisplay::setPixmaps (Skin *skin)
{
QBrush b (skin->getNumber (10));
QPainter paint;
paint.begin (&m_pixmap);
paint.fillRect (m_pixmap.rect (), b);
paint.drawPixmap (m_startpx, 0, skin->getNumber (m_n1));
paint.drawPixmap (m_startpx+12, 0, skin->getNumber (m_n2));
paint.end();
update ();
}
void
NumberDisplay::setNumber (uint n1, uint n2)
{
if (m_n1 != n1 || m_n2 != n2) {
Skin *skin = Skin::getInstance ();
m_n1 = n1;
m_n2 = n2;
setPixmaps (skin);
}
}
NumberDisplay::~NumberDisplay ()
{
}
void
NumberDisplay::mousePressEvent (QMouseEvent *event)
{
}
void
NumberDisplay::mouseReleaseEvent (QMouseEvent *event)
{
// TimeDisplay *td = dynamic_cast<TimeDisplay *>(parent());
emit clicked();
m_td->drawMinus ();
}

View file

@ -1,49 +0,0 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 XMMS2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __NUMBERDISPLAY_H__
#define __NUMBERDISPLAY_H__
class TimeDisplay;
#include "PixWidget.h"
class NumberDisplay : public PixWidget
{
Q_OBJECT
public:
NumberDisplay (QWidget *parent, TimeDisplay *td, uint, uint);
~NumberDisplay ();
void setNumber (uint, uint);
public slots:
void setPixmaps (Skin *skin);
signals:
void clicked(void);
protected:
void mousePressEvent (QMouseEvent *event);
void mouseReleaseEvent (QMouseEvent *event);
int m_w;
int m_startpx;
TimeDisplay *m_td;
uint m_n1;
uint m_n2;
};
#endif

View file

@ -725,7 +725,7 @@ Skin::BuildSliders (void)
void
Skin::BuildNumbers (void)
{
uint num = 12;
int num = 12;
QPixmap *img = getPixmap("nums_ex");
if (!img) {
@ -735,9 +735,18 @@ Skin::BuildNumbers (void)
if(img)
{
for (uint i = 0; i < num; i++) {
for (int i = 0; i < num; i++) {
m_numbers[i] = img->copy (i*9, 0, 9, qMin (13, img->height ()));
}
if (num < 12) {
// We do not yet have a '-' Symbol, so we create one
// from the '2' character and the blank as background
QPixmap pix = m_numbers[10].copy ();
QRect r (3, 6, 3, 1);
QPainter painter (&pix);
painter.drawPixmap (r, m_numbers[2], r);
m_numbers[11] = pix;
}
delete img;
}
else

View file

@ -27,7 +27,8 @@
class QDir;
typedef QList<QPixmap> QPixmapList;
typedef QList <QPixmap> QPixmapList;
typedef QMap <int, QPixmap> PixmapMap;
class Skin : public QObject
{
@ -43,6 +44,7 @@ class Skin : public QObject
const QIcon getIcon (uint item) const { return m_icons.value(item); };
const QPixmapList getBackgrounds (uint item) const
{ return m_backgrounds.value(item); };
const PixmapMap getNumbers () const { return m_numbers; }
const QPixmap getItem (uint part) const { return m_items[part]; }
const QPixmap getPls (uint part) const { return m_playlist[part]; }
@ -255,9 +257,9 @@ class Skin : public QObject
QMap<uint, QIcon> m_icons;
QMap<uint, QPixmapList> m_backgrounds;
QMap<int, QPixmap> m_numbers;
QMap<uint, QPixmap> m_items;
QMap<uint, QPixmap> m_letterMap;
QMap<uint, QPixmap> m_numbers;
QMap<uint, QPixmap> m_playlist;
QMap<QByteArray, QByteArray> m_pledit_txt;

View file

@ -1,118 +0,0 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 XMMS2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "XMMSHandler.h"
#include "mainwindow.h"
#include "maindisplay.h"
#include "TimeDisplay.h"
#include "NumberDisplay.h"
#include "Skin.h"
#include <QPen>
TimeDisplay::TimeDisplay (QWidget *parent, int time) : PixWidget (parent)
{
uint w = 12;//+78;
m_w = w;
m_pixmap = QPixmap (m_w, 13);
setMinimumSize (m_w, 13);
setMaximumSize (m_w, 13);
move (37, 26);
//FIXME: let this be the parent
/* XXX: colon disappear, how make transparent?
m_number_min = new NumberDisplay (this, 24, 0);
m_number_min->move (10, 0);
m_number_sec = new NumberDisplay (this, 24, 0);
m_number_sec->move (78-37, 0);
*/
m_number_min = new NumberDisplay (parent, this,24, 0);
m_number_min->move (37+10, 26);
m_number_sec = new NumberDisplay (parent, this,24, 0);
m_number_sec->move (78, 26);
connect (m_number_min, SIGNAL(clicked()), parent, SLOT(toggleTime()));
connect (m_number_sec, SIGNAL(clicked()), parent, SLOT(toggleTime()));
}
void TimeDisplay::setPixmaps (Skin *skin)
{
drawMinus();
m_number_min->setPixmaps (skin);
m_number_sec->setPixmaps (skin);
}
TimeDisplay::~TimeDisplay ()
{
}
void TimeDisplay::setTime (int time)
{
if (m_time == time) return;
m_time = time;
uint showtime = abs(time);
uint sec, min;
sec = (showtime / 1000) % 60;
min = (showtime / 1000) / 60;
m_number_min->setNumber (min / 10, min % 10);
m_number_sec->setNumber (sec / 10, sec % 10);
drawMinus ();
}
void
TimeDisplay::drawMinus ()
{
Skin *skin = Skin::getInstance ();
// Draw background
QBrush b (skin->getNumber (10));
QPainter paint;
paint.begin (&m_pixmap);
paint.fillRect (m_pixmap.rect (), b);
MainDisplay *md = dynamic_cast<MainDisplay *>(parent());
if (md->getMW()->isTimemodeReverse()) {// draw a minus sign
if (skin->getNumberSize() < 12) { // Skin hasn't got any, draw a line in correct color.
QByteArray a = skin->getPLeditValue("normal");
QColor c;
c.setNamedColor(a);
QPen pen(c);
paint.setPen(pen);
paint.drawLine (3,6,8,6);
} else {
paint.drawPixmap (0, 0, skin->getNumber (11));
}
}
paint.end();
update ();
}
void
TimeDisplay::mousePressEvent (QMouseEvent *event)
{
}
void
TimeDisplay::mouseReleaseEvent (QMouseEvent *event)
{
emit clicked();
drawMinus ();
}

View file

@ -26,8 +26,7 @@
#include "pixmapslider.h"
#include "TitleBar.h"
#include "TextBar.h"
#include "NumberDisplay.h"
#include "TimeDisplay.h"
#include "timedisplay.h"
#include "Skin.h"
#include "SmallNumberDisplay.h"
#include "stereomono.h"
@ -59,8 +58,8 @@ MainDisplay::MainDisplay (QWidget *parent) : SkinDisplay(parent)
m_text = new TextScroller (this, 154, 10, "main");
m_text->move (112, 25);
m_time = new TimeDisplay(this, 0);
// m_time->move (36, 26);
m_time = new TimeDisplay(this);
m_time->move (36, 26);
connect (m_time, SIGNAL(clicked()), this, SLOT(toggleTime()));
m_kbps = new SmallNumberDisplay (this, 15);
@ -157,6 +156,9 @@ MainDisplay::setPixmaps (Skin *skin)
m_bslider->setBackground (skin->getBackgrounds (Skin::SLIDER_BALANCEBAR_BGS));
m_bslider->setSliders (skin->getItem (Skin::BALANCE_BTN_0),
skin->getItem (Skin::BALANCE_BTN_1));
/* update some other widgets */
m_time->setPixmaps (skin->getNumbers ());
}
void
@ -178,9 +180,9 @@ MainDisplay::setPlaytime (uint32_t time)
uint32_t showtime;
if (m_mw->isTimemodeReverse()) {
uint maxtime = m_posbar->maximum ();
showtime = -(maxtime - time);
showtime = (time/1000 - maxtime/1000);
} else {
showtime = time;
showtime = time/1000;
}
m_time->setTime (showtime);

View file

@ -4,7 +4,8 @@ HEADERS += clutterbar.h \
playstatus.h \
posbar.h \
shadeddisplay.h \
stereomono.h
stereomono.h \
timedisplay.h
SOURCES += clutterbar.cpp \
mainwindow.cpp \
@ -12,7 +13,8 @@ SOURCES += clutterbar.cpp \
playstatus.cpp \
posbar.cpp \
shadeddisplay.cpp \
stereomono.cpp
stereomono.cpp \
timedisplay.cpp
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD

View file

@ -0,0 +1,72 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 XMMS2 Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "timedisplay.h"
#include <QPainter>
#include <QPixmap>
#include <QMap>
//TimeDisplay::TimeDisplay (QWidget *parent) : PixWidget (parent)
TimeDisplay::TimeDisplay (QWidget *parent) : QWidget (parent)
{
setFixedSize (63, 13);
}
void TimeDisplay::setTime (int time)
{
if (m_time == time) return;
m_time = time;
update ();
}
void
TimeDisplay::paintEvent (QPaintEvent *event)
{
if (m_pixmaps.size () < 11) {
qDebug ("too small");
return;
}
QPainter paint;
paint.begin (this);
if (m_time < 0) {
// draw minus
paint.drawPixmap (0, 0, m_pixmaps[11]);
} else {
// draw blank
paint.drawPixmap (0, 0, m_pixmaps[10]);
}
uint showtime = abs(m_time);
// draw minutes
uint min = showtime / 60;
paint.drawPixmap (12, 0, m_pixmaps[min/10]);
paint.drawPixmap (24, 0, m_pixmaps[min%10]);
// draw seconds
uint sec = showtime % 60;
paint.drawPixmap (42, 0, m_pixmaps[sec/10]);
paint.drawPixmap (54, 0, m_pixmaps[sec%10]);
paint.end ();
}
void
TimeDisplay::mouseReleaseEvent (QMouseEvent *event)
{
emit clicked();
}

View file

@ -16,32 +16,36 @@
#ifndef __TIMEDISPLAY_H__
#define __TIMEDISPLAY_H__
class TimeDisplay;
#include <QWidget>
#include <QMap>
#include "PixWidget.h"
#include "NumberDisplay.h"
class QMouseEvent;
class QPaintEvent;
class QPixmap;
class TimeDisplay : public PixWidget
typedef QMap<int, QPixmap> PixmapMap;
class TimeDisplay : public QWidget
{
Q_OBJECT
public:
TimeDisplay (QWidget *parent, int time);
~TimeDisplay ();
TimeDisplay (QWidget *parent);
~TimeDisplay () {};
void setTime (int);
void drawMinus();
public slots:
void setPixmaps (Skin *skin);
void setPixmaps (const PixmapMap &p) {m_pixmaps = p;}
signals:
void clicked(void);
protected:
void mousePressEvent (QMouseEvent *event);
void mousePressEvent (QMouseEvent *event) {};
void mouseReleaseEvent (QMouseEvent *event);
int m_time;
NumberDisplay *m_number_min;
NumberDisplay *m_number_sec;
void paintEvent (QPaintEvent *event);
uint m_w;
int m_time;
PixmapMap m_pixmaps;
};
#endif

View file

@ -9,8 +9,6 @@ HEADERS += PixWidget.h \
Display.h \
TitleBar.h \
TextBar.h \
NumberDisplay.h \
TimeDisplay.h \
XMMSHandler.h \
SmallNumberDisplay.h \
SkinChooser.h \
@ -26,8 +24,6 @@ SOURCES += main.cpp \
Display.cpp \
TitleBar.cpp \
TextBar.cpp \
NumberDisplay.cpp \
TimeDisplay.cpp \
XMMSHandler.cpp \
SmallNumberDisplay.cpp \
SkinChooser.cpp \