mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-12 07:17:32 +00:00
39be450fa3
Adds a basic carousel view, or essentially a horizontal list a la Android/Qt Quick. Lacks a lot of niceties like autoscroll, smooth shifts, etc. Will work on those later Also fixed a bug introduced recently that capped game icon size to 8 at the low end, breaking the None option Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4112 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Reviewed-by: Lizzie <lizzie@eden-emu.dev>
36 lines
1.0 KiB
C++
36 lines
1.0 KiB
C++
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
/**
|
|
* A stylized "card"-like delegate for the game grid view.
|
|
* Adapted from QML
|
|
*/
|
|
class GameCard : public QStyledItemDelegate {
|
|
Q_OBJECT
|
|
public:
|
|
explicit GameCard(QObject* parent = nullptr);
|
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
const QModelIndex& index) const override;
|
|
|
|
QRect getCardRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
bool hitTest(const QPoint& point, const QModelIndex& index,
|
|
const QWidget* widget, const QRect& cellRect) const;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
|
void setSize(const QSize& newSize, const QSize& contentSize, const int padding, const int columns);
|
|
|
|
private:
|
|
static constexpr int cardMargin = 8;
|
|
|
|
QSize m_size;
|
|
QSize m_contentSize;
|
|
int m_padding;
|
|
int m_columns;
|
|
};
|