improve sizing and dynamic width for view
C++ / fmt (pull_request) Successful in 6s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 17s
Python / static (pull_request) Successful in 1m2s
Rust / fmt (pull_request) Successful in 1m5s
C++ / build (pull_request) Successful in 2m36s
Rust / build (pull_request) Successful in 2m27s
Rust / clippy (pull_request) Successful in 1m51s
Python / verify (pull_request) Successful in 3m33s
C++ / clang-tidy (pull_request) Successful in 7m12s
C++ / fmt (pull_request) Successful in 6s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 17s
Python / static (pull_request) Successful in 1m2s
Rust / fmt (pull_request) Successful in 1m5s
C++ / build (pull_request) Successful in 2m36s
Rust / build (pull_request) Successful in 2m27s
Rust / clippy (pull_request) Successful in 1m51s
Python / verify (pull_request) Successful in 3m33s
C++ / clang-tidy (pull_request) Successful in 7m12s
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QEasingCurve>
|
||||
#include <QList>
|
||||
#include <QPointF>
|
||||
#include <QQuickItem>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
#include <QVariantList>
|
||||
#include <QVariantAnimation>
|
||||
#include <QEasingCurve>
|
||||
#include <QElapsedTimer>
|
||||
#include <QPointF>
|
||||
#include <QVariantList>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
|
||||
namespace ZShell::components {
|
||||
|
||||
@@ -112,6 +112,7 @@ class CarouselView : public QQuickItem {
|
||||
|
||||
protected:
|
||||
void geometryChange(const QRectF& newGeo, const QRectF& oldGeo) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||
@@ -125,8 +126,11 @@ class CarouselView : public QQuickItem {
|
||||
struct Arrangement {
|
||||
int n = 0;
|
||||
qreal width = 0;
|
||||
qreal outerSpacing = 0;
|
||||
|
||||
QVector<qreal> sizes;
|
||||
QVector<qreal> centers;
|
||||
|
||||
qreal effectiveExtraWidth = 0;
|
||||
};
|
||||
|
||||
@@ -139,25 +143,36 @@ class CarouselView : public QQuickItem {
|
||||
|
||||
void rebuildArrangement();
|
||||
void relayout();
|
||||
|
||||
Arrangement arrangementForCount(int n) const;
|
||||
|
||||
int layoutCapacityForWidth(qreal width) const;
|
||||
qreal targetWidthForMaxWidth(qreal maxWidth) const;
|
||||
|
||||
void updateSlotContent(Slot& slot, int virtualIndex);
|
||||
|
||||
void positionSlot(const Slot& slot) const;
|
||||
|
||||
void applyPropertiesToItem(QQuickItem* item, int realIndex) const;
|
||||
|
||||
qreal pitch() const { return m_focalWidth + m_itemSpacing; }
|
||||
|
||||
qreal contentXForIndex(qreal index) const;
|
||||
int indexForContentX(qreal x) const;
|
||||
qreal snapTargetX(qreal x) const;
|
||||
|
||||
void snapToNearest();
|
||||
void glideTo(qreal dest);
|
||||
void cancelAnimations();
|
||||
|
||||
qreal keylineCenter(int io) const;
|
||||
qreal keylineSize(int io) const;
|
||||
qreal sampleCenter(qreal childLoc) const;
|
||||
qreal sampleSize(qreal childLoc) const;
|
||||
qreal continuousIndex() const;
|
||||
|
||||
int realIndexOf(int virtualIndex) const;
|
||||
|
||||
void updateCurrentIndexFromContentX(bool emitPreview);
|
||||
|
||||
void wrapContentIfNeeded();
|
||||
void centerInstantlyOnReal(int realIndex);
|
||||
|
||||
@@ -176,12 +191,13 @@ class CarouselView : public QQuickItem {
|
||||
|
||||
Arrangement m_arrangement;
|
||||
|
||||
int m_layoutCapacity = 0;
|
||||
|
||||
qreal m_contentX = 0;
|
||||
int m_currentVirtualIndex = 0;
|
||||
int m_currentRealIndex = -1;
|
||||
int m_previewRealIndex = -1;
|
||||
|
||||
static constexpr int kLoopMultiplier = 401;
|
||||
int m_centerBlockStart = 0;
|
||||
|
||||
QList<Slot> m_slots;
|
||||
@@ -192,16 +208,19 @@ class CarouselView : public QQuickItem {
|
||||
|
||||
bool m_dragging = false;
|
||||
bool m_dragActive = false;
|
||||
|
||||
QPointF m_pressPos;
|
||||
qreal m_pressContentX = 0;
|
||||
|
||||
QElapsedTimer m_dragTimer;
|
||||
qreal m_lastMoveX = 0;
|
||||
qint64 m_lastMoveT = 0;
|
||||
qreal m_velocity = 0;
|
||||
|
||||
QVariantAnimation* m_flickAnim = nullptr;
|
||||
|
||||
bool m_initializedLayout = false;
|
||||
bool m_relayoutQueued = false;
|
||||
};
|
||||
|
||||
}; // namespace ZShell::components
|
||||
} // namespace ZShell::components
|
||||
|
||||
Reference in New Issue
Block a user