Skip to content

Commit

Permalink
Animation for tab close buttons
Browse files Browse the repository at this point in the history
Also, restored dark KvFlat themes.
Also, polished KvBeige and KvBrown.
  • Loading branch information
tsujan committed Nov 14, 2018
1 parent 9f83018 commit 80a7a61
Show file tree
Hide file tree
Showing 12 changed files with 2,737 additions and 137 deletions.
1 change: 1 addition & 0 deletions Kvantum/ChangeLog
Expand Up @@ -28,6 +28,7 @@ V0.10.9
* Show menus of menubar items exactly below them, without a gap.
* Removed text shadow depths > 1 until Qt supports a better way of adding text shadows with QPainter.
* Added a workaround for Qt scroll jump with mouse gestures (as a hacking option in Kvantum Manager).
* Animation for tab close buttons.

V0.10.8
---------
Expand Down
2 changes: 1 addition & 1 deletion Kvantum/NEWS
@@ -1,5 +1,5 @@
Latest version:

13 Nov 2018, V0.10.9
14 Nov 2018, V0.10.9

See "ChangeLog" for changes.
73 changes: 58 additions & 15 deletions Kvantum/style/Kvantum.cpp
Expand Up @@ -4469,31 +4469,24 @@ void Style::drawPrimitive(PrimitiveElement element,
default_frame_spec(fspec);
const indicator_spec dspec = getIndicatorSpec("Tab");

bool pseudoState(false);
QString status;
if (!(option->state & State_Enabled))
status = "disabled";
else if ((option->state & State_Selected) && hasActiveIndicator_)
{
if (option->state & State_Sunken)
{
if (renderIndicator(painter, option->rect, fspec, dspec,
dspec.element+"-close-toggledPressed",
option->direction))
{
break;
}
pseudoState = true;
status = "toggledPressed";
}
else if (option->state & State_MouseOver)
{
if (renderIndicator(painter, option->rect, fspec, dspec,
dspec.element+"-close-toggledFocused" + (isWidgetInactive(widget)
? "-inactive" : QString()),
option->direction))
{
break;
}
pseudoState = true;
status = "toggledFocused";
}
status = "toggled";
else
status = "toggled";
}
else
{
Expand All @@ -4502,7 +4495,57 @@ void Style::drawPrimitive(PrimitiveElement element,
}
if (isWidgetInactive(widget))
status.append("-inactive");
renderIndicator(painter,option->rect,fspec,dspec,dspec.element+"-close-"+status,option->direction);

QObject *styleObject = option->styleObject;
QString animationStartState;
if (styleObject)
animationStartState = styleObject->property("_kv_state").toString();
bool animate(widget && widget->isEnabled() && animatedWidget_ == widget
&& !animationStartState.isEmpty()
&& qobject_cast<const QAbstractButton*>(widget));
if (animate && animationStartState == status)
{
if (opacityTimer_->isActive())
opacityTimer_->stop();
animationOpacity_ = 0;
animate = false;
}

if (animate)
{
if (!opacityTimer_->isActive())
{
animationOpacity_ = 0;
opacityTimer_->start(ANIMATION_FRAME);
}
if (animationOpacity_ < 100)
{
renderIndicator(painter,option->rect,fspec,dspec,
dspec.element+"-close-"+animationStartState,option->direction);
}
painter->save();
painter->setOpacity(static_cast<qreal>(animationOpacity_)/100.0);
}

if (pseudoState)
{
if(!renderIndicator(painter,option->rect,fspec,dspec,dspec.element+"-close-"+status,option->direction))
{ // the "toggledX" pseudo-state doesn't exist
status = "toggled" + (isWidgetInactive(widget) ? "-inactive" : QString());
renderIndicator(painter,option->rect,fspec,dspec,dspec.element+"-close-"+status,option->direction);
}
}
else
renderIndicator(painter,option->rect,fspec,dspec,dspec.element+"-close-"+status,option->direction);

if (animate)
{
painter->restore();
if (animationOpacity_ >= 100)
styleObject->setProperty("_kv_state", status);
}
else if (styleObject)
styleObject->setProperty("_kv_state", status);

break;
}
Expand Down
2 changes: 2 additions & 0 deletions Kvantum/style/polishing.cpp
Expand Up @@ -621,6 +621,7 @@ void Style::polish(QWidget *widget)
&& !qobject_cast<QLineEdit*>(pw)) // exclude line-edit clear buttons
|| qobject_cast<QCheckBox*>(widget)
|| qobject_cast<QRadioButton*>(widget)
|| (qobject_cast<QAbstractButton*>(widget) && qobject_cast<QTabBar*>(pw)) // tab close button
|| widget->inherits("QComboBoxPrivateContainer")))
/* unfortunately, KisSliderSpinBox uses a null widget in drawing
its progressbar, so we can identify it only through eventFilter()
Expand Down Expand Up @@ -1135,6 +1136,7 @@ void Style::unpolish(QWidget *widget)
(qobject_cast<QPushButton*>(widget)
|| qobject_cast<QCheckBox*>(widget)
|| qobject_cast<QRadioButton*>(widget)
|| (qobject_cast<QAbstractButton*>(widget) && qobject_cast<QTabBar*>(widget->parentWidget()))
|| qobject_cast<QScrollBar*>(widget)
|| qobject_cast<QSlider*>(widget)
|| qobject_cast<QLineEdit*>(widget)
Expand Down
105 changes: 105 additions & 0 deletions Kvantum/themes/colors/KvFlat.colors
@@ -0,0 +1,105 @@
[ColorEffects:Disabled]
Color=112,111,110
ColorAmount=0
ColorEffect=0
ContrastAmount=0.65
ContrastEffect=1
IntensityAmount=0.1
IntensityEffect=0

[ColorEffects:Inactive]
ChangeSelectionColor=true
Color=112,111,110
ColorAmount=0.025
ColorEffect=2
ContrastAmount=0.1
ContrastEffect=2
Enable=true
IntensityAmount=0
IntensityEffect=0

[Colors:Button]
BackgroundAlternate=74,74,74
BackgroundNormal=85,85,85
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Selection]
BackgroundAlternate=63,103,165
BackgroundNormal=63,103,165
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Tooltip]
BackgroundAlternate=0,0,0
BackgroundNormal=0,0,0
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=225,225,225
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:View]
BackgroundAlternate=56,56,56
BackgroundNormal=46,46,46
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Window]
BackgroundAlternate=49,49,49
BackgroundNormal=61,61,62
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[General]
ColorScheme=KvFlat
Name=KvFlat
shadeSortColumn=true

[KDE]
contrast=0

[WM]
activeBackground=61,61,62
activeBlend=61,61,62
activeForeground=255,255,255
inactiveBackground=61,61,62
inactiveBlend=61,61,62
inactiveForeground=155,155,155
105 changes: 105 additions & 0 deletions Kvantum/themes/colors/KvFlatRed.colors
@@ -0,0 +1,105 @@
[ColorEffects:Disabled]
Color=112,111,110
ColorAmount=0
ColorEffect=0
ContrastAmount=0.65
ContrastEffect=1
IntensityAmount=0.1
IntensityEffect=0

[ColorEffects:Inactive]
ChangeSelectionColor=true
Color=112,111,110
ColorAmount=0.025
ColorEffect=2
ContrastAmount=0.1
ContrastEffect=2
Enable=true
IntensityAmount=0
IntensityEffect=0

[Colors:Button]
BackgroundAlternate=74,74,74
BackgroundNormal=85,85,85
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Selection]
BackgroundAlternate=162,18,21
BackgroundNormal=162,18,21
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Tooltip]
BackgroundAlternate=0,0,0
BackgroundNormal=0,0,0
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=225,225,225
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:View]
BackgroundAlternate=56,56,56
BackgroundNormal=46,46,46
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[Colors:Window]
BackgroundAlternate=49,49,49
BackgroundNormal=61,61,62
DecorationFocus=170,170,170
DecorationHover=150,150,150
ForegroundActive=255,128,224
ForegroundInactive=160,160,160
ForegroundLink=46,184,230
ForegroundNegative=240,1,1
ForegroundNeutral=255,221,0
ForegroundNormal=255,255,255
ForegroundPositive=128,255,128
ForegroundVisited=255,102,102

[General]
ColorScheme=KvFlatRed
Name=KvFlatRed
shadeSortColumn=true

[KDE]
contrast=0

[WM]
activeBackground=61,61,62
activeBlend=61,61,62
activeForeground=255,255,255
inactiveBackground=61,61,62
inactiveBlend=61,61,62
inactiveForeground=155,155,155

0 comments on commit 80a7a61

Please sign in to comment.