Skip to content

Commit

Permalink
chore: adjust the animation for menu
Browse files Browse the repository at this point in the history
add the enter transition animation

Log:
  • Loading branch information
FeiWang1119 authored and kegechen committed Aug 8, 2024
1 parent 5c946f9 commit 2be251e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
14 changes: 0 additions & 14 deletions qt6/src/qml/ArrowListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@ FocusScope {
}
interactive: Window.window ? (contentHeight > Window.window.height || model.count > maxVisibleItems) : false
ScrollIndicator.vertical: ScrollIndicator { }
highlight: Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 6
anchors.rightMargin: 6
anchors.topMargin: 6
anchors.bottomMargin: 6
property D.Palette backgroundColor: DS.Style.highlightPanel.background
color: D.ColorSelector.backgroundColor
radius: 6 // TODO can't display background when using dtk's InWindowBlur.
}
highlightFollowsCurrentItem: true
highlightMoveDuration: -1
highlightMoveVelocity: 400
}

P.ArrowListViewButton {
Expand Down
21 changes: 21 additions & 0 deletions qt6/src/qml/Menu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ T.Menu {

onCountChanged: refreshContentItemWidth()
onWidthChanged: refreshContentItemWidth()
view.highlightFollowsCurrentItem: true
view.highlightMoveDuration: 50
view.highlightMoveVelocity: -1

view.highlight: Rectangle {
anchors.left: parent ? parent.left : undefined
anchors.right: parent ? parent.right : undefined
anchors.leftMargin: 6
anchors.rightMargin: 6
scale: 0.9
property D.Palette backgroundColor: DS.Style.highlightPanel.background
color: D.ColorSelector.backgroundColor
radius: 6
Component.onCompleted: {
scale = 1.0
}
Behavior on scale {
NumberAnimation { duration: 100 }
}

}
}
Loader {
Layout.fillWidth: true
Expand Down
3 changes: 3 additions & 0 deletions qt6/src/qml/MenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ T.MenuItem {
text: control.text
font: control.font
color: control.palette.windowText
Behavior on color {
ColorAnimation { duration: control.hovered ? 100 : 0; }
}
icon: D.DTK.makeIcon(control.icon, control.D.DciIcon)
}

Expand Down
1 change: 1 addition & 0 deletions src/private/dquickiconlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ void DQuickIconLabel::setColor(const QColor &color)
d->color = color;
if (d->label)
d->label->setColor(color);
Q_EMIT colorChanged(color);
}

DQuickIconLabel::Display DQuickIconLabel::display() const
Expand Down
5 changes: 4 additions & 1 deletion src/private/dquickiconlabel_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DQuickIconLabel : public QQuickItem
Q_PROPERTY(DTK_QUICK_NAMESPACE::DQuickDciIcon icon READ icon WRITE setIcon FINAL)
Q_PROPERTY(QString text READ text WRITE setText FINAL)
Q_PROPERTY(QFont font READ font WRITE setFont FINAL)
Q_PROPERTY(QColor color READ color WRITE setColor FINAL)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
Q_PROPERTY(Display display READ display WRITE setDisplay FINAL)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing FINAL)
Q_PROPERTY(bool mirrored READ isMirrored WRITE setMirrored FINAL)
Expand Down Expand Up @@ -87,6 +87,9 @@ class DQuickIconLabel : public QQuickItem
void setBottomPadding(qreal padding);
void resetBottomPadding();

Q_SIGNALS:
void colorChanged(const QColor &color);

protected:
void componentComplete() override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Expand Down

0 comments on commit 2be251e

Please sign in to comment.