OTHER: fixes for displaying clutterbar
This commit is contained in:
parent
ae6dd70b2a
commit
9b595af753
5 changed files with 157 additions and 59 deletions
|
|
@ -20,7 +20,9 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
ClutterBar::ClutterBar (QWidget *parent) : QWidget (parent)
|
ClutterBar::ClutterBar (QWidget *parent) : QWidget (parent),
|
||||||
|
m_val (Skin::CLUTTER_ON), m_checked_a (false), m_checked_d (false),
|
||||||
|
m_show_always (true)
|
||||||
{
|
{
|
||||||
connect (SkinManager::instance (), SIGNAL (skinChanged (Skin *)),
|
connect (SkinManager::instance (), SIGNAL (skinChanged (Skin *)),
|
||||||
this, SLOT (setPixmaps(Skin *)));
|
this, SLOT (setPixmaps(Skin *)));
|
||||||
|
|
@ -34,18 +36,16 @@ ClutterBar::~ClutterBar ()
|
||||||
void
|
void
|
||||||
ClutterBar::setPixmaps(Skin *skin)
|
ClutterBar::setPixmaps(Skin *skin)
|
||||||
{
|
{
|
||||||
m_clutter_on = skin->getItem(Skin::CLUTTER_ON);
|
setPixmaps (skin->getPixmapList (Skin::PIXMAPS_CLUTTERBAR));
|
||||||
m_clutter_off = skin->getItem(Skin::CLUTTER_OFF);
|
}
|
||||||
|
|
||||||
m_clutter_o = skin->getItem(Skin::CLUTTER_O);
|
void
|
||||||
m_clutter_a = skin->getItem(Skin::CLUTTER_A);
|
ClutterBar::setPixmaps (const QPixmapList &p)
|
||||||
m_clutter_i = skin->getItem(Skin::CLUTTER_I);
|
{
|
||||||
m_clutter_d = skin->getItem(Skin::CLUTTER_D);
|
m_pixmaps = p;
|
||||||
m_clutter_v = skin->getItem(Skin::CLUTTER_V);
|
|
||||||
|
|
||||||
m_pixmap = m_clutter_on;
|
QPixmap pixmap = m_pixmaps.value (Skin::CLUTTER_ON);
|
||||||
|
setFixedSize (pixmap.size ());
|
||||||
setFixedSize (m_clutter_on.size ());
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
@ -53,41 +53,118 @@ ClutterBar::setPixmaps(Skin *skin)
|
||||||
void
|
void
|
||||||
ClutterBar::mousePressEvent (QMouseEvent *event)
|
ClutterBar::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int y = event->pos().y();
|
m_val = posToVal (event->x (), event->y ());
|
||||||
|
|
||||||
if (y > 2 && y < 11) {
|
|
||||||
m_pixmap = m_clutter_o;
|
|
||||||
} else if (y > 10 && y < 19) {
|
|
||||||
m_pixmap = m_clutter_a;
|
|
||||||
} else if (y > 18 && y < 27) {
|
|
||||||
m_pixmap = m_clutter_i;
|
|
||||||
} else if (y > 26 && y < 35) {
|
|
||||||
m_pixmap = m_clutter_d;
|
|
||||||
} else if (y > 34 && y < 43) {
|
|
||||||
m_pixmap = m_clutter_v;
|
|
||||||
}
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
void
|
||||||
|
ClutterBar::mouseMoveEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
const int val = posToVal (event->x(), event->y());
|
||||||
|
|
||||||
|
if (m_val != val) {
|
||||||
|
m_val = val;
|
||||||
|
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClutterBar::mouseReleaseEvent (QMouseEvent *event)
|
ClutterBar::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_pixmap = m_clutter_on;
|
m_val = Skin::CLUTTER_ON;
|
||||||
|
|
||||||
|
const int val = posToVal (event->x (), event->y());
|
||||||
|
switch (val) {
|
||||||
|
case Skin::CLUTTER_O:
|
||||||
|
emit clicked_o ();
|
||||||
|
break;
|
||||||
|
case Skin::CLUTTER_A:
|
||||||
|
m_checked_a = !m_checked_a;
|
||||||
|
emit clicked_a (m_checked_a);
|
||||||
|
break;
|
||||||
|
case Skin::CLUTTER_I:
|
||||||
|
emit clicked_i ();
|
||||||
|
break;
|
||||||
|
case Skin::CLUTTER_D:
|
||||||
|
m_checked_d = !m_checked_d;
|
||||||
|
emit clicked_d (m_checked_d);
|
||||||
|
break;
|
||||||
|
case Skin::CLUTTER_V:
|
||||||
|
emit clicked_v ();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClutterBar::enterEvent (QEvent * event)
|
||||||
|
{
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
void
|
||||||
|
ClutterBar::leaveEvent (QEvent * event)
|
||||||
|
{
|
||||||
|
update ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ClutterBar::posInWidget (const int x, const int y) const
|
||||||
|
{
|
||||||
|
return (x >= 0 && y >= 0 && x < width() && y < height());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ClutterBar::posToVal (const int x, const int y) const
|
||||||
|
{
|
||||||
|
if (!posInWidget (x, y))
|
||||||
|
return Skin::CLUTTER_ON;
|
||||||
|
|
||||||
|
if (y <= 2) {
|
||||||
|
return Skin::CLUTTER_ON;
|
||||||
|
} else if (y <= 10) {
|
||||||
|
return Skin::CLUTTER_O;
|
||||||
|
} else if (y <= 18) {
|
||||||
|
return Skin::CLUTTER_A;
|
||||||
|
} else if (y <= 26) {
|
||||||
|
return Skin::CLUTTER_I;
|
||||||
|
} else if (y <= 34) {
|
||||||
|
return Skin::CLUTTER_D;
|
||||||
|
} else if (y <= 42) {
|
||||||
|
return Skin::CLUTTER_V;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Skin::CLUTTER_ON;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClutterBar::paintEvent (QPaintEvent *event)
|
ClutterBar::paintEvent (QPaintEvent *event)
|
||||||
{
|
{
|
||||||
if (m_pixmap.isNull ()) {
|
QPainter paint (this);
|
||||||
return;
|
if (m_show_always || underMouse ()) {
|
||||||
|
const QPixmap pix = m_pixmaps.value (m_val);
|
||||||
|
if (pix.isNull ())
|
||||||
|
return;
|
||||||
|
paint.drawPixmap (rect (), pix, pix.rect ());
|
||||||
|
if (m_checked_a) {
|
||||||
|
const QPixmap pix_a = m_pixmaps.value (Skin::CLUTTER_A);
|
||||||
|
const QRect rect(0, 10, pix_a.width (), 8);
|
||||||
|
paint.drawPixmap (rect, pix_a, rect);
|
||||||
|
}
|
||||||
|
if (m_checked_d) {
|
||||||
|
const QPixmap pix_d = m_pixmaps.value (Skin::CLUTTER_D);
|
||||||
|
const QRect rect(0, 26, pix_d.width (), 8);
|
||||||
|
paint.drawPixmap (rect, pix_d, rect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const QPixmap pix = m_pixmaps.value (Skin::CLUTTER_OFF);
|
||||||
|
if (pix.isNull ())
|
||||||
|
return;
|
||||||
|
paint.drawPixmap (rect (), pix, pix.rect ());
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter p (this);
|
|
||||||
p.drawPixmap (rect (), m_pixmap, m_pixmap.rect ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "clutterbar.moc"
|
#include "clutterbar.moc"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* This file is a part of Promoe, an XMMS2 Client.
|
* This file is a part of Promoe, an XMMS2 Client.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005-2008 XMMS2 Team
|
* Copyright (C) 2005-2010 XMMS2 Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
@ -16,12 +16,17 @@
|
||||||
#ifndef __CLUTTERBAR_H__
|
#ifndef __CLUTTERBAR_H__
|
||||||
#define __CLUTTERBAR_H__
|
#define __CLUTTERBAR_H__
|
||||||
|
|
||||||
#include "QWidget"
|
#include <QWidget>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
|
|
||||||
class Skin;
|
class Skin;
|
||||||
|
|
||||||
|
typedef QList<QPixmap> QPixmapList;
|
||||||
|
|
||||||
class ClutterBar : public QWidget
|
class ClutterBar : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -30,26 +35,36 @@ class ClutterBar : public QWidget
|
||||||
~ClutterBar ();
|
~ClutterBar ();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void setPixmaps (const QPixmapList &);
|
||||||
void setPixmaps(Skin *skin);
|
void setPixmaps(Skin *skin);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked_o ();
|
||||||
|
void clicked_a (bool checked);
|
||||||
|
void clicked_i ();
|
||||||
|
void clicked_d (bool checked);
|
||||||
|
void clicked_v ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent (QPaintEvent *event);
|
void paintEvent (QPaintEvent *event);
|
||||||
|
|
||||||
void mousePressEvent (QMouseEvent *event);
|
void mousePressEvent (QMouseEvent *event);
|
||||||
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
void mouseReleaseEvent (QMouseEvent *event);
|
void mouseReleaseEvent (QMouseEvent *event);
|
||||||
|
|
||||||
QPixmap m_clutter_off;
|
void enterEvent (QEvent *event);
|
||||||
QPixmap m_clutter_on;
|
void leaveEvent (QEvent *event);
|
||||||
|
|
||||||
QPixmap m_clutter_o;
|
bool posInWidget (const int x, const int y) const;
|
||||||
QPixmap m_clutter_a;
|
int posToVal (const int x, const int y) const;
|
||||||
QPixmap m_clutter_i;
|
|
||||||
QPixmap m_clutter_d;
|
|
||||||
QPixmap m_clutter_v;
|
|
||||||
|
|
||||||
bool enabled;
|
QPixmapList m_pixmaps;
|
||||||
|
|
||||||
QPixmap m_pixmap;
|
int m_val;
|
||||||
|
bool m_checked_a;
|
||||||
|
bool m_checked_d;
|
||||||
|
|
||||||
|
bool m_show_always;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#ifndef __PLAYLISTMENU_H__
|
#ifndef __PLAYLISTMENU_H__
|
||||||
#define __PLAYLISTMENU_H__
|
#define __PLAYLISTMENU_H__
|
||||||
|
|
||||||
#include <skin.h>
|
#include "skin.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,14 +125,17 @@ Skin::handle_titlebar (const QPixmap &img)
|
||||||
m_items[STATUSBAR_0] = img.copy(27, 29, 275, 14);
|
m_items[STATUSBAR_0] = img.copy(27, 29, 275, 14);
|
||||||
m_items[STATUSBAR_1] = img.copy(27, 29+13, 275, 14);
|
m_items[STATUSBAR_1] = img.copy(27, 29+13, 275, 14);
|
||||||
|
|
||||||
m_items[CLUTTER_ON] = img.copy(304+8*0, 0, 8, 43);
|
// Must be the same order as ClutterItems
|
||||||
m_items[CLUTTER_OFF] = img.copy(304+8*1, 0, 8, 43);
|
QPixmapList clist;
|
||||||
|
clist << img.copy(304+8*0, 0, 8, 43); // CLUTTER_ON
|
||||||
|
clist << img.copy(304+8*1, 0, 8, 43); // CLUTTER_OFF
|
||||||
|
|
||||||
m_items[CLUTTER_O] = img.copy(304+8*0, 44, 8, 43);
|
clist << img.copy(304+8*0, 44, 8, 43); // CLUTTER_O
|
||||||
m_items[CLUTTER_A] = img.copy(304+8*1, 44, 8, 43);
|
clist << img.copy(304+8*1, 44, 8, 43); // CLUTTER_A
|
||||||
m_items[CLUTTER_I] = img.copy(304+8*2, 44, 8, 43);
|
clist << img.copy(304+8*2, 44, 8, 43); // CLUTTER_I
|
||||||
m_items[CLUTTER_D] = img.copy(304+8*3, 44, 8, 43);
|
clist << img.copy(304+8*3, 44, 8, 43); // CLUTTER_D
|
||||||
m_items[CLUTTER_V] = img.copy(304+8*4, 44, 8, 43);
|
clist << img.copy(304+8*4, 44, 8, 43); // CLUTTER_V
|
||||||
|
m_pixmaplists[PIXMAPS_CLUTTERBAR] = clist;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,8 @@ class Skin : public QObject
|
||||||
SLIDER_BALANCEBAR_BUTTON,
|
SLIDER_BALANCEBAR_BUTTON,
|
||||||
SLIDER_EQUALIZER,
|
SLIDER_EQUALIZER,
|
||||||
SLIDER_EQUALIZER_BGS,
|
SLIDER_EQUALIZER_BGS,
|
||||||
|
/* Various */
|
||||||
|
PIXMAPS_CLUTTERBAR,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// enum Part { // Old and not yet sorted enum
|
// enum Part { // Old and not yet sorted enum
|
||||||
|
|
@ -177,20 +179,10 @@ class Skin : public QObject
|
||||||
TITLEBAR_1,
|
TITLEBAR_1,
|
||||||
STATUSBAR_0,
|
STATUSBAR_0,
|
||||||
STATUSBAR_1,
|
STATUSBAR_1,
|
||||||
SEEKBAR,
|
|
||||||
SEEKBAR_POS_0,
|
|
||||||
SEEKBAR_POS_1,
|
|
||||||
TEXTBG,
|
TEXTBG,
|
||||||
PIC_PLAY,
|
PIC_PLAY,
|
||||||
PIC_PAUSE,
|
PIC_PAUSE,
|
||||||
PIC_STOP,
|
PIC_STOP,
|
||||||
CLUTTER_ON,
|
|
||||||
CLUTTER_OFF,
|
|
||||||
CLUTTER_O,
|
|
||||||
CLUTTER_A,
|
|
||||||
CLUTTER_I,
|
|
||||||
CLUTTER_D,
|
|
||||||
CLUTTER_V,
|
|
||||||
EQ_WIN_BG,
|
EQ_WIN_BG,
|
||||||
EQ_WIN_TITLE_ACTIVE,
|
EQ_WIN_TITLE_ACTIVE,
|
||||||
EQ_WIN_TITLE_INACTIVE,
|
EQ_WIN_TITLE_INACTIVE,
|
||||||
|
|
@ -200,6 +192,17 @@ class Skin : public QObject
|
||||||
POSBAR,
|
POSBAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// The order here must be the same as in handle_titlebar
|
||||||
|
enum ClutterItems {
|
||||||
|
CLUTTER_ON,
|
||||||
|
CLUTTER_OFF,
|
||||||
|
CLUTTER_O,
|
||||||
|
CLUTTER_A,
|
||||||
|
CLUTTER_I,
|
||||||
|
CLUTTER_D,
|
||||||
|
CLUTTER_V
|
||||||
|
};
|
||||||
|
|
||||||
enum PlaylistParts {
|
enum PlaylistParts {
|
||||||
PLS_CORNER_UL_0,
|
PLS_CORNER_UL_0,
|
||||||
PLS_CORNER_UL_1,
|
PLS_CORNER_UL_1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue