added some dank tab animations
This commit is contained in:
@@ -18,7 +18,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
|||||||
, chatWidget(parent)
|
, chatWidget(parent)
|
||||||
, scrollbar(this)
|
, scrollbar(this)
|
||||||
{
|
{
|
||||||
this->scrollbar.setSmallChange(2);
|
this->scrollbar.setSmallChange(5);
|
||||||
|
|
||||||
QObject::connect(&Settings::getInstance(), &Settings::wordTypeMaskChanged,
|
QObject::connect(&Settings::getInstance(), &Settings::wordTypeMaskChanged,
|
||||||
this, &ChatWidgetView::wordTypeMaskChanged);
|
this, &ChatWidgetView::wordTypeMaskChanged);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ Notebook::select(NotebookPage *page)
|
|||||||
if (page != nullptr) {
|
if (page != nullptr) {
|
||||||
page->setHidden(false);
|
page->setHidden(false);
|
||||||
page->tab->setSelected(true);
|
page->tab->setSelected(true);
|
||||||
|
page->tab->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->selectedPage != nullptr) {
|
if (this->selectedPage != nullptr) {
|
||||||
@@ -110,7 +111,7 @@ Notebook::tabAt(QPoint point, int &index)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (auto *page : pages) {
|
for (auto *page : pages) {
|
||||||
if (page->tab->geometry().contains(point)) {
|
if (page->tab->getDesiredRect().contains(point)) {
|
||||||
index = i;
|
index = i;
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
@@ -135,7 +136,7 @@ Notebook::rearrangePage(NotebookPage *page, int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Notebook::performLayout()
|
Notebook::performLayout(bool animated)
|
||||||
{
|
{
|
||||||
int x = 48, y = 0;
|
int x = 48, y = 0;
|
||||||
int tabHeight = 16;
|
int tabHeight = 16;
|
||||||
@@ -148,10 +149,10 @@ Notebook::performLayout()
|
|||||||
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
|
(i == this->pages.last() ? tabHeight : 0) + x + i->tab->width() >
|
||||||
width()) {
|
width()) {
|
||||||
y += i->tab->height();
|
y += i->tab->height();
|
||||||
i->tab->moveAnimated(QPoint(0, y));
|
i->tab->moveAnimated(QPoint(0, y), animated);
|
||||||
x = i->tab->width();
|
x = i->tab->width();
|
||||||
} else {
|
} else {
|
||||||
i->tab->moveAnimated(QPoint(x, y));
|
i->tab->moveAnimated(QPoint(x, y), animated);
|
||||||
x += i->tab->width();
|
x += i->tab->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +170,7 @@ Notebook::performLayout()
|
|||||||
void
|
void
|
||||||
Notebook::resizeEvent(QResizeEvent *)
|
Notebook::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
performLayout();
|
performLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ public:
|
|||||||
return selectedPage;
|
return selectedPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void performLayout();
|
void performLayout(bool animate = true);
|
||||||
|
|
||||||
NotebookPage *tabAt(QPoint point, int &index);
|
NotebookPage *tabAt(QPoint point, int &index);
|
||||||
void rearrangePage(NotebookPage *page, int index);
|
void rearrangePage(NotebookPage *page, int index);
|
||||||
|
|||||||
+26
-18
@@ -10,8 +10,9 @@ namespace widgets {
|
|||||||
|
|
||||||
NotebookTab::NotebookTab(Notebook *notebook)
|
NotebookTab::NotebookTab(Notebook *notebook)
|
||||||
: QWidget(notebook)
|
: QWidget(notebook)
|
||||||
// , posAnimation(this, "pos")
|
, posAnimation(this, "pos")
|
||||||
// , posAnimated(false)
|
, posAnimated(false)
|
||||||
|
, posAnimationDesired()
|
||||||
, notebook(notebook)
|
, notebook(notebook)
|
||||||
, text("<no title>")
|
, text("<no title>")
|
||||||
, selected(false)
|
, selected(false)
|
||||||
@@ -24,12 +25,17 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
|||||||
this->calcSize();
|
this->calcSize();
|
||||||
this->setAcceptDrops(true);
|
this->setAcceptDrops(true);
|
||||||
|
|
||||||
|
posAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||||
|
|
||||||
/* XXX(pajlada): Fix this
|
/* XXX(pajlada): Fix this
|
||||||
QObject::connect(&Settings::getInstance().getHideTabX(),
|
QObject::connect(&Settings::getInstance().getHideTabX(),
|
||||||
&BoolSetting::valueChanged, this,
|
&BoolSetting::valueChanged, this,
|
||||||
&NotebookTab::hideTabXChanged);
|
&NotebookTab::hideTabXChanged);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Settings::getInstance().hideTabX.valueChanged.connect(
|
||||||
|
// boost::bind(&NotebookTab::hideTabXChanged, this));
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,26 +59,28 @@ NotebookTab::calcSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NotebookTab::moveAnimated(QPoint pos)
|
NotebookTab::moveAnimated(QPoint pos, bool animated)
|
||||||
{
|
{
|
||||||
move(pos);
|
// move(pos);
|
||||||
|
|
||||||
// if (posAnimated == false) {
|
posAnimationDesired = pos;
|
||||||
// move(pos);
|
|
||||||
|
|
||||||
// posAnimated = true;
|
if (!animated || posAnimated == false) {
|
||||||
// return;
|
move(pos);
|
||||||
// }
|
|
||||||
|
|
||||||
// if (this->posAnimation.endValue() == pos) {
|
posAnimated = true;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// this->posAnimation.stop();
|
if (this->posAnimation.endValue() == pos) {
|
||||||
// this->posAnimation.setDuration(50);
|
return;
|
||||||
// this->posAnimation.setStartValue(this->pos());
|
}
|
||||||
// this->posAnimation.setEndValue(pos);
|
|
||||||
// this->posAnimation.start();
|
this->posAnimation.stop();
|
||||||
|
this->posAnimation.setDuration(75);
|
||||||
|
this->posAnimation.setStartValue(this->pos());
|
||||||
|
this->posAnimation.setEndValue(pos);
|
||||||
|
this->posAnimation.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -184,7 +192,7 @@ NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
|||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->mouseDown && !this->rect().contains(event->pos())) {
|
if (this->mouseDown && !this->getDesiredRect().contains(event->pos())) {
|
||||||
QPoint relPoint = this->mapToParent(event->pos());
|
QPoint relPoint = this->mapToParent(event->pos());
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
|
|||||||
+11
-3
@@ -66,7 +66,14 @@ public:
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveAnimated(QPoint pos);
|
void moveAnimated(QPoint pos, bool animated = true);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QRect
|
||||||
|
getDesiredRect() const
|
||||||
|
{
|
||||||
|
return QRect(posAnimationDesired, this->size());
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
@@ -81,8 +88,9 @@ protected:
|
|||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QPropertyAnimation posAnimation;
|
QPropertyAnimation posAnimation;
|
||||||
// bool posAnimated;
|
bool posAnimated;
|
||||||
|
QPoint posAnimationDesired;
|
||||||
|
|
||||||
Notebook *notebook;
|
Notebook *notebook;
|
||||||
|
|
||||||
|
|||||||
@@ -172,21 +172,21 @@ ScrollBar::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
if (y < this->buttonHeight) {
|
if (y < this->buttonHeight) {
|
||||||
if (this->mouseDownIndex == 0) {
|
if (this->mouseDownIndex == 0) {
|
||||||
this->setValue(this->value - this->smallChange);
|
this->setValue(this->value - this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else if (y < this->thumbRect.y()) {
|
} else if (y < this->thumbRect.y()) {
|
||||||
if (this->mouseDownIndex == 0) {
|
if (this->mouseDownIndex == 1) {
|
||||||
this->setValue(this->value - this->smallChange);
|
this->setValue(this->value - this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else if (this->thumbRect.contains(2, y)) {
|
} else if (this->thumbRect.contains(2, y)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (y < height() - this->buttonHeight) {
|
} else if (y < height() - this->buttonHeight) {
|
||||||
if (this->mouseDownIndex == 0) {
|
if (this->mouseDownIndex == 3) {
|
||||||
this->setValue(this->value + this->smallChange);
|
this->setValue(this->value + this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this->mouseDownIndex == 0) {
|
if (this->mouseDownIndex == 4) {
|
||||||
this->setValue(this->value + this->smallChange);
|
this->setValue(this->value + this->smallChange, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
if (animated) {
|
if (animated) {
|
||||||
this->valueAnimation.stop();
|
this->valueAnimation.stop();
|
||||||
this->valueAnimation.setStartValue(this->value);
|
this->valueAnimation.setStartValue(this->value);
|
||||||
|
|
||||||
this->valueAnimation.setEndValue(value);
|
this->valueAnimation.setEndValue(value);
|
||||||
this->valueAnimation.start();
|
this->valueAnimation.start();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user