mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cover Browser: Scale text size with height of cover browser. Only show a reflection of half the cover. Also Fix #5808 (Cover browser in 0.7.2 now has reduced quality images.)
This commit is contained in:
parent
421f2ebc90
commit
2511b5d135
@ -83,7 +83,6 @@ if pictureflow is not None:
|
||||
self.setFocusPolicy(Qt.WheelFocus)
|
||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
|
||||
QSizePolicy.Expanding))
|
||||
self.setZoomFactor(150)
|
||||
|
||||
def sizeHint(self):
|
||||
return self.minimumSize()
|
||||
|
@ -85,7 +85,9 @@ typedef long PFreal;
|
||||
|
||||
typedef unsigned short QRgb565;
|
||||
|
||||
#define FONT_SIZE 18
|
||||
#define REFLECTION_FACTOR 1.5
|
||||
|
||||
#define MAX(x, y) ((x > y) ? x : y)
|
||||
|
||||
#define RGB565_RED_MASK 0xF800
|
||||
#define RGB565_GREEN_MASK 0x07E0
|
||||
@ -124,6 +126,7 @@ inline PFreal floatToFixed(float val)
|
||||
return (PFreal)(val*PFREAL_ONE);
|
||||
}
|
||||
|
||||
// sinTable {{{
|
||||
#define IANGLE_MAX 1024
|
||||
#define IANGLE_MASK 1023
|
||||
|
||||
@ -293,6 +296,7 @@ int main(int, char**)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
// }}}
|
||||
|
||||
inline PFreal fsin(int iangle)
|
||||
{
|
||||
@ -315,6 +319,8 @@ struct SlideInfo
|
||||
PFreal cy;
|
||||
};
|
||||
|
||||
// PicturePlowPrivate {{{
|
||||
|
||||
class PictureFlowPrivate
|
||||
{
|
||||
public:
|
||||
@ -369,6 +375,7 @@ private:
|
||||
|
||||
int slideWidth;
|
||||
int slideHeight;
|
||||
int fontSize;
|
||||
int zoom;
|
||||
int queueLength;
|
||||
|
||||
@ -406,6 +413,7 @@ PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w, int queueLength_)
|
||||
|
||||
slideWidth = 200;
|
||||
slideHeight = 200;
|
||||
fontSize = 10;
|
||||
zoom = 100;
|
||||
|
||||
centerIndex = 0;
|
||||
@ -542,8 +550,11 @@ void PictureFlowPrivate::showSlide(int index)
|
||||
|
||||
void PictureFlowPrivate::resize(int w, int h)
|
||||
{
|
||||
slideHeight = int(float(h)/2.);
|
||||
if (w < 10) w = 10;
|
||||
if (h < 10) h = 10;
|
||||
slideHeight = int(float(h)/REFLECTION_FACTOR);
|
||||
slideWidth = int(float(slideHeight) * 2/3.);
|
||||
fontSize = MAX(int(h/20.), 12);
|
||||
recalc(w, h);
|
||||
resetSlides();
|
||||
triggerRender();
|
||||
@ -592,8 +603,8 @@ static QImage prepareSurface(QImage img, int w, int h)
|
||||
img = img.scaled(w, h, Qt::IgnoreAspectRatio, mode);
|
||||
|
||||
// slightly larger, to accomodate for the reflection
|
||||
int hs = h * 2;
|
||||
int hofs = h / 3;
|
||||
int hs = int(h * REFLECTION_FACTOR);
|
||||
int hofs = 0;
|
||||
|
||||
// offscreen buffer: black is sweet
|
||||
QImage result(hs, w, QImage::Format_RGB16);
|
||||
@ -715,13 +726,13 @@ void PictureFlowPrivate::render()
|
||||
|
||||
QFont font = QFont();
|
||||
font.setBold(true);
|
||||
font.setPointSize(FONT_SIZE);
|
||||
font.setPixelSize(fontSize);
|
||||
painter.setFont(font);
|
||||
painter.setPen(Qt::white);
|
||||
//painter.setPen(QColor(255,255,255,127));
|
||||
|
||||
if (centerIndex < slideCount() && centerIndex > -1)
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2-FONT_SIZE*3),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2-fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(centerIndex));
|
||||
|
||||
painter.end();
|
||||
@ -766,7 +777,7 @@ void PictureFlowPrivate::render()
|
||||
|
||||
QFont font = QFont();
|
||||
font.setBold(true);
|
||||
font.setPointSize(FONT_SIZE);
|
||||
font.setPixelSize(fontSize);
|
||||
painter.setFont(font);
|
||||
|
||||
int leftTextIndex = (step>0) ? centerIndex : centerIndex-1;
|
||||
@ -774,12 +785,12 @@ void PictureFlowPrivate::render()
|
||||
|
||||
painter.setPen(QColor(255,255,255, (255-fade) ));
|
||||
if (leftTextIndex < sc && leftTextIndex > -1)
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - FONT_SIZE*3),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(leftTextIndex));
|
||||
|
||||
painter.setPen(QColor(255,255,255, fade));
|
||||
if (leftTextIndex+1 < sc && leftTextIndex > -2)
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - FONT_SIZE*3),
|
||||
painter.drawText( QRect(0,0, buffer.width(), buffer.height()*2 - fontSize*3),
|
||||
Qt::AlignCenter, slideImages->caption(leftTextIndex+1));
|
||||
|
||||
|
||||
@ -893,7 +904,7 @@ int col1, int col2)
|
||||
int center = (sh*BILINEAR_STRETCH_VER/2);
|
||||
int dy = dist*BILINEAR_STRETCH_VER / h;
|
||||
#else
|
||||
int center = (sh/2);
|
||||
int center = sh/2;
|
||||
int dy = dist / h;
|
||||
#endif
|
||||
int p1 = center*PFREAL_ONE - dy/2;
|
||||
@ -1110,8 +1121,9 @@ void PictureFlowPrivate::clearSurfaceCache()
|
||||
surfaceCache.clear();
|
||||
}
|
||||
|
||||
// -----------------------------------------
|
||||
// }}}
|
||||
|
||||
// PictureFlow {{{
|
||||
PictureFlow::PictureFlow(QWidget* parent, int queueLength): QWidget(parent)
|
||||
{
|
||||
d = new PictureFlowPrivate(this, queueLength);
|
||||
@ -1387,3 +1399,5 @@ void PictureFlow::emitcurrentChanged(int index) { emit currentChanged(index); }
|
||||
int FlowImages::count() { return 0; }
|
||||
QImage FlowImages::image(int index) { index=0; return QImage(); }
|
||||
QString FlowImages::caption(int index) {index=0; return QString(); }
|
||||
|
||||
// }}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user