mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
Merged in daisuke_cato/yacreader/dev_cato7 (pull request #42)
Horizontal aware auto scrolling (target branch = develop)
This commit is contained in:
commit
04ec0c5acb
@ -225,6 +225,12 @@ void GoToFlow::updateConfig(QSettings * settings)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
||||
void GoToFlow::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//SlideInitializer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -63,6 +63,8 @@ private slots:
|
||||
void setFlowType(FlowType flowType);
|
||||
void updateSize();
|
||||
void updateConfig(QSettings * settings);
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
signals:
|
||||
void goToPage(unsigned int page);
|
||||
|
||||
|
@ -164,3 +164,8 @@ void GoToFlowGL::resizeEvent(QResizeEvent *event)
|
||||
toolBar->move(0, event->size().height() - toolBar->height());
|
||||
toolBar->setFixedWidth(width());
|
||||
}
|
||||
|
||||
void GoToFlowGL::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
void updateSize();
|
||||
|
||||
void updateConfig(QSettings * settings);
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
signals:
|
||||
void goToPage(unsigned int page);
|
||||
|
@ -29,6 +29,7 @@ public slots:
|
||||
virtual void setImageReady(int index,const QByteArray & image) = 0;
|
||||
virtual void updateSize() = 0;
|
||||
virtual void updateConfig(QSettings * settings) = 0;
|
||||
virtual void setFlowRightToLeft(bool b) = 0;
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
@ -963,6 +963,7 @@ void Viewer::doubleMangaPageSwitch()
|
||||
doubleMangaPage = !doubleMangaPage;
|
||||
render->doubleMangaPageSwitch();
|
||||
Configuration::getConfiguration().setDoubleMangaPage(doubleMangaPage);
|
||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
||||
}
|
||||
|
||||
void Viewer::resetContent()
|
||||
|
@ -200,7 +200,7 @@ struct Preset pressetYACReaderFlowDownConfig = {
|
||||
};
|
||||
/*Constructor*/
|
||||
YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p)
|
||||
:QOpenGLWidget(/*QOpenGLWidget migration QGLFormat(QGL::SampleBuffers),*/ parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false),hasBeenInitialized(false)
|
||||
:QOpenGLWidget(/*QOpenGLWidget migration QGLFormat(QGL::SampleBuffers),*/ parent),numObjects(0),lazyPopulateObjects(-1),bUseVSync(false),hasBeenInitialized(false),flowRightToLeft(false)
|
||||
{
|
||||
updateCount = 0;
|
||||
config = p;
|
||||
@ -385,7 +385,11 @@ void YACReaderFlowGL::udpatePerspective(int width, int height)
|
||||
/*Private*/
|
||||
void YACReaderFlowGL::calcPos(YACReader3DImage & image, int pos)
|
||||
{
|
||||
if(pos == 0){
|
||||
if(flowRightToLeft){
|
||||
pos = pos * -1;
|
||||
}
|
||||
|
||||
if(pos == 0){
|
||||
image.current = centerPos;
|
||||
}else{
|
||||
if(pos > 0){
|
||||
@ -1052,6 +1056,11 @@ void YACReaderFlowGL::render()
|
||||
//do nothing
|
||||
}
|
||||
|
||||
void YACReaderFlowGL::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flowRightToLeft = b;
|
||||
}
|
||||
|
||||
//EVENTOS
|
||||
|
||||
void YACReaderFlowGL::wheelEvent(QWheelEvent * event)
|
||||
@ -1073,7 +1082,7 @@ void YACReaderFlowGL::wheelEvent(QWheelEvent * event)
|
||||
|
||||
void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_Left)
|
||||
if((event->key() == Qt::Key_Left && !flowRightToLeft) || (event->key() == Qt::Key_Right && flowRightToLeft))
|
||||
{
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
setCurrentIndex((currentSelected-10<0)?0:currentSelected-10);
|
||||
@ -1083,7 +1092,7 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(event->key() == Qt::Key_Right)
|
||||
if((event->key() == Qt::Key_Right && !flowRightToLeft) || (event->key() == Qt::Key_Left && flowRightToLeft))
|
||||
{
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
setCurrentIndex((currentSelected+10>=numObjects)?numObjects-1:currentSelected+10);
|
||||
@ -1128,7 +1137,7 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
|
||||
|
||||
if(posX >= 0.5)
|
||||
if((posX >= 0.5 && !flowRightToLeft) || (posX <=-0.5 && flowRightToLeft))
|
||||
{
|
||||
//int index = currentSelected+1;
|
||||
//while((cfImages[index].current.x-cfImages[index].width/(2.0*config.rotation)) < posX)
|
||||
@ -1136,7 +1145,7 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
//setCurrentIndex(index-1);
|
||||
showNext();
|
||||
}
|
||||
else if(posX <=-0.5)
|
||||
else if((posX <=-0.5 && !flowRightToLeft) || (posX >= 0.5 && flowRightToLeft) )
|
||||
showPrevious();
|
||||
} else
|
||||
QOpenGLWidget::mousePressEvent(event);
|
||||
|
@ -173,6 +173,9 @@ protected:
|
||||
//sets the updateInterval in ms
|
||||
static int updateInterval;
|
||||
|
||||
// sets flow direction right-to-left (manga mode)
|
||||
bool flowRightToLeft;
|
||||
|
||||
void startAnimationTimer();
|
||||
void stopAnimationTimer();
|
||||
|
||||
@ -251,6 +254,8 @@ public:
|
||||
|
||||
void useVSync(bool b);
|
||||
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
virtual void updateImageData() = 0;
|
||||
|
||||
void reset();
|
||||
|
@ -207,6 +207,8 @@ public:
|
||||
QVector<SlideInfo> leftSlides;
|
||||
QVector<SlideInfo> rightSlides;
|
||||
int centerIndex;
|
||||
|
||||
bool flowRightToLeft;
|
||||
};
|
||||
|
||||
class PictureFlowAnimator
|
||||
@ -281,7 +283,7 @@ private:
|
||||
|
||||
PictureFlowState::PictureFlowState(int a, float sr):
|
||||
backgroundColor(0), slideWidth(150), slideHeight(200),
|
||||
reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0) , rawAngle(a), spacingRatio(sr)
|
||||
reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0) , rawAngle(a), spacingRatio(sr), flowRightToLeft(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -327,7 +329,10 @@ void PictureFlowState::reset()
|
||||
si.angle = angle;
|
||||
si.cx = -(offsetX + spacing*(i)*PFREAL_ONE);
|
||||
si.cy = offsetY;
|
||||
si.slideIndex = centerIndex-1-i;
|
||||
if(!flowRightToLeft)
|
||||
si.slideIndex = centerIndex-1-i;
|
||||
else
|
||||
si.slideIndex = centerIndex+1+i;
|
||||
si.blend = 200;
|
||||
if(i == (int)leftSlides.count()-2)
|
||||
si.blend = 128;
|
||||
@ -344,7 +349,10 @@ void PictureFlowState::reset()
|
||||
si.angle = -angle;
|
||||
si.cx = offsetX + spacing*(i)*PFREAL_ONE;
|
||||
si.cy = offsetY;
|
||||
si.slideIndex = centerIndex+1+i;
|
||||
if(!flowRightToLeft)
|
||||
si.slideIndex = centerIndex+1+i;
|
||||
else
|
||||
si.slideIndex = centerIndex-1-i;
|
||||
si.blend = 200;
|
||||
if(i == (int)rightSlides.count()-2)
|
||||
si.blend = 128;
|
||||
@ -423,13 +431,31 @@ void PictureFlowAnimator::update()
|
||||
frame = index << 16;
|
||||
state->centerSlide.slideIndex = state->centerIndex;
|
||||
for(int i = 0; i < (int)state->leftSlides.count(); i++)
|
||||
state->leftSlides[i].slideIndex = state->centerIndex-1-i;
|
||||
{
|
||||
if(!state->flowRightToLeft)
|
||||
state->leftSlides[i].slideIndex = state->centerIndex-1-i;
|
||||
else
|
||||
state->leftSlides[i].slideIndex = state->centerIndex+1+i;
|
||||
}
|
||||
for(int i = 0; i < (int)state->rightSlides.count(); i++)
|
||||
state->rightSlides[i].slideIndex = state->centerIndex+1+i;
|
||||
{
|
||||
if(!state->flowRightToLeft)
|
||||
state->rightSlides[i].slideIndex = state->centerIndex+1+i;
|
||||
else
|
||||
state->rightSlides[i].slideIndex = state->centerIndex-1-i;
|
||||
}
|
||||
}
|
||||
|
||||
state->centerSlide.angle = (step * tick * state->angle) >> 16;
|
||||
state->centerSlide.cx = -step * fmul(state->offsetX, ftick);
|
||||
if(!state->flowRightToLeft)
|
||||
{
|
||||
state->centerSlide.angle = (step * tick * state->angle) >> 16;
|
||||
state->centerSlide.cx = -step * fmul(state->offsetX, ftick);
|
||||
}
|
||||
else
|
||||
{
|
||||
state->centerSlide.angle = (-step * tick * state->angle) >> 16;
|
||||
state->centerSlide.cx = step * fmul(state->offsetX, ftick);
|
||||
}
|
||||
state->centerSlide.cy = fmul(state->offsetY, ftick);
|
||||
|
||||
if(state->centerIndex == target)
|
||||
@ -443,7 +469,10 @@ void PictureFlowAnimator::update()
|
||||
{
|
||||
SlideInfo& si = state->leftSlides[i];
|
||||
si.angle = state->angle;
|
||||
si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick);
|
||||
if(!state->flowRightToLeft)
|
||||
si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick);
|
||||
else
|
||||
si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick);
|
||||
si.cy = state->offsetY;
|
||||
}
|
||||
|
||||
@ -451,24 +480,41 @@ void PictureFlowAnimator::update()
|
||||
{
|
||||
SlideInfo& si = state->rightSlides[i];
|
||||
si.angle = -state->angle;
|
||||
si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick;
|
||||
if(!state->flowRightToLeft)
|
||||
si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick;
|
||||
else
|
||||
si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick;
|
||||
si.cy = state->offsetY;
|
||||
}
|
||||
|
||||
if(step > 0)
|
||||
if(step > 0 && !state->flowRightToLeft)
|
||||
{
|
||||
PFreal ftick = (neg * PFREAL_ONE) >> 16;
|
||||
state->rightSlides[0].angle = -(neg * state->angle) >> 16;
|
||||
state->rightSlides[0].cx = fmul(state->offsetX, ftick);
|
||||
state->rightSlides[0].cy = fmul(state->offsetY, ftick);
|
||||
}
|
||||
else
|
||||
else if(!state->flowRightToLeft)
|
||||
{
|
||||
PFreal ftick = (pos * PFREAL_ONE) >> 16;
|
||||
state->leftSlides[0].angle = (pos * state->angle) >> 16;
|
||||
state->leftSlides[0].cx = -fmul(state->offsetX, ftick);
|
||||
state->leftSlides[0].cy = fmul(state->offsetY, ftick);
|
||||
}
|
||||
else if(step < 0)
|
||||
{
|
||||
PFreal ftick = (pos * PFREAL_ONE) >> 16;
|
||||
state->rightSlides[0].angle = -(pos * state->angle) >> 16;
|
||||
state->rightSlides[0].cx = fmul(state->offsetX, ftick);
|
||||
state->rightSlides[0].cy = fmul(state->offsetY, ftick);
|
||||
}
|
||||
else
|
||||
{
|
||||
PFreal ftick = (neg * PFREAL_ONE) >> 16;
|
||||
state->leftSlides[0].angle = (neg * state->angle) >> 16;
|
||||
state->leftSlides[0].cx = -fmul(state->offsetX, ftick);
|
||||
state->leftSlides[0].cy = fmul(state->offsetY, ftick);
|
||||
}
|
||||
|
||||
// must change direction ?
|
||||
if(target < index) if(step > 0)
|
||||
@ -1053,6 +1099,13 @@ void PictureFlow::setReflectionEffect(ReflectionEffect effect)
|
||||
triggerRender();
|
||||
}
|
||||
|
||||
void PictureFlow::setFlowRightToLeft(bool b)
|
||||
{
|
||||
d->state->flowRightToLeft = b;
|
||||
d->state->reset();
|
||||
triggerRender();
|
||||
}
|
||||
|
||||
QImage PictureFlow::slide(int index) const
|
||||
{
|
||||
QImage* i = 0;
|
||||
@ -1225,7 +1278,8 @@ void PictureFlow::showSlide(unsigned int index)
|
||||
|
||||
void PictureFlow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if(event->key() == Qt::Key_Left)
|
||||
if((event->key() == Qt::Key_Left && !(d->state->flowRightToLeft))
|
||||
|| (event->key() == Qt::Key_Right && d->state->flowRightToLeft))
|
||||
{
|
||||
/*if(event->modifiers() == Qt::ControlModifier)
|
||||
showSlide(centerIndex()-10);
|
||||
@ -1235,7 +1289,8 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(event->key() == Qt::Key_Right)
|
||||
if((event->key() == Qt::Key_Right && !(d->state->flowRightToLeft))
|
||||
|| (event->key() == Qt::Key_Left && d->state->flowRightToLeft))
|
||||
{
|
||||
/*if(event->modifiers() == Qt::ControlModifier)
|
||||
showSlide(centerIndex()+10);
|
||||
@ -1256,10 +1311,19 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
|
||||
|
||||
void PictureFlow::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if(event->x() > width()/2)
|
||||
mousePressEvent(event, 0);
|
||||
}
|
||||
|
||||
void PictureFlow::mousePressEvent(QMouseEvent* event, int slideWidth)
|
||||
{
|
||||
if((event->x() > (width() + slideWidth)/2 && !(d->state->flowRightToLeft))
|
||||
|| (event->x() < (width() - slideWidth)/2 && d->state->flowRightToLeft))
|
||||
showNext();
|
||||
else
|
||||
showPrevious();
|
||||
else if((event->x() < (width() - slideWidth)/2 && !(d->state->flowRightToLeft))
|
||||
|| (event->x() > (width() + slideWidth)/2 && d->state->flowRightToLeft))
|
||||
showPrevious();
|
||||
|
||||
//else (centered slide space)
|
||||
}
|
||||
|
||||
void PictureFlow::paintEvent(QPaintEvent* event)
|
||||
|
@ -119,7 +119,12 @@ public:
|
||||
*/
|
||||
void setReflectionEffect(ReflectionEffect effect);
|
||||
|
||||
/*!
|
||||
Sets the flow direction right-to-left (manga mode)
|
||||
*/
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/*!
|
||||
@ -213,6 +218,7 @@ public:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event, int slideWidth);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
private slots:
|
||||
|
@ -7,12 +7,7 @@ YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(p
|
||||
|
||||
void YACReaderFlow::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if(event->x() > (width()+slideSize().width())/2)
|
||||
showNext();
|
||||
else
|
||||
if(event->x() < (width()-slideSize().width())/2)
|
||||
showPrevious();
|
||||
//else (centered cover space)
|
||||
PictureFlow::mousePressEvent(event, slideSize().width());
|
||||
}
|
||||
|
||||
void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user