Show the library edge on the card in limited deck views (#6741) (#6741)

Limited deck views (view top/bottom N cards, scry, surveil) made it
ambiguous which card was the top or bottom of the library. Label the card
itself with a small in-view marker instead of placing text above or below
the whole zone, which became ambiguous once the grid used several columns
or the window was resized.

The marker stays on the part of its card that the column leaves visible:
for a top view, the right end of the exposed strip of the first card; for
a bottom view, the bottom-left corner of the last, fully visible card.

The view logic now answers whether it is a limited library-end view and
which edge it shows. The graphics zone draws and positions a marker on
the first or last displayed card, and re-translates its tooltip with the
rest of the zone view.

Co-authored-by: Lukas Brübach <44814898+BruebachL@users.noreply.github.com>
This commit is contained in:
scotland0208 2026-11-07 10:24:40 -06:00 • committed by GitHub
parent 80986266b9
commit d9cd308a2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 243 additions and 2 deletions

View file

@ -9,9 +9,11 @@
#include "select_zone.h"
#include <QGraphicsItem>
#include <QGraphicsLayoutItem>
#include <QList>
#include <QLoggingCategory>
#include <QPointF>
#include <QRectF>
#include <QSizeF>
#include <QString>
@ -33,6 +35,30 @@ inline Q_LOGGING_CATEGORY(ViewZoneLog, "view_zone");
class Response;
class ServerInfo_Card;
class QGraphicsSceneWheelEvent;
class QPainter;
class QStyleOptionGraphicsItem;
class QWidget;
/**
* A small chip drawn on the card at the edge of a viewed library.
*
* It is a sibling of the card items rather than part of the zone widget, so it
* stays attached to its card when the view reflows into several columns or is
* resized. ZoneViewZone owns and positions it.
*/
class LibraryEdgeMarker : public QGraphicsItem
{
public:
explicit LibraryEdgeMarker(QGraphicsItem *parent = nullptr);
void setLabel(const QString &label, const QString &toolTip);
[[nodiscard]] QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
QRectF markerRect;
QString label;
};
/**
* A CardZone that is a view into another CardZone.
@ -56,6 +82,8 @@ private:
FilterString filterString = FilterString("");
CardList::SortOption groupBy, sortBy;
bool pileView;
LibraryEdgeMarker *libraryEdgeMarker;
QPointF libraryEdgeMarkerAnchorPos;
struct GridSize
{
@ -64,6 +92,9 @@ private:
};
GridSize positionCardsForDisplay(CardList &cards, CardList::SortOption pileOption = CardList::NoSort);
void updateLibraryEdgeMarker(const CardList &displayedCards);
void applyLibraryEdgeMarkerText();
void positionLibraryEdgeMarker();
void
handleDropEvent(const QList<CardDragItem *> &dragItems, CardZoneLogic *startZone, const QPoint &dropPoint) override;
@ -79,6 +110,10 @@ public:
{
return optimumRect;
}
/** @brief Re-applies the translated library edge marker text after a language change. */
void retranslateEdgeMarker();
public slots:
void addToViews();
void removeFromViews();