summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2011-02-23 07:23:11 +0000
committerdeva <deva>2011-02-23 07:23:11 +0000
commit8fbf461b279c0b96fdf5b764ef04376b5f7da7ec (patch)
tree458975653c6c84a1b005a6438fc548fa14f5df9d /client
parent47561fdd6e67ab1918acf8f44ed54759bdf467a7 (diff)
Fade between widgets introduced in Collapser.
Diffstat (limited to 'client')
-rw-r--r--client/collapser.cc72
-rw-r--r--client/collapser.h12
-rw-r--r--client/macrodrawer.cc4
-rw-r--r--client/resumewidget.cc2
4 files changed, 71 insertions, 19 deletions
diff --git a/client/collapser.cc b/client/collapser.cc
index a00dcff..6ae9d21 100644
--- a/client/collapser.cc
+++ b/client/collapser.cc
@@ -31,7 +31,7 @@
#include "debug.h"
-#define ANIM_TIME 250
+#define ANIM_TIME 2000
#define ANIM_INTERVAL 20
Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed,
@@ -58,48 +58,57 @@ Collapser::Collapser(QWidget *collapsed, QWidget *expanded, bool setcollapsed,
void Collapser::setWidgets(QWidget *collapsed, QWidget *expanded)
{
+ DEBUG(collapser, "\n");
setCollapsedWidget(collapsed);
setExpandedWidget(expanded);
}
void Collapser::setCollapsedWidget(QWidget *collapsed)
{
+ DEBUG(collapser, "\n");
this->collapsed = collapsed;
-
+ /*
if(isCollapsed() == true && collapsed) {
layout()->addWidget(collapsed);
collapsed->setVisible(true);
}
+ */
}
void Collapser::setExpandedWidget(QWidget *expanded)
{
+ DEBUG(collapser, "\n");
this->expanded = expanded;
-
+ /*
if(isCollapsed() == false && expanded) {
layout()->addWidget(expanded);
expanded->setVisible(true);
}
+ */
}
QWidget *Collapser::collapsedWidget()
{
+ DEBUG(collapser, "\n");
return collapsed;
}
QWidget *Collapser::expandedWidget()
{
+ DEBUG(collapser, "\n");
return expanded;
}
bool Collapser::isCollapsed()
{
+ DEBUG(collapser, "\n");
return is_collapsed;
}
void Collapser::setCollapsed(bool setcollapsed)
{
+ DEBUG(collapser, "\n");
if(this->is_collapsed == setcollapsed) return;
if(setcollapsed) collapse();
@@ -108,6 +117,7 @@ void Collapser::setCollapsed(bool setcollapsed)
void Collapser::collapse()
{
+ DEBUG(collapser, "\n");
emit collapsing();
t_anim.start();
@@ -119,14 +129,17 @@ void Collapser::collapse()
expanded->setVisible(false);
layout()->removeWidget(expanded);
}
+ if(expanded) placeholder.grab_from(expanded);
layout()->addWidget(&placeholder);
placeholder.setVisible(true);
- if(expanded) placeholder.grab(expanded);
+
+ if(collapsed) placeholder.grab_to(collapsed);
}
void Collapser::expand()
{
+ DEBUG(collapser, "\n");
emit expanding();
t_anim.start();
@@ -134,16 +147,16 @@ void Collapser::expand()
// show expanded
if(collapsed) {
collapsed->setVisible(false);
- // qApp->processEvents(); // Make sure it is actually invisble before removing it form the layout.
+ //qApp->processEvents(); // Make sure it is actually invisble before removing it form the layout.
layout()->removeWidget(collapsed);
+
+ placeholder.grab_from(collapsed);
}
- if(expanded) {
- layout()->addWidget(&placeholder);
- placeholder.setVisible(true);
- placeholder.grab(expanded);
- // layout()->addWidget(expanded);
- // expanded->setVisible(true);
- }
+
+ layout()->addWidget(&placeholder);
+ placeholder.setVisible(true);
+
+ if(expanded) placeholder.grab_to(expanded);
is_collapsed = false;
timer->start();
@@ -151,12 +164,14 @@ void Collapser::expand()
void Collapser::toggleCollapse()
{
+ DEBUG(collapser, "\n");
if(!is_collapsed) collapse();
else expand();
}
void Collapser::anim()
{
+ DEBUG(collapser, "\n");
int c_height = 16;
int e_height = 16;
if(collapsed) {
@@ -175,6 +190,8 @@ void Collapser::anim()
if(x < 1) {
y = x * x * x;
+ placeholder.setWeight(x);
+
int height;
if(!is_collapsed) {
height = (int)((1 - y) * c_height + y * e_height);
@@ -195,7 +212,7 @@ void Collapser::anim()
if(collapsed) {
layout()->addWidget(collapsed);
- collapsed->setFixedHeight(c_height);
+ // collapsed->setFixedHeight(c_height);
collapsed->setVisible(true);
}
@@ -227,16 +244,37 @@ void Collapser::anim()
void Collapser::Placeholder::paintEvent(QPaintEvent *)
{
QPainter p(this);
- p.drawPixmap(rect(), pixmap, pixmap.rect());
+ p.setOpacity(1 - weight);
+ p.drawPixmap(rect(), pixmap_from, pixmap_from.rect());
+ p.setOpacity(weight);
+ p.drawPixmap(rect(), pixmap_to, pixmap_to.rect());
+}
+
+void Collapser::Placeholder::grab_from(QWidget *w)
+{
+ weight = 0; // Reset
+
+ if(!w) return;
+ // w->setFixedWidth(contentsRect().width());
+ QSize sz = w->minimumSizeHint();
+ // w->setFixedHeight(sz.height());
+ w->resize(width(), sz.height());
+ pixmap_from = QPixmap::grabWidget(w, 0, 0);
}
-void Collapser::Placeholder::grab(QWidget *w)
+void Collapser::Placeholder::grab_to(QWidget *w)
{
+ weight = 0; // Reset
+
if(!w) return;
// w->setFixedWidth(contentsRect().width());
QSize sz = w->minimumSizeHint();
// w->setFixedHeight(sz.height());
- DEBUG(collapser, "WIDTH: %d\n", width());
w->resize(width(), sz.height());
- pixmap = QPixmap::grabWidget(w, 0, 0);
+ pixmap_to = QPixmap::grabWidget(w, 0, 0);
+}
+
+void Collapser::Placeholder::setWeight(double w)
+{
+ weight = w * w * w;
}
diff --git a/client/collapser.h b/client/collapser.h
index 2b1ad3c..9702351 100644
--- a/client/collapser.h
+++ b/client/collapser.h
@@ -69,11 +69,19 @@ protected:
private:
class Placeholder : public QWidget {
public:
- QPixmap pixmap;
- void grab(QWidget *w);
+ QPixmap pixmap_from;
+ QPixmap pixmap_to;
+
+ void grab_from(QWidget *w);
+ void grab_to(QWidget *w);
+
+ void setWeight(double weight);
protected:
void paintEvent(QPaintEvent*);
+
+ private:
+ double weight;
};
Placeholder placeholder;
diff --git a/client/macrodrawer.cc b/client/macrodrawer.cc
index a28e7da..f42a3b7 100644
--- a/client/macrodrawer.cc
+++ b/client/macrodrawer.cc
@@ -64,6 +64,10 @@ MacroDrawer::MacroDrawer(Macro *macro, QString title, QWidget *edge)
installEventFilter(this);
connect(button, SIGNAL(clicked()), this, SLOT(toggleMe()));
}
+
+ QMargins m = contentsMargins();
+ m.setLeft(6);
+ setContentsMargins(m);
}
bool MacroDrawer::eventFilter(QObject *obj, QEvent *event)
diff --git a/client/resumewidget.cc b/client/resumewidget.cc
index a017ab7..3b69c0c 100644
--- a/client/resumewidget.cc
+++ b/client/resumewidget.cc
@@ -43,6 +43,8 @@ extern QFont *fixedfont; // Defined in pracro.cc
ResumeWidget::ResumeWidget(bool compact)
{
+ setAutoFillBackground(true);
+
this->compact = compact;
setLayout(new QHBoxLayout());
layout()->setContentsMargins(10,2,2,2);