mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
[Game] Add hover zoom and a tabbed card panel to the board (#7700)
* [Settings] Add hover zoom/panel triggers, delays, and double-confirm * [Game] Smooth board hover-zoom with fade helpers * [Game] Add hover card panel with tabbed actions * [Game] Wire hover zoom/panel triggers through the scene * [Game] Repaint cached zones when the hover zoom moves `TableZone` cuts the hovered card out of its own paint so zone washes, indicators, dimming and the land divider never draw over the zoom. It is a `DeviceCoordinateCache` item, so the card changing geometry never dirtied it and the stale hole stayed transparent, uncovering the black viewport as soon as the zoom crossed a zone edge. - Emit `hoverFootprintChanged(old, new)` from `setCardScale()` and once from `setHovered(false)`. - Repaint every overlapping `TableZone` on that signal. - Clip with the card's painted outline instead of its bounding rectangle, and treat a zoom covering the whole zone as "paint nothing". * [Interface] Keep the hover panel P/T controls out of the way The P/T set/inc/dec rows were always visible and sat under the cursor, so clicking a card to select it could mutate its P/T instead. - Collapse the controls to a pill on the printed P/T box, anchored on the drawn artwork so letterboxed and sideways cards stay aligned. - Open the rows only from the pill and grow them upward, and re-measure the pill on every value so three-digit P/T does not clip. - Close the panel when another card is hovered, and repaint the area it covered so no patch is left behind. * [Interface] Address hover panel review findings * [Game] Fix include order flagged by the format gate The card hover widget header was included before theme_manager.h, which clang-format rejects; the branch's format CI job failed on it. * [Interface] Load the hover panel icons through the themed icon engine The panel still named pre-#7595 assets (arrow_*_green, arrow_right_blue, cogwheel) and built QIcon snapshots from themePixmap(), so the deleted names rendered blank and every other glyph froze one palette. Load every glyph through loadThemedIcon() with the emphasis axis the adoption plan calls for: the category tabs take the primary level as panel wayfinding, the action grid the quiet level because its glyphs label the button text. Semantic tints keep their family and follow the same quiet level; Clone keeps its sticker treatment. * [Icons] Add an Informational semantic color family Face-down play and the exile zone are states that are neither a gain nor a loss, and the pre-#7595 art painted them blue (arrow_right_blue). #7595 dropped that hue, and the icon engine has had only Positive and Negative since, so both states fall back to neutral ink. Add the family with the same three-level ladder the other semantic roles use: authored roles per theme, scheme defaults otherwise, an emphasis mapping, the palette-editor rows and the generator seed. The defaults clear the 4.5:1 label floor on both schemes and the ladder's saturation ordering; the existing emphasis, hue and preview tests now cover the new family. Preview sheets that name roles resolve an unauthored one through the same default the client paints. * [Interface] Split the hover panel icons by emphasis and semantics Category tabs only navigate between pages, so they take the quiet level; the action grid is the surface the player works in and takes the primary level. Both stay line glyphs: a filled treatment reads as a second state on every cell. Hue marks an outcome where the glyph cannot. Play, clone and to hand are Positive; reduce life and graveyard Negative; play face down and exile Informational. Direction-only moves (top and bottom of library) stay neutral because the arrow already carries the meaning. * [Icons] Add Hidden and Marked semantic color families Two game concepts had no hue of their own. Hidden information (a face-down play, peeking at a card face) now has violet, and the marks a player leaves on a card (annotation, draw arrow) now share amber instead of splitting blue and red for the same job. Both families follow the existing three-level ladder: authored roles per theme, scheme defaults otherwise, an emphasis mapping, palette-editor rows and generator seeding. The defaults clear the 4.5:1 floor on the representative platform surfaces and keep the saturation ordering the emphasis tests assert; the hue tests pin violet's blue-red-green dominance and amber's red-green-blue one, and every preview sheet now renders the two families. The hover panel grid preview is added alongside: it renders the real pages (section headers, two-column cells, glyph over label) so the whole map can be judged at once instead of glyph by glyph. * [Icons] Add a Movement semantic color family A card changing position inside the library is neither a gain, a loss nor information, so it had no hue. Movement names it with teal and covers the three library placements (top, bottom, X from top). It follows the existing ladder: authored roles per theme, scheme defaults otherwise, an emphasis mapping, palette-editor rows and generator seeding. The defaults clear the 4.5:1 floor on the representative platform surfaces, keep strong > base > soft saturation, and keep green > blue > red so teal cannot be mistaken for the green gain family. * [Interface] Give every hover panel action a semantic color The quick actions are the panel's whole point, so a neutral glyph made the most-used buttons the hardest to scan. Every action now names a game fact with its hue: gain, loss, information, hidden information, a mark on the card or a move. The line glyph stays identical, so the colour is the only difference between neighbours. The grid is also ordered by family so a row reads as one idea: the two state toggles, the two gains, the two marks, the two hidden-information actions and the two losses each share a row. Conditional actions (Peek, Unattach) sit at the end of their pair, so a missing one leaves a hole at the section edge instead of splitting a row. In a zone, Play and Play Face Down stay adjacent on purpose: the same action, one of them hiding information. The move tab leads with the three library placements (Movement), then the destinations. actionGridIcon is removed; semanticActionIcon is now the only grid ink. The preview renders the real pages so the whole map can be judged at once. * [Icons] Use quiet emphasis for glyphs that label rather than act The search and info glyphs inside the search fields, and the combo-box chevron, label or afford an action rather than performing one. At the default secondary weight they compete with the actual controls next to them. Paint them at quiet emphasis so they stay legible without claiming attention. Sites: deck editor, visual database display, visual deck storage, set manager, settings search, in-game zone view, and the dropdown chevron. * [Icons] Restore sticker treatment to the add, remove and delete actions The pre-#7595 add and delete glyphs were filled shapes with an outline. After the line migration they read as ordinary toolbar glyphs, losing the weight their verbs had. Give the add and delete family the sticker treatment again. - Deck editor Add card: primary positive sticker. It is the one action the database panel exists for. - Visual database Clear filters: negative sticker, matching the delete family. - Filter dock Clear all: negative sticker, matching Clear one. * [Icons] Give sharing and pinning their semantic families Sharing is an informational act: the app already tints reveal and make-public with the informational family, so the deck storage share action, the replay share-code action and the visual deck storage share button follow it. The printing-selector pin badge marks a card as pinned. Paint it with the marked family, the same one used for a mark left on a card, instead of leaving it neutral. * [Game] Dismiss the hover panel before opening a modal dialog The hover panel is a Qt::ToolTip window, i.e. a popup: it is always on top and holds the input grab. Actions on the panel that open a modal dialog (Set power/toughness, Set annotation, Set counter value, token creation) therefore opened the dialog behind the panel, where it could not be seen or activated. Hide the panel synchronously and defer the action to the next event-loop turn, so the popup grab is released before the dialog's event loop starts. The panel asks the scene to dismiss it through a new dismissRequested signal, keeping hover timers and the covered-card fade on the scene's side. Reported from the P/T overlay SET button; the same path covers the counter tab and the token tab. * [Icons] Refine VDE and VDD emphasis and semantics The visual database filter section and the syntax help are information aids, so paint them with the informational family at the default emphasis: the filter section glyph and the search field's help glyph. The help glyph leaves quiet emphasis because it is a clickable action, not a field label. The visual deck editor's display-type toggle is the one control that changes the whole view, so it takes primary emphasis. The search glyphs stay quiet; only the help action changes. * [Icons] Raise the visual database filter controls to primary The six quick-filter buttons are the controls the filter section exists for, so paint them at primary emphasis instead of the default weight. The sort glyph carries the same informational family as the filter glyph, in both the visual database toolbar label and the visual deck editor's sort-criteria button. * [Icons] Keep the display options sort glyph neutral The sort button beside the display-mode toggle is not part of the informational family. Only the visual database toolbar's sort glyph carries informational; the display options button returns to the default neutral weight. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
6138fbd0a0
commit
b1c8f156dc
46 changed files with 3796 additions and 76 deletions
|
|
@ -172,6 +172,7 @@ set(cockatrice_SOURCES
|
||||||
src/interface/widgets/cards/card_group_display_widgets/card_group_display_widget.cpp
|
src/interface/widgets/cards/card_group_display_widgets/card_group_display_widget.cpp
|
||||||
src/interface/widgets/cards/card_group_display_widgets/flat_card_group_display_widget.cpp
|
src/interface/widgets/cards/card_group_display_widgets/flat_card_group_display_widget.cpp
|
||||||
src/interface/widgets/cards/card_group_display_widgets/overlapped_card_group_display_widget.cpp
|
src/interface/widgets/cards/card_group_display_widgets/overlapped_card_group_display_widget.cpp
|
||||||
|
src/interface/widgets/cards/card_hover_widget.cpp
|
||||||
src/interface/widgets/cards/card_info_display_widget.cpp
|
src/interface/widgets/cards/card_info_display_widget.cpp
|
||||||
src/interface/widgets/cards/card_info_frame_widget.cpp
|
src/interface/widgets/cards/card_info_frame_widget.cpp
|
||||||
src/interface/widgets/cards/card_info_picture_art_crop_widget.cpp
|
src/interface/widgets/cards/card_info_picture_art_crop_widget.cpp
|
||||||
|
|
|
||||||
|
|
@ -569,6 +569,9 @@ private:
|
||||||
{"Player/aRevealToAll", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Reveal Selected Cards to All Players"),
|
{"Player/aRevealToAll", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Reveal Selected Cards to All Players"),
|
||||||
parseSequenceString(""),
|
parseSequenceString(""),
|
||||||
ShortcutGroup::Playing_Area)},
|
ShortcutGroup::Playing_Area)},
|
||||||
|
{"Player/aShowHoverPanel", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Show Hover Panel for Card"),
|
||||||
|
parseSequenceString(""),
|
||||||
|
ShortcutGroup::Playing_Area)},
|
||||||
{"Player/aMoveToBottomLibrary", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Bottom of Library"),
|
{"Player/aMoveToBottomLibrary", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Bottom of Library"),
|
||||||
parseSequenceString("Ctrl+B"),
|
parseSequenceString("Ctrl+B"),
|
||||||
ShortcutGroup::Move_selected)},
|
ShortcutGroup::Move_selected)},
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "libcockatrice/card/printing/exact_card.h"
|
#include "libcockatrice/card/printing/exact_card.h"
|
||||||
#include "libcockatrice/utility/card_ref.h"
|
#include "libcockatrice/utility/card_ref.h"
|
||||||
|
|
||||||
|
#include <QAbstractAnimation>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QGraphicsView>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
@ -29,6 +31,7 @@
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
|
@ -42,9 +45,19 @@
|
||||||
|
|
||||||
class QSizeF;
|
class QSizeF;
|
||||||
|
|
||||||
|
// Width the hovered card smooth-zooms to: exactly the hover panel picture size, so
|
||||||
|
// all four corners coincide when the panel swaps in over it.
|
||||||
|
static constexpr qreal HOVER_ZOOM_WIDTH = 270.0;
|
||||||
|
// The pre-panel hover enlargement. The smooth zoom is opt-in, so this stays the hover
|
||||||
|
// behavior whenever no zoom trigger is configured (see setHoverHighlighted).
|
||||||
|
static constexpr qreal LEGACY_HOVER_SCALE = 1.1;
|
||||||
|
static constexpr int HOVER_ZOOM_IN_MS = 220;
|
||||||
|
static constexpr int HOVER_ZOOM_OUT_MS = 140;
|
||||||
|
static constexpr int FADE_DURATION_MS = 140;
|
||||||
|
|
||||||
AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef, PlayerLogic *_owner, int _id)
|
AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef, PlayerLogic *_owner, int _id)
|
||||||
: ArrowTarget(_owner, parent), state(new CardState(this, nullptr, cardRef, _id)), tapAngle(0),
|
: ArrowTarget(_owner, parent), state(new CardState(this, nullptr, cardRef, _id)), tapAngle(0),
|
||||||
bgColor(Qt::transparent), isHovered(false), realZValue(0)
|
bgColor(Qt::transparent), isHovered(false), isHoverHighlighted(false), realZValue(0)
|
||||||
{
|
{
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
|
|
@ -54,12 +67,38 @@ AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef
|
||||||
connect(state, &CardState::cardInfoChanged, this, &AbstractCardItem::onCardInfoChanged);
|
connect(state, &CardState::cardInfoChanged, this, &AbstractCardItem::onCardInfoChanged);
|
||||||
connect(state, &CardState::cardRefChanged, this, &AbstractCardItem::onCardRefChanged);
|
connect(state, &CardState::cardRefChanged, this, &AbstractCardItem::onCardRefChanged);
|
||||||
connect(state, &CardState::tappedChanged, this, &AbstractCardItem::onTappedChanged);
|
connect(state, &CardState::tappedChanged, this, &AbstractCardItem::onTappedChanged);
|
||||||
connect(state, &CardState::facedownChanged, this, [this] { update(); });
|
connect(state, &CardState::facedownChanged, this, [this](bool faceDown) {
|
||||||
|
update();
|
||||||
|
emit faceDownChanged(faceDown);
|
||||||
|
});
|
||||||
connect(state, &CardState::colorChanged, this, [this] {
|
connect(state, &CardState::colorChanged, this, [this] {
|
||||||
cacheBgColor();
|
cacheBgColor();
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hoverZoom = new QPropertyAnimation(this, "cardScale", this);
|
||||||
|
hoverZoom->setEasingCurve(QEasingCurve::InOutCubic);
|
||||||
|
// Settling the unhover waits for the shrink-out to finish: the stacking override,
|
||||||
|
// the clip escape and the ancestor lift all stay put while the card is still large,
|
||||||
|
// so siblings and the clip container cannot cut through the shrinking card.
|
||||||
|
connect(hoverZoom, &QPropertyAnimation::finished, this, [this] {
|
||||||
|
if (!isHovered) {
|
||||||
|
// The cursor may still rest on the card (e.g. wheel-up reverts the zoom),
|
||||||
|
// in which case the highlight keeps it raised.
|
||||||
|
setZValue(isHoverHighlighted ? ZValues::HOVERED_CARD : realZValue);
|
||||||
|
// Final repaint at the settled footprint: with no scale delta the animation
|
||||||
|
// emits no per-frame updates, and zones would keep a stale clip hole behind.
|
||||||
|
if (scene()) {
|
||||||
|
scene()->update(sceneBoundingRect());
|
||||||
|
}
|
||||||
|
emit hoverShrinkFinished(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
opacityAnim = new QPropertyAnimation(this, "cardOpacity", this);
|
||||||
|
opacityAnim->setDuration(FADE_DURATION_MS);
|
||||||
|
opacityAnim->setEasingCurve(QEasingCurve::OutCubic);
|
||||||
|
|
||||||
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::displayCardNamesChanged, this,
|
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::displayCardNamesChanged, this,
|
||||||
[this] { update(); });
|
[this] { update(); });
|
||||||
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::cardLangChanged, this,
|
connect(&SettingsCache::instance().cardsDisplay(), &CardsDisplaySettings::cardLangChanged, this,
|
||||||
|
|
@ -131,7 +170,7 @@ void AbstractCardItem::setRealZValue(qreal _zValue)
|
||||||
// During hover, zValue is overridden to HOVERED_CARD. Layout operations
|
// During hover, zValue is overridden to HOVERED_CARD. Layout operations
|
||||||
// like reorganizeCards() call setRealZValue() on all cards including the
|
// like reorganizeCards() call setRealZValue() on all cards including the
|
||||||
// hovered one — skip setZValue() here to avoid clobbering the override.
|
// hovered one — skip setZValue() here to avoid clobbering the override.
|
||||||
if (!isHovered) {
|
if (!isHovered && !isHoverHighlighted) {
|
||||||
setZValue(_zValue);
|
setZValue(_zValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -229,9 +268,9 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
if (isSelected() || isHovered) {
|
if (isSelected() || isHovered || isHoverHighlighted) {
|
||||||
QPen pen;
|
QPen pen;
|
||||||
if (isHovered) {
|
if (isHovered || isHoverHighlighted) {
|
||||||
pen.setColor(Qt::yellow);
|
pen.setColor(Qt::yellow);
|
||||||
}
|
}
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
|
|
@ -257,14 +296,88 @@ void AbstractCardItem::setHovered(bool _hovered)
|
||||||
// Mark the hovered card's current scene footprint dirty so overlapped
|
// Mark the hovered card's current scene footprint dirty so overlapped
|
||||||
// sibling zones (e.g. StackZone) repaint after the card moves away.
|
// sibling zones (e.g. StackZone) repaint after the card moves away.
|
||||||
if (scene()) {
|
if (scene()) {
|
||||||
scene()->update(sceneBoundingRect());
|
const QRectF footprint = sceneBoundingRect();
|
||||||
|
scene()->update(footprint);
|
||||||
|
// The hole disappears the moment the card is no longer hovered, even though the
|
||||||
|
// card has not changed size yet: tell the zones so they repaint it shut.
|
||||||
|
emit hoverFootprintChanged(footprint, footprint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isHovered = _hovered;
|
isHovered = _hovered;
|
||||||
setZValue(_hovered ? ZValues::HOVERED_CARD : realZValue);
|
// The stacking override is one-directional: it applies the moment the hover starts
|
||||||
setScale(_hovered && SettingsCache::instance().cardsDisplay().getScaleCards() ? 1.1 : 1);
|
// and only drops once the shrink-out finishes (see the hoverZoom finished handler).
|
||||||
setTransformOriginPoint(_hovered ? CardDimensions::WIDTH_HALF_F : 0, _hovered ? CardDimensions::HEIGHT_HALF_F : 0);
|
// Restoring it here would let siblings paint over the still-enlarged card.
|
||||||
|
if (_hovered) {
|
||||||
|
setZValue(ZValues::HOVERED_CARD);
|
||||||
|
}
|
||||||
|
// Scale about the center in both directions: at scale 1 the origin is moot,
|
||||||
|
// and keeping it centered avoids drift while shrinking back down.
|
||||||
|
setTransformOriginPoint(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F);
|
||||||
|
|
||||||
|
// Smooth-zoom up to the hover picture size (instead of the old 1.1 snap) so the
|
||||||
|
// hover panel can then swap in over the zoomed card with matching corners.
|
||||||
|
// The target is constant ON-SCREEN pixels: divide out the board view zoom so
|
||||||
|
// fullscreen (or zoomed) boards don't overshoot while the fixed-size panel matches.
|
||||||
|
qreal target = 1.0;
|
||||||
|
if (_hovered && SettingsCache::instance().cardsDisplay().getScaleCards()) {
|
||||||
|
const qreal w = boundingRect().width();
|
||||||
|
qreal viewScale = 1.0;
|
||||||
|
if (scene() && !scene()->views().isEmpty()) {
|
||||||
|
if (const auto *view = scene()->views().first()) {
|
||||||
|
viewScale = qAbs(view->transform().m11());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (w > 0.0 && viewScale > 0.0) {
|
||||||
|
target = qBound(1.0, HOVER_ZOOM_WIDTH / (w * viewScale), 6.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hoverZoom->stop();
|
||||||
|
hoverZoom->setStartValue(scale());
|
||||||
|
hoverZoom->setEndValue(target);
|
||||||
|
hoverZoom->setDuration(_hovered ? HOVER_ZOOM_IN_MS : HOVER_ZOOM_OUT_MS);
|
||||||
|
hoverZoom->start();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::setHoverHighlighted(bool highlighted)
|
||||||
|
{
|
||||||
|
if (isHoverHighlighted == highlighted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (highlighted) {
|
||||||
|
// The card-info widget listens for this: hovering still updates it right away.
|
||||||
|
processHoverEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
isHoverHighlighted = highlighted;
|
||||||
|
if (highlighted) {
|
||||||
|
setZValue(ZValues::HOVERED_CARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to the historical hover scale: the smooth hover zoom is opt-in and its
|
||||||
|
// trigger defaults to Off, so when hovering drives neither the zoom nor the panel
|
||||||
|
// (zoom trigger Off, panel not on hover) contact alone must still enlarge the card
|
||||||
|
// to the old 1.1x while scaleCards is on. Otherwise every existing user silently
|
||||||
|
// loses the hover enlargement on upgrade.
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const bool legacyHoverScale = display.getScaleCards() &&
|
||||||
|
display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerOff &&
|
||||||
|
display.getHoverPanelTrigger() != CardsDisplaySettings::HoverPanelTriggerHover;
|
||||||
|
if (legacyHoverScale) {
|
||||||
|
// Centered like the smooth zoom, so growing and shrinking never drift.
|
||||||
|
setTransformOriginPoint(CardDimensions::WIDTH_HALF_F, CardDimensions::HEIGHT_HALF_F);
|
||||||
|
hoverZoom->stop();
|
||||||
|
hoverZoom->setStartValue(scale());
|
||||||
|
hoverZoom->setEndValue(highlighted ? LEGACY_HOVER_SCALE : 1.0);
|
||||||
|
hoverZoom->setDuration(highlighted ? HOVER_ZOOM_IN_MS : HOVER_ZOOM_OUT_MS);
|
||||||
|
hoverZoom->start();
|
||||||
|
} else if (!highlighted && !isHovered && hoverZoom->state() != QAbstractAnimation::Running) {
|
||||||
|
// A zoomed card keeps its raised z until the shrink-out finishes (its finished
|
||||||
|
// handler restores it); a highlight-only card has nothing to unwind.
|
||||||
|
setZValue(realZValue);
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,6 +386,64 @@ void AbstractCardItem::setColor(const QString &_color)
|
||||||
state->setColor(_color);
|
state->setColor(_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal AbstractCardItem::getCardScale() const
|
||||||
|
{
|
||||||
|
return scale();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::setCardScale(qreal _scale)
|
||||||
|
{
|
||||||
|
if (qFuzzyCompare(_scale, scale())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The scale animates every frame: keep the scene index in step or hover
|
||||||
|
// picking tests a stale rect and the hover oscillates on/off by itself.
|
||||||
|
// Repaint the union of the old and new footprints, not just the card: zones
|
||||||
|
// dodge the zoomed card via a clip hole computed at paint time, and without
|
||||||
|
// a repaint they keep a stale hole — covering the card mid-animation and
|
||||||
|
// leaving a black rect behind once the hover ends.
|
||||||
|
const QRectF oldFootprint = sceneBoundingRect();
|
||||||
|
prepareGeometryChange();
|
||||||
|
setScale(_scale);
|
||||||
|
const QRectF newFootprint = sceneBoundingRect();
|
||||||
|
if (scene()) {
|
||||||
|
scene()->update(oldFootprint.united(newFootprint));
|
||||||
|
// Marking the scene region dirty is not enough for cached items: a zone that cuts a
|
||||||
|
// hover hole out of itself keeps the hole from its last repaint, which then shows as
|
||||||
|
// an uncovered black rectangle under the zoom.
|
||||||
|
emit hoverFootprintChanged(oldFootprint, newFootprint);
|
||||||
|
} else {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal AbstractCardItem::getCardOpacity() const
|
||||||
|
{
|
||||||
|
return opacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::setCardOpacity(qreal _opacity)
|
||||||
|
{
|
||||||
|
setOpacity(_opacity);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::fadeCardOut()
|
||||||
|
{
|
||||||
|
opacityAnim->stop();
|
||||||
|
opacityAnim->setStartValue(opacity());
|
||||||
|
opacityAnim->setEndValue(0.0);
|
||||||
|
opacityAnim->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::fadeCardIn()
|
||||||
|
{
|
||||||
|
opacityAnim->stop();
|
||||||
|
opacityAnim->setStartValue(opacity());
|
||||||
|
opacityAnim->setEndValue(1.0);
|
||||||
|
opacityAnim->start();
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractCardItem::cacheBgColor()
|
void AbstractCardItem::cacheBgColor()
|
||||||
{
|
{
|
||||||
QChar colorChar;
|
QChar colorChar;
|
||||||
|
|
@ -310,6 +481,7 @@ void AbstractCardItem::cacheBgColor()
|
||||||
|
|
||||||
void AbstractCardItem::onTappedChanged(bool newTapped, bool canAnimate)
|
void AbstractCardItem::onTappedChanged(bool newTapped, bool canAnimate)
|
||||||
{
|
{
|
||||||
|
emit tappedChanged(newTapped);
|
||||||
if (SettingsCache::instance().cardsDisplay().getTapAnimation() && canAnimate) {
|
if (SettingsCache::instance().cardsDisplay().getTapAnimation() && canAnimate) {
|
||||||
static_cast<GameScene *>(scene())->registerAnimationItem(this);
|
static_cast<GameScene *>(scene())->registerAnimationItem(this);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,13 @@ class PlayerLogic;
|
||||||
class CardInfo;
|
class CardInfo;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QPoint;
|
class QPoint;
|
||||||
|
class QPropertyAnimation;
|
||||||
|
|
||||||
class AbstractCardItem : public ArrowTarget, public IAnimatedItem
|
class AbstractCardItem : public ArrowTarget, public IAnimatedItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(qreal cardScale READ getCardScale WRITE setCardScale)
|
||||||
|
Q_PROPERTY(qreal cardOpacity READ getCardOpacity WRITE setCardOpacity)
|
||||||
protected:
|
protected:
|
||||||
CardState *state;
|
CardState *state;
|
||||||
int tapAngle;
|
int tapAngle;
|
||||||
|
|
@ -34,9 +37,12 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isHovered;
|
bool isHovered;
|
||||||
|
bool isHoverHighlighted;
|
||||||
qreal realZValue;
|
qreal realZValue;
|
||||||
bool pendingSelectionCollapse;
|
bool pendingSelectionCollapse;
|
||||||
int selectionCollapseGeneration = 0; ///< Guards the deferred collapse timer against stale firings
|
int selectionCollapseGeneration = 0; ///< Guards the deferred collapse timer against stale firings
|
||||||
|
QPropertyAnimation *hoverZoom = nullptr;
|
||||||
|
QPropertyAnimation *opacityAnim = nullptr;
|
||||||
private slots:
|
private slots:
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
void onCardInfoChanged();
|
void onCardInfoChanged();
|
||||||
|
|
@ -57,6 +63,19 @@ signals:
|
||||||
void playSelectedFaceDown(AbstractCardItem *card);
|
void playSelectedFaceDown(AbstractCardItem *card);
|
||||||
void hideSelected(AbstractCardItem *card);
|
void hideSelected(AbstractCardItem *card);
|
||||||
void selectionChanged(AbstractCardItem *card, bool selected);
|
void selectionChanged(AbstractCardItem *card, bool selected);
|
||||||
|
void tappedChanged(bool tapped);
|
||||||
|
void faceDownChanged(bool faceDown);
|
||||||
|
/** @brief Emitted when the hover shrink-out animation runs to completion while unhovered. */
|
||||||
|
void hoverShrinkFinished(AbstractCardItem *card);
|
||||||
|
/**
|
||||||
|
* @brief Emitted when the hover zoom changes this card's scene footprint.
|
||||||
|
*
|
||||||
|
* Zones (and anything else that dodges the zoomed card) draw from the live footprint at
|
||||||
|
* paint time but are cached: they need this to invalidate, or a stale hole is left behind.
|
||||||
|
* Also emitted once when the hover ends, with both rects equal, because the hole
|
||||||
|
* disappears without the card changing size.
|
||||||
|
*/
|
||||||
|
void hoverFootprintChanged(const QRectF &oldFootprint, const QRectF &newFootprint);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
|
|
@ -116,6 +135,23 @@ public:
|
||||||
}
|
}
|
||||||
void setRealZValue(qreal _zValue);
|
void setRealZValue(qreal _zValue);
|
||||||
void setHovered(bool _hovered);
|
void setHovered(bool _hovered);
|
||||||
|
/**
|
||||||
|
* @brief Shows the hover outline and stacking lift, plus the historical 1.1x hover
|
||||||
|
* scale whenever no zoom trigger is configured.
|
||||||
|
*
|
||||||
|
* The board zoom is trigger-gated; the hover feedback (card info, outline, raised
|
||||||
|
* stacking) still follows the cursor immediately on contact. With the zoom trigger
|
||||||
|
* off and the panel not on hover, the old 1.1x enlargement (gated by scaleCards)
|
||||||
|
* stays in effect so upgrading does not silently drop it.
|
||||||
|
*/
|
||||||
|
void setHoverHighlighted(bool highlighted);
|
||||||
|
qreal getCardScale() const;
|
||||||
|
void setCardScale(qreal scale);
|
||||||
|
qreal getCardOpacity() const;
|
||||||
|
void setCardOpacity(qreal opacity);
|
||||||
|
/** @brief Fades the card out under the hover panel, or back in when it closes. */
|
||||||
|
void fadeCardOut();
|
||||||
|
void fadeCardIn();
|
||||||
bool getIsHovered() const
|
bool getIsHovered() const
|
||||||
{
|
{
|
||||||
return isHovered;
|
return isHovered;
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,11 @@ void CardItem::deleteLater()
|
||||||
void CardItem::setZone(CardZoneLogic *_zone)
|
void CardItem::setZone(CardZoneLogic *_zone)
|
||||||
{
|
{
|
||||||
state->setZone(_zone);
|
state->setZone(_zone);
|
||||||
|
// A card faded out under the open hover panel must come back as soon as it changes
|
||||||
|
// zones; otherwise it stays invisible at its destination until the panel closes.
|
||||||
|
if (opacity() < 1.0) {
|
||||||
|
fadeCardIn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardItem::retranslateUi()
|
void CardItem::retranslateUi()
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "../client/settings/cache_settings.h"
|
#include "../client/settings/cache_settings.h"
|
||||||
#include "../interface/theme_manager.h"
|
#include "../interface/theme_manager.h"
|
||||||
|
#include "../interface/widgets/cards/card_hover_widget.h"
|
||||||
#include "animated_item.h"
|
#include "animated_item.h"
|
||||||
#include "board/abstract_card_item.h"
|
#include "board/abstract_card_item.h"
|
||||||
#include "board/arrow_item.h"
|
#include "board/arrow_item.h"
|
||||||
|
|
@ -11,16 +12,21 @@
|
||||||
#include "player/menu/player_menu.h"
|
#include "player/menu/player_menu.h"
|
||||||
#include "player/player_graphics_item.h"
|
#include "player/player_graphics_item.h"
|
||||||
#include "player/player_target.h"
|
#include "player/player_target.h"
|
||||||
|
#include "z_values.h"
|
||||||
#include "zones/card_zone.h"
|
#include "zones/card_zone.h"
|
||||||
#include "zones/select_zone.h"
|
#include "zones/select_zone.h"
|
||||||
|
#include "zones/table_zone.h"
|
||||||
#include "zones/view_zone.h"
|
#include "zones/view_zone.h"
|
||||||
#include "zones/view_zone_widget.h"
|
#include "zones/view_zone_widget.h"
|
||||||
|
|
||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
|
#include <QCursor>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QGraphicsObject>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QGraphicsSceneWheelEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QListIterator>
|
#include <QListIterator>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
@ -29,9 +35,11 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QtMath>
|
#include <QTimer>
|
||||||
|
#include <QtGlobal>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <libcockatrice/game/abstract_game.h>
|
#include <libcockatrice/game/abstract_game.h>
|
||||||
|
|
@ -43,6 +51,7 @@
|
||||||
#include <libcockatrice/game/player/player_logic.h>
|
#include <libcockatrice/game/player/player_logic.h>
|
||||||
#include <libcockatrice/game/zones/card_zone_logic.h>
|
#include <libcockatrice/game/zones/card_zone_logic.h>
|
||||||
#include <libcockatrice/game/zones/view_zone_logic.h>
|
#include <libcockatrice/game/zones/view_zone_logic.h>
|
||||||
|
#include <libcockatrice/settings/cards_display_settings.h>
|
||||||
#include <libcockatrice/settings/interface_settings.h>
|
#include <libcockatrice/settings/interface_settings.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
@ -75,6 +84,22 @@ GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Card hover popup (cardHoverWidget is created lazily on first show)
|
||||||
|
hoverActivateTimer = new QTimer(this);
|
||||||
|
hoverActivateTimer->setSingleShot(true);
|
||||||
|
hoverActivateTimer->setInterval(500);
|
||||||
|
connect(hoverActivateTimer, &QTimer::timeout, this, &GameScene::onHoverActivateTimeout);
|
||||||
|
|
||||||
|
hoverPanelTimer = new QTimer(this);
|
||||||
|
hoverPanelTimer->setSingleShot(true);
|
||||||
|
hoverPanelTimer->setInterval(200);
|
||||||
|
connect(hoverPanelTimer, &QTimer::timeout, this, &GameScene::onHoverPanelTimeout);
|
||||||
|
|
||||||
|
hoverGraceTimer = new QTimer(this);
|
||||||
|
hoverGraceTimer->setSingleShot(true);
|
||||||
|
hoverGraceTimer->setInterval(200);
|
||||||
|
connect(hoverGraceTimer, &QTimer::timeout, this, &GameScene::onHoverGraceTimeout);
|
||||||
|
|
||||||
rearrange();
|
rearrange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +118,9 @@ GameScene::~GameScene()
|
||||||
|
|
||||||
delete animationTimer;
|
delete animationTimer;
|
||||||
animationTimer = nullptr;
|
animationTimer = nullptr;
|
||||||
|
delete hoverActivateTimer;
|
||||||
|
delete hoverPanelTimer;
|
||||||
|
delete hoverGraceTimer;
|
||||||
|
|
||||||
// Delete all ArrowItems before QGraphicsScene's base destructor runs.
|
// Delete all ArrowItems before QGraphicsScene's base destructor runs.
|
||||||
// QGraphicsScene::~QGraphicsScene() destroys items in arbitrary order.
|
// QGraphicsScene::~QGraphicsScene() destroys items in arbitrary order.
|
||||||
|
|
@ -239,6 +267,23 @@ void GameScene::onCardRightClicked(AbstractCardItem *abstractCard, QPoint screen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The zoom and panel triggers are independently bindable: a right-click fires
|
||||||
|
// whichever phases listen to it. When the panel is the trigger it carries every
|
||||||
|
// action itself, so the context menu stays suppressed; when right-click only zooms,
|
||||||
|
// the menu still opens, since nothing else would summon it.
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const bool zoomFired = display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerRightClick;
|
||||||
|
const bool panelFired = display.getHoverPanelTrigger() == CardsDisplaySettings::HoverPanelTriggerRightClick;
|
||||||
|
if (zoomFired || panelFired) {
|
||||||
|
fireTriggers(card, zoomFired, panelFired);
|
||||||
|
if (panelFired) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide the hover popup when the context menu opens
|
||||||
|
hideCardHoverPopup();
|
||||||
|
|
||||||
setActiveCard(card);
|
setActiveCard(card);
|
||||||
|
|
||||||
if (auto *menu = view->getPlayerMenu()->updateCardMenu(card->getState())) {
|
if (auto *menu = view->getPlayerMenu()->updateCardMenu(card->getState())) {
|
||||||
|
|
@ -690,7 +735,6 @@ void GameScene::requestArrowDeletion(int playerId, int arrowId)
|
||||||
emit arrowDeletionRequested(playerId, arrowId);
|
emit arrowDeletionRequested(playerId, arrowId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::onCardZoneChanged(CardState *card, bool sameZone)
|
void GameScene::onCardZoneChanged(CardState *card, bool sameZone)
|
||||||
{
|
{
|
||||||
auto *item = qobject_cast<CardItem *>(card->parent());
|
auto *item = qobject_cast<CardItem *>(card->parent());
|
||||||
|
|
@ -710,6 +754,11 @@ void GameScene::onCardZoneChanged(CardState *card, bool sameZone)
|
||||||
for (auto *arrow : toDelete) {
|
for (auto *arrow : toDelete) {
|
||||||
deleteArrow(arrow->getCreatorId(), arrow->getId());
|
deleteArrow(arrow->getCreatorId(), arrow->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The hover panel stays open on a moved card: follow it instead of stranding.
|
||||||
|
if (!sameZone && cardHoverWidget && cardHoverWidget->getCardItem() == item) {
|
||||||
|
positionCardHoverPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::onCardViewRefreshRequested(CardState *card, bool zoneChanged, PlayerLogic *newOwner)
|
void GameScene::onCardViewRefreshRequested(CardState *card, bool zoneChanged, PlayerLogic *newOwner)
|
||||||
|
|
@ -746,27 +795,137 @@ void GameScene::clearArrowsForPlayerLocally(int playerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- Hover Handling ----------
|
// ---------- Hover Handling ----------
|
||||||
|
|
||||||
|
CardItem *GameScene::getHoveredCard() const
|
||||||
|
{
|
||||||
|
return hoveredCard;
|
||||||
|
}
|
||||||
|
|
||||||
void GameScene::updateHover(const QPointF &scenePos)
|
void GameScene::updateHover(const QPointF &scenePos)
|
||||||
{
|
{
|
||||||
auto itemList = items(scenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder, getViewTransform());
|
updateHoveredCard(pickCardAt(scenePos));
|
||||||
|
}
|
||||||
|
|
||||||
|
CardItem *GameScene::pickCardAt(const QPointF &scenePos)
|
||||||
|
{
|
||||||
|
auto itemList = items(scenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder, getViewTransform());
|
||||||
CardZone *zone = findTopmostZone(itemList);
|
CardZone *zone = findTopmostZone(itemList);
|
||||||
CardItem *topCard = zone ? findTopmostCardInZone(itemList, zone) : nullptr;
|
CardItem *topCard = zone ? findTopmostCardInZone(itemList, zone) : nullptr;
|
||||||
updateHoveredCard(topCard);
|
if (!topCard && hoveredCard) {
|
||||||
|
const QRectF guard = hoveredCard->sceneBoundingRect().adjusted(-8, -8, 8, 8);
|
||||||
|
if (guard.contains(scenePos)) {
|
||||||
|
// The zoomed card overflows onto neighboring zones, where naive topmost-zone
|
||||||
|
// picking attributes the cursor to the zone underneath. While the cursor is
|
||||||
|
// still over the zoomed footprint (with hysteresis for edge jiggle), keep it.
|
||||||
|
// A genuinely different topmost card still takes over.
|
||||||
|
return hoveredCard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return topCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::updateHoveredCard(CardItem *newCard)
|
void GameScene::updateHoveredCard(CardItem *newCard)
|
||||||
{
|
{
|
||||||
|
// Safety: if the popup's card was destroyed, hide the popup immediately
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && !cardHoverWidget->hasCard()) {
|
||||||
|
hideCardHoverPopup();
|
||||||
|
}
|
||||||
|
// The hovered card may have been destroyed without ending the hover: its QPointer
|
||||||
|
// nulled itself, but the ancestor lift is still outstanding. Restore it now.
|
||||||
|
if (!hoveredCard && !hoverLiftedAncestors.isEmpty()) {
|
||||||
|
restoreHoverLift();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hovering alone never starts anything anymore: the trigger (dwell, click, wheel,
|
||||||
|
// shortcut) resolves first, then the zoom follows. This keeps the feature calm.
|
||||||
|
bool wasHoveringCard = (hoveredCard != nullptr);
|
||||||
if (hoveredCard && (newCard != hoveredCard)) {
|
if (hoveredCard && (newCard != hoveredCard)) {
|
||||||
endCardHover(hoveredCard);
|
endCardHover(hoveredCard);
|
||||||
|
hoveredCard = nullptr;
|
||||||
}
|
}
|
||||||
if (newCard && (newCard != hoveredCard)) {
|
|
||||||
|
// The hover outline and the card info follow the cursor on contact: only the board
|
||||||
|
// zoom and the panel wait for their trigger. A highlight-only card has no zoom to
|
||||||
|
// unwind, so it is dropped directly instead of through endCardHover().
|
||||||
|
if (hoverHighlightCard && hoverHighlightCard != newCard) {
|
||||||
|
hoverHighlightCard->setHoverHighlighted(false);
|
||||||
|
}
|
||||||
|
hoverHighlightCard = newCard;
|
||||||
|
if (newCard) {
|
||||||
|
newCard->setHoverHighlighted(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const int zoomTrigger = display.getHoverZoomTrigger();
|
||||||
|
const int panelTrigger = display.getHoverPanelTrigger();
|
||||||
|
const bool doubleConfirm = display.getHoverPanelDoubleConfirm() && zoomTrigger == panelTrigger;
|
||||||
|
|
||||||
|
if (newCard) {
|
||||||
|
// Cancel any pending grace timer (mouse is back on a card)
|
||||||
|
hoverGracePending = false;
|
||||||
|
hoverGraceTimer->stop();
|
||||||
|
|
||||||
|
if (newCard == hoveredCard) {
|
||||||
|
// Steady state: zoom already up. Refresh an open panel, otherwise nothing —
|
||||||
|
// in particular this must not re-fire an armed double-confirm.
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && cardHoverWidget->getCardItem() == newCard) {
|
||||||
|
cardHoverWidget->refreshDisplay();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && !cardHoverWidget->isClosing() &&
|
||||||
|
cardHoverWidget->getCardItem() == newCard) {
|
||||||
|
// Panel open but zoom dropped (e.g. survived a Leave) — zoom back and refresh.
|
||||||
beginCardHover(newCard);
|
beginCardHover(newCard);
|
||||||
}
|
|
||||||
hoveredCard = newCard;
|
hoveredCard = newCard;
|
||||||
|
cardHoverWidget->refreshDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && !cardHoverWidget->isClosing()) {
|
||||||
|
// A different card is hovered while the panel is up: close the old panel
|
||||||
|
// first, then fall through to first contact so the new card follows the
|
||||||
|
// normal dwell instead of the old panel trailing the cursor.
|
||||||
|
hideCardHoverPopup();
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
}
|
||||||
|
if (zoomTrigger != CardsDisplaySettings::HoverPanelTriggerHover &&
|
||||||
|
panelTrigger != CardsDisplaySettings::HoverPanelTriggerHover) {
|
||||||
|
// Mouse contact alone drives neither phase in this config.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (doubleConfirm && confirmArmedCard == newCard) {
|
||||||
|
// Repeat hover on an armed card: zoom and show at once, no second dwell.
|
||||||
|
beginCardHover(newCard);
|
||||||
|
hoveredCard = newCard;
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
showCardHoverPopup(newCard);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newCard != hoverPopupTarget) {
|
||||||
|
// First contact (or a new card): dwell, then resolve on timeout.
|
||||||
|
hoverPopupTarget = newCard;
|
||||||
|
hoverActivateTimer->start(display.getHoverZoomDelayMs());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No card hovered: drop any pending dwell/panel timers (kills stale shows) and start
|
||||||
|
// the grace timer only when the mouse just left a card with the panel open.
|
||||||
|
hoverPopupTarget = nullptr;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
hoverActivateTimer->stop();
|
||||||
|
hoverPanelTimer->stop();
|
||||||
|
// Non-hover zoom arms only make sense while approaching the card: leaving
|
||||||
|
// re-arms the zoom for the next explicit trigger instead of showing the panel.
|
||||||
|
// (Hover-trigger arms survive the leave so re-entering completes the repeat.)
|
||||||
|
if (zoomTrigger != CardsDisplaySettings::HoverPanelTriggerHover) {
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
}
|
||||||
|
if (wasHoveringCard && cardHoverWidget && cardHoverWidget->isVisible() &&
|
||||||
|
!cardHoverWidget->isMouseOverWidget() && !hoverGracePending) {
|
||||||
|
hoverGracePending = true;
|
||||||
|
hoverGraceTimer->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::beginCardHover(CardItem *card)
|
void GameScene::beginCardHover(CardItem *card)
|
||||||
|
|
@ -775,16 +934,340 @@ void GameScene::beginCardHover(CardItem *card)
|
||||||
if (auto *zone = SelectZone::findOwningSelectZone(card)) {
|
if (auto *zone = SelectZone::findOwningSelectZone(card)) {
|
||||||
zone->escapeClipForHover(card);
|
zone->escapeClipForHover(card);
|
||||||
}
|
}
|
||||||
|
// Lift the whole ancestor chain above their siblings: the zoomed card overflows its
|
||||||
|
// own zone, and Qt orders whole subtrees level by level, so no single z-value wins
|
||||||
|
// every comparison on its own. Harmless elsewhere (areas and zones tile without
|
||||||
|
// overlapping; arrows, zone views and drag items keep their higher layers).
|
||||||
|
// Restore first: if a previous hover never ended (its card was destroyed mid-hover),
|
||||||
|
// its chain is still outstanding and must land before a new one is recorded.
|
||||||
|
restoreHoverLift();
|
||||||
|
QGraphicsItem *ancestor = card->parentItem();
|
||||||
|
while (ancestor) {
|
||||||
|
// The chain is QGraphicsObject-derived in practice; a plain QGraphicsItem
|
||||||
|
// ancestor cannot be guarded, so it keeps its z-value instead of risking an
|
||||||
|
// unrestorable lift.
|
||||||
|
if (QGraphicsObject *ancestorObject = ancestor->toGraphicsObject()) {
|
||||||
|
hoverLiftedAncestors.append({QPointer<QGraphicsObject>(ancestorObject), ancestor->zValue()});
|
||||||
|
ancestor->setZValue(ZValues::HOVERED_AREA);
|
||||||
|
}
|
||||||
|
ancestor = ancestor->parentItem();
|
||||||
|
}
|
||||||
|
liftOwner = card;
|
||||||
|
connect(card, &AbstractCardItem::hoverShrinkFinished, this, &GameScene::onHoverShrinkFinished,
|
||||||
|
Qt::UniqueConnection);
|
||||||
|
connect(card, &AbstractCardItem::hoverFootprintChanged, this, &GameScene::onHoverFootprintChanged,
|
||||||
|
Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::endCardHover(CardItem *card)
|
void GameScene::endCardHover(CardItem *card)
|
||||||
{
|
{
|
||||||
if (auto *zone = SelectZone::findOwningSelectZone(card)) {
|
// Only the zoom-out starts here: the z-value, the clip escape and the ancestor
|
||||||
zone->restoreClipAfterHover(card);
|
// lift stay put until the shrink finishes (onHoverShrinkFinished), so siblings and
|
||||||
}
|
// the clip container cannot cut through the still-enlarged card.
|
||||||
card->setHovered(false);
|
card->setHovered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverShrinkFinished(AbstractCardItem *card)
|
||||||
|
{
|
||||||
|
auto *cardItem = qobject_cast<CardItem *>(card);
|
||||||
|
if (!cardItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Per-card and idempotent: always settle, even if a newer hover owns the lift.
|
||||||
|
if (auto *zone = SelectZone::findOwningSelectZone(cardItem)) {
|
||||||
|
zone->restoreClipAfterHover(cardItem);
|
||||||
|
}
|
||||||
|
if (liftOwner != cardItem) {
|
||||||
|
// A newer hover already owns the lift (or nothing does): leave it alone.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
restoreHoverLift();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverFootprintChanged(const QRectF &oldFootprint, const QRectF &newFootprint)
|
||||||
|
{
|
||||||
|
const QRectF dirty = oldFootprint.united(newFootprint);
|
||||||
|
if (dirty.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TableZone cuts the hovered card out of its own paint, but it is cached: the card
|
||||||
|
// changing size does not dirty the zone, so the previous hole would stay transparent in
|
||||||
|
// the cache — an uncovered black rectangle under the zoom whenever the card grows across
|
||||||
|
// a zone boundary. Nudge only the zones the footprint touches; the scene repaint itself
|
||||||
|
// is already scheduled by the card.
|
||||||
|
const auto overlapping = items(dirty, Qt::IntersectsItemBoundingRect);
|
||||||
|
for (QGraphicsItem *item : overlapping) {
|
||||||
|
if (auto *zone = qobject_cast<TableZone *>(item->toGraphicsObject())) {
|
||||||
|
zone->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::restoreHoverLift()
|
||||||
|
{
|
||||||
|
for (const auto &[lifted, zValue] : hoverLiftedAncestors) {
|
||||||
|
if (lifted) {
|
||||||
|
lifted->setZValue(zValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hoverLiftedAncestors.clear();
|
||||||
|
liftOwner.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Card Hover Popup ----------
|
||||||
|
|
||||||
|
void GameScene::showCardHoverPopup(CardItem *card)
|
||||||
|
{
|
||||||
|
if (!card || !card->getOwner()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerGraphicsItem *playerView = playerViews.value(card->getOwner()->getPlayerInfo()->getId());
|
||||||
|
if (!playerView) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hoverActivateTimer->stop();
|
||||||
|
hoverPanelTimer->stop();
|
||||||
|
hoverGracePending = false;
|
||||||
|
hoverGraceTimer->stop();
|
||||||
|
hoverPopupTarget = card;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
|
||||||
|
if (!cardHoverWidget) {
|
||||||
|
auto *viewport = views().isEmpty() ? nullptr : views().first()->viewport();
|
||||||
|
cardHoverWidget = new CardHoverWidget(viewport);
|
||||||
|
connect(cardHoverWidget, &CardHoverWidget::hoverEntered, this, &GameScene::onHoverWidgetEntered);
|
||||||
|
connect(cardHoverWidget, &CardHoverWidget::hoverLeft, this, &GameScene::onHoverWidgetLeft);
|
||||||
|
connect(cardHoverWidget, &CardHoverWidget::dismissRequested, this, &GameScene::hideCardHoverPopup);
|
||||||
|
|
||||||
|
// Keep the popup anchored to its card while the view scrolls, zooms, or resizes
|
||||||
|
if (!views().isEmpty()) {
|
||||||
|
auto *view = views().first();
|
||||||
|
connect(view->horizontalScrollBar(), &QScrollBar::valueChanged, this, &GameScene::positionCardHoverPopup);
|
||||||
|
connect(view->verticalScrollBar(), &QScrollBar::valueChanged, this, &GameScene::positionCardHoverPopup);
|
||||||
|
if (viewport) {
|
||||||
|
viewport->installEventFilter(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crossfade: the opaque panel picture sits exactly over the zoomed card, so fade
|
||||||
|
// the board card out underneath it (masks any residual size/corner mismatch) and
|
||||||
|
// fade any previously shown card back in.
|
||||||
|
CardItem *oldCard = cardHoverWidget->hasCard() ? cardHoverWidget->getCardItem() : nullptr;
|
||||||
|
|
||||||
|
cardHoverWidget->setCard(card, playerView);
|
||||||
|
positionCardHoverPopup();
|
||||||
|
cardHoverWidget->showAnimated();
|
||||||
|
|
||||||
|
if (oldCard && oldCard != card) {
|
||||||
|
oldCard->fadeCardIn();
|
||||||
|
}
|
||||||
|
card->fadeCardOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::hideCardHoverPopup()
|
||||||
|
{
|
||||||
|
// Hiding is terminal: drop all pending hover timing with it, or a dwell/panel
|
||||||
|
// timer that resolves afterwards pops the panel back up (e.g. over the context
|
||||||
|
// menu that hideCardHoverPopup was just called for).
|
||||||
|
hoverActivateTimer->stop();
|
||||||
|
hoverPanelTimer->stop();
|
||||||
|
hoverGracePending = false;
|
||||||
|
hoverGraceTimer->stop();
|
||||||
|
if (cardHoverWidget) {
|
||||||
|
// The panel is gone: whatever card it covered must come back.
|
||||||
|
if (CardItem *coveredCard = cardHoverWidget->getCardItem()) {
|
||||||
|
coveredCard->fadeCardIn();
|
||||||
|
}
|
||||||
|
if (cardHoverWidget->isVisible()) {
|
||||||
|
cardHoverWidget->hideAnimated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hoverPopupTarget = nullptr;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::positionCardHoverPopup()
|
||||||
|
{
|
||||||
|
if (!cardHoverWidget || !cardHoverWidget->hasCard()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *viewport = views().isEmpty() ? nullptr : views().first()->viewport();
|
||||||
|
if (!viewport) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF sceneRect = cardHoverWidget->getCardItem()->sceneBoundingRect();
|
||||||
|
QTransform vpTransform = getViewportTransform();
|
||||||
|
cardHoverWidget->positionNextTo(sceneRect, vpTransform, viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverActivateTimeout()
|
||||||
|
{
|
||||||
|
// Dwell resolved: the hover drives whichever phases listen to it. The cursor must
|
||||||
|
// still be over the pending card (rect test, not a fresh pick, so pick flakiness
|
||||||
|
// cannot veto it); otherwise this was a stale timer.
|
||||||
|
CardItem *target = hoverPopupTarget;
|
||||||
|
hoverPopupTarget = nullptr;
|
||||||
|
if (!target || views().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto *view = views().first();
|
||||||
|
const QPointF cursorScene = view->mapToScene(view->viewport()->mapFromGlobal(QCursor::pos()));
|
||||||
|
if (!target->sceneBoundingRect().contains(cursorScene)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const bool zoomPhase = display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerHover;
|
||||||
|
const bool panelPhase = display.getHoverPanelTrigger() == CardsDisplaySettings::HoverPanelTriggerHover;
|
||||||
|
const bool effectiveDouble =
|
||||||
|
display.getHoverPanelDoubleConfirm() && display.getHoverZoomTrigger() == display.getHoverPanelTrigger();
|
||||||
|
if (hoveredCard && hoveredCard != target) {
|
||||||
|
endCardHover(hoveredCard);
|
||||||
|
}
|
||||||
|
if (zoomPhase) {
|
||||||
|
if (hoveredCard != target) {
|
||||||
|
beginCardHover(target);
|
||||||
|
hoveredCard = target;
|
||||||
|
}
|
||||||
|
if (effectiveDouble) {
|
||||||
|
confirmArmedCard = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (panelPhase && !effectiveDouble) {
|
||||||
|
hoverPanelTarget = target;
|
||||||
|
hoverPanelTimer->start(display.getHoverPanelDelayMs());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverPanelTimeout()
|
||||||
|
{
|
||||||
|
// Panel delay resolved: show, but only if the target card is still the one under
|
||||||
|
// the cursor (same cheap rect check — no dependence on pick stability).
|
||||||
|
CardItem *target = hoverPanelTarget;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
if (!target || views().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto *view = views().first();
|
||||||
|
const QPointF cursorScene = view->mapToScene(view->viewport()->mapFromGlobal(QCursor::pos()));
|
||||||
|
if (!target->sceneBoundingRect().contains(cursorScene)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ensureZoomed(target);
|
||||||
|
showCardHoverPopup(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverGraceTimeout()
|
||||||
|
{
|
||||||
|
hoverGracePending = false;
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && cardHoverWidget->isMouseOverWidget()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hideCardHoverPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::summonHoverPanel()
|
||||||
|
{
|
||||||
|
// Summon for whatever is under the cursor right now; hovering is not required.
|
||||||
|
if (views().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto *view = views().first();
|
||||||
|
const QPointF cursorScene = view->mapToScene(view->viewport()->mapFromGlobal(QCursor::pos()));
|
||||||
|
if (CardItem *card = pickCardAt(cursorScene)) {
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
fireTriggers(card, display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerShortcut,
|
||||||
|
display.getHoverPanelTrigger() == CardsDisplaySettings::HoverPanelTriggerShortcut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::ensureZoomed(CardItem *card)
|
||||||
|
{
|
||||||
|
if (hoveredCard != card) {
|
||||||
|
if (hoveredCard) {
|
||||||
|
endCardHover(hoveredCard);
|
||||||
|
}
|
||||||
|
beginCardHover(card);
|
||||||
|
hoveredCard = card;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::fireTriggers(CardItem *card, bool zoomFired, bool panelFired)
|
||||||
|
{
|
||||||
|
if (!card || !card->getOwner()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && !cardHoverWidget->isClosing() &&
|
||||||
|
cardHoverWidget->getCardItem() == card) {
|
||||||
|
cardHoverWidget->refreshDisplay();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Explicit triggers preempt any pending hover timing.
|
||||||
|
hoverPopupTarget = nullptr;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
hoverActivateTimer->stop();
|
||||||
|
hoverPanelTimer->stop();
|
||||||
|
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const bool effectiveDouble =
|
||||||
|
display.getHoverPanelDoubleConfirm() && display.getHoverZoomTrigger() == display.getHoverPanelTrigger();
|
||||||
|
|
||||||
|
if (zoomFired && panelFired) {
|
||||||
|
// Both phases on one action: one-step zooms and shows at once (the crossfade
|
||||||
|
// covers it); double-confirm arms on first fire and shows on repeat.
|
||||||
|
if (effectiveDouble) {
|
||||||
|
if (confirmArmedCard == card) {
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
ensureZoomed(card);
|
||||||
|
showCardHoverPopup(card);
|
||||||
|
} else {
|
||||||
|
confirmArmedCard = card;
|
||||||
|
ensureZoomed(card);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ensureZoomed(card);
|
||||||
|
showCardHoverPopup(card);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (zoomFired) {
|
||||||
|
ensureZoomed(card);
|
||||||
|
}
|
||||||
|
if (panelFired) {
|
||||||
|
ensureZoomed(card);
|
||||||
|
showCardHoverPopup(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverWidgetEntered()
|
||||||
|
{
|
||||||
|
hoverGracePending = false;
|
||||||
|
hoverGraceTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScene::onHoverWidgetLeft()
|
||||||
|
{
|
||||||
|
if (!hoveredCard && cardHoverWidget && cardHoverWidget->isVisible() && !hoverGracePending) {
|
||||||
|
hoverGracePending = true;
|
||||||
|
hoverGraceTimer->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameScene::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::Resize) {
|
||||||
|
positionCardHoverPopup();
|
||||||
|
}
|
||||||
|
return QGraphicsScene::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
CardZone *GameScene::findTopmostZone(const QList<QGraphicsItem *> &items)
|
CardZone *GameScene::findTopmostZone(const QList<QGraphicsItem *> &items)
|
||||||
{
|
{
|
||||||
for (QGraphicsItem *item : items) {
|
for (QGraphicsItem *item : items) {
|
||||||
|
|
@ -940,7 +1423,50 @@ bool GameScene::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseMove) {
|
if (event->type() == QEvent::GraphicsSceneMouseMove) {
|
||||||
updateHover(static_cast<QGraphicsSceneMouseEvent *>(event)->scenePos());
|
updateHover(static_cast<QGraphicsSceneMouseEvent *>(event)->scenePos());
|
||||||
|
} else if (event->type() == QEvent::GraphicsSceneWheel) {
|
||||||
|
// Wheel trigger: wheeling over a card fires whichever phases listen to it
|
||||||
|
// instead of scrolling. Fully consumed here: forwarding to the base dispatcher
|
||||||
|
// as well would double-deliver it to items under the cursor (e.g. zone views,
|
||||||
|
// which scroll on wheel). Scrolling up instead reverts an active zoom/panel —
|
||||||
|
// backing out of the gesture undoes it; with nothing to revert the event falls
|
||||||
|
// through to normal scrolling.
|
||||||
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
|
const bool zoomFired = display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerWheel;
|
||||||
|
const bool panelFired = display.getHoverPanelTrigger() == CardsDisplaySettings::HoverPanelTriggerWheel;
|
||||||
|
if (zoomFired || panelFired) {
|
||||||
|
auto *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);
|
||||||
|
// QGraphicsSceneWheelEvent carries delta()/pixelDelta(), not angleDelta().
|
||||||
|
const int wheelUp = !wheelEvent->pixelDelta().isNull()
|
||||||
|
? wheelEvent->pixelDelta().y()
|
||||||
|
: (wheelEvent->orientation() == Qt::Vertical ? wheelEvent->delta() : 0);
|
||||||
|
if (wheelUp > 0) {
|
||||||
|
if ((cardHoverWidget && cardHoverWidget->isVisible()) || hoveredCard) {
|
||||||
|
hoverPopupTarget = nullptr;
|
||||||
|
hoverPanelTarget = nullptr;
|
||||||
|
confirmArmedCard.clear();
|
||||||
|
hideCardHoverPopup();
|
||||||
|
if (hoveredCard) {
|
||||||
|
endCardHover(hoveredCard);
|
||||||
|
hoveredCard = nullptr;
|
||||||
|
}
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (CardItem *card = pickCardAt(wheelEvent->scenePos())) {
|
||||||
|
fireTriggers(card, zoomFired, panelFired);
|
||||||
|
event->accept();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (event->type() == QEvent::Leave) {
|
} else if (event->type() == QEvent::Leave) {
|
||||||
|
// The hover panel opens directly over the zoomed card under the cursor, which the
|
||||||
|
// scene observes as a Leave. The cursor never actually left: if it is over the open
|
||||||
|
// panel, keep the hover (dropping it here shrinks the card from under the panel and
|
||||||
|
// starves the popup logic, so the menu never shows). A genuine leave of the window
|
||||||
|
// misses the panel and still ends the hover as before.
|
||||||
|
if (cardHoverWidget && cardHoverWidget->isVisible() && cardHoverWidget->isMouseOverWidget()) {
|
||||||
|
return QGraphicsScene::event(event);
|
||||||
|
}
|
||||||
updateHoveredCard(nullptr);
|
updateHoveredCard(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
|
#include <QPair>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QRectF>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QSizeF>
|
#include <QSizeF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
@ -30,6 +32,7 @@
|
||||||
class CardZoneLogic;
|
class CardZoneLogic;
|
||||||
class IAnimatedItem;
|
class IAnimatedItem;
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
|
class QGraphicsObject;
|
||||||
class QPoint;
|
class QPoint;
|
||||||
struct ArrowData;
|
struct ArrowData;
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
@ -48,6 +51,8 @@ class ServerInfo_Card;
|
||||||
class PhasesToolbar;
|
class PhasesToolbar;
|
||||||
class QBasicTimer;
|
class QBasicTimer;
|
||||||
class QObject;
|
class QObject;
|
||||||
|
class QTimer;
|
||||||
|
class CardHoverWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class GameScene
|
* @class GameScene
|
||||||
|
|
@ -73,8 +78,24 @@ private:
|
||||||
ArrowRegistry arrowRegistry; ///< ID registry for arrow graphics items
|
ArrowRegistry arrowRegistry; ///< ID registry for arrow graphics items
|
||||||
QList<ZoneViewWidget *> zoneViews; ///< Active zone view widgets
|
QList<ZoneViewWidget *> zoneViews; ///< Active zone view widgets
|
||||||
QSize viewSize; ///< Current view size
|
QSize viewSize; ///< Current view size
|
||||||
QPointer<CardItem> hoveredCard; ///< Currently hovered card
|
QPointer<CardItem> hoveredCard; ///< Currently hovered card (zoomed)
|
||||||
|
/// Card the cursor is resting on. It carries the hover outline and the card-info
|
||||||
|
/// update immediately, independently of the zoom/panel triggers.
|
||||||
|
QPointer<CardItem> hoverHighlightCard;
|
||||||
QPointer<CardItem> activeCard; ///< Card the currently open context menu targets
|
QPointer<CardItem> activeCard; ///< Card the currently open context menu targets
|
||||||
|
/// Card armed for double-confirm panel summon (first trigger zooms, repeat shows).
|
||||||
|
QPointer<CardItem> confirmArmedCard;
|
||||||
|
/// Ancestor chain of the hovered card with pre-hover Z-values. Lifted while hovering
|
||||||
|
/// because Qt orders subtrees level by level: the card z alone cannot beat a sibling
|
||||||
|
/// zone, and the top ancestor alone cannot beat same-area sibling zones either — every
|
||||||
|
/// level from the zone up must win its own comparison. Guarded pointers: if the card
|
||||||
|
/// is destroyed mid-hover (or an ancestor goes away first), the guards null out and
|
||||||
|
/// the next restore skips them instead of touching freed memory. An orphaned lift is
|
||||||
|
/// invisible — areas and zones tile without overlapping and all UI layers still win —
|
||||||
|
/// and any outstanding lift is restored by the next hover transition.
|
||||||
|
QList<QPair<QPointer<QGraphicsObject>, qreal>> hoverLiftedAncestors;
|
||||||
|
/// Card whose ancestor chain is currently lifted (cleared together with the chain).
|
||||||
|
QPointer<CardItem> liftOwner;
|
||||||
QBasicTimer *animationTimer; ///< Timer for scene animations
|
QBasicTimer *animationTimer; ///< Timer for scene animations
|
||||||
QHash<QObject *, IAnimatedItem *> animatedItems; ///< Items currently animating
|
QHash<QObject *, IAnimatedItem *> animatedItems; ///< Items currently animating
|
||||||
QHash<QObject *, QMetaObject::Connection>
|
QHash<QObject *, QMetaObject::Connection>
|
||||||
|
|
@ -83,6 +104,15 @@ private:
|
||||||
bool rearranging = false; ///< Guard against re-entrant rearrange
|
bool rearranging = false; ///< Guard against re-entrant rearrange
|
||||||
bool needsReArrange = false; ///< Pending rearrange requested during a pass
|
bool needsReArrange = false; ///< Pending rearrange requested during a pass
|
||||||
|
|
||||||
|
// Card hover popup
|
||||||
|
QPointer<CardHoverWidget> cardHoverWidget; ///< The hover popup widget
|
||||||
|
QTimer *hoverActivateTimer; ///< Dwell delay before the hover zoom kicks in
|
||||||
|
QTimer *hoverPanelTimer; ///< Delay after the zoom before the tab panel shows
|
||||||
|
QTimer *hoverGraceTimer; ///< Grace period before hiding popup (200ms)
|
||||||
|
QPointer<CardItem> hoverPopupTarget; ///< Card the popup is intended for
|
||||||
|
QPointer<CardItem> hoverPanelTarget; ///< Card the panel timer will show
|
||||||
|
bool hoverGracePending = false; ///< Grace timer armed (mouse left a card or the popup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Updates which card is currently hovered based on scene coordinates.
|
* @brief Updates which card is currently hovered based on scene coordinates.
|
||||||
* @param scenePos Scene position of the cursor.
|
* @param scenePos Scene position of the cursor.
|
||||||
|
|
@ -96,6 +126,23 @@ private:
|
||||||
void beginCardHover(CardItem *card);
|
void beginCardHover(CardItem *card);
|
||||||
/** @brief Deactivates hover state and restores the card to its clip container. */
|
/** @brief Deactivates hover state and restores the card to its clip container. */
|
||||||
void endCardHover(CardItem *card);
|
void endCardHover(CardItem *card);
|
||||||
|
/** @brief Restores every lifted ancestor to its pre-hover Z-value and drops the chain. */
|
||||||
|
void restoreHoverLift();
|
||||||
|
/** @brief Settles a finished shrink-out: clip container and ancestor lift restore. */
|
||||||
|
void onHoverShrinkFinished(AbstractCardItem *card);
|
||||||
|
/**
|
||||||
|
* @brief Repaints the zones that dodge the zoomed card when its footprint moves.
|
||||||
|
*
|
||||||
|
* Those zones cut the hovered card out of their paint, but they are cached: another
|
||||||
|
* item's geometry change does not dirty them, so without this the previous hole stays
|
||||||
|
* transparent in the cache and a black rectangle shows under the zoom.
|
||||||
|
*/
|
||||||
|
void onHoverFootprintChanged(const QRectF &oldFootprint, const QRectF &newFootprint);
|
||||||
|
|
||||||
|
// Card hover popup methods
|
||||||
|
void showCardHoverPopup(CardItem *card);
|
||||||
|
void hideCardHoverPopup();
|
||||||
|
void positionCardHoverPopup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
@ -227,6 +274,21 @@ public:
|
||||||
/** @brief Updates hovered card highlighting. */
|
/** @brief Updates hovered card highlighting. */
|
||||||
void updateHoveredCard(CardItem *newCard);
|
void updateHoveredCard(CardItem *newCard);
|
||||||
|
|
||||||
|
/** @brief Topmost card at a scene position, without side effects. */
|
||||||
|
CardItem *pickCardAt(const QPointF &scenePos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Fires the zoom and/or panel trigger for a card (one explicit user action).
|
||||||
|
* When both fire on one action, double-confirm arms on first fire and shows on repeat.
|
||||||
|
*/
|
||||||
|
void fireTriggers(CardItem *card, bool zoomFired, bool panelFired);
|
||||||
|
|
||||||
|
/** @brief Starts the hover zoom for a card without touching panel state. */
|
||||||
|
void ensureZoomed(CardItem *card);
|
||||||
|
|
||||||
|
/** @brief The currently hovered card, if any (used by zones to dodge it while painting). */
|
||||||
|
CardItem *getHoveredCard() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Registers an item for animation updates with the shared scene timer.
|
* @brief Registers an item for animation updates with the shared scene timer.
|
||||||
*
|
*
|
||||||
|
|
@ -293,10 +355,22 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void onCardViewRefreshRequested(CardState *card, bool zoneChanged, PlayerLogic *newOwner);
|
void onCardViewRefreshRequested(CardState *card, bool zoneChanged, PlayerLogic *newOwner);
|
||||||
|
|
||||||
|
// Card hover popup slots
|
||||||
|
void onHoverActivateTimeout();
|
||||||
|
void onHoverPanelTimeout();
|
||||||
|
void onHoverGraceTimeout();
|
||||||
|
void onHoverWidgetEntered();
|
||||||
|
void onHoverWidgetLeft();
|
||||||
|
/** @brief Summons the hover panel for the currently hovered card, if any. */
|
||||||
|
void summonHoverPanel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** @brief Handles hover updates. */
|
/** @brief Handles hover updates. */
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
|
|
||||||
|
/** @brief Repositions the hover popup when the viewport resizes. */
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
/** @brief Handles animation timer updates. */
|
/** @brief Handles animation timer updates. */
|
||||||
void timerEvent(QTimerEvent *event) override;
|
void timerEvent(QTimerEvent *event) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,10 @@ GameView::GameView(GameScene *scene, QWidget *parent) : QGraphicsView(scene, par
|
||||||
|
|
||||||
connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView);
|
connect(aCloseMostRecentZoneView, &QAction::triggered, scene, &GameScene::closeMostRecentZoneView);
|
||||||
addAction(aCloseMostRecentZoneView);
|
addAction(aCloseMostRecentZoneView);
|
||||||
|
|
||||||
|
aShowHoverPanel = new QAction(this);
|
||||||
|
connect(aShowHoverPanel, &QAction::triggered, scene, &GameScene::summonHoverPanel);
|
||||||
|
addAction(aShowHoverPanel);
|
||||||
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
connect(&SettingsCache::instance().shortcuts(), &ShortcutsSettings::shortCutChanged, this,
|
||||||
&GameView::refreshShortcuts);
|
&GameView::refreshShortcuts);
|
||||||
refreshShortcuts();
|
refreshShortcuts();
|
||||||
|
|
@ -246,6 +250,7 @@ void GameView::refreshShortcuts()
|
||||||
{
|
{
|
||||||
aCloseMostRecentZoneView->setShortcuts(
|
aCloseMostRecentZoneView->setShortcuts(
|
||||||
SettingsCache::instance().shortcuts().getShortcut("Player/aCloseMostRecentZoneView"));
|
SettingsCache::instance().shortcuts().getShortcut("Player/aCloseMostRecentZoneView"));
|
||||||
|
aShowHoverPanel->setShortcuts(SettingsCache::instance().shortcuts().getShortcut("Player/aShowHoverPanel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::clearTallyLabels()
|
void GameView::clearTallyLabels()
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class GameView : public QGraphicsView
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QAction *aCloseMostRecentZoneView;
|
QAction *aCloseMostRecentZoneView;
|
||||||
|
QAction *aShowHoverPanel;
|
||||||
QRubberBand *rubberBand;
|
QRubberBand *rubberBand;
|
||||||
QLabel *dragCountLabel;
|
QLabel *dragCountLabel;
|
||||||
QLabel *totalCountLabel;
|
QLabel *totalCountLabel;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ constexpr qreal OVERLAY_BASE = ZValueLayerManager::OVERLAY_BASE;
|
||||||
|
|
||||||
// Overlay layer Z-values for items that should appear above normal cards
|
// Overlay layer Z-values for items that should appear above normal cards
|
||||||
constexpr qreal HOVERED_CARD = ZValueLayerManager::overlayZValue(1.0);
|
constexpr qreal HOVERED_CARD = ZValueLayerManager::overlayZValue(1.0);
|
||||||
|
// Lifts the hovered card's whole player area above sibling areas (and their zone
|
||||||
|
// decorations) while hovering. One level only: Qt compares subtrees at their highest
|
||||||
|
// differing ancestor, so the top ancestor decides. Below arrows/views/drags on purpose.
|
||||||
|
constexpr qreal HOVERED_AREA = ZValueLayerManager::overlayZValue(2.0);
|
||||||
constexpr qreal ARROWS = ZValueLayerManager::overlayZValue(3.0);
|
constexpr qreal ARROWS = ZValueLayerManager::overlayZValue(3.0);
|
||||||
constexpr qreal ZONE_VIEW_WIDGET = ZValueLayerManager::overlayZValue(4.0);
|
constexpr qreal ZONE_VIEW_WIDGET = ZValueLayerManager::overlayZValue(4.0);
|
||||||
constexpr qreal DRAG_ITEM = ZValueLayerManager::overlayZValue(5.0);
|
constexpr qreal DRAG_ITEM = ZValueLayerManager::overlayZValue(5.0);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QListIterator>
|
#include <QListIterator>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
@ -34,6 +35,7 @@
|
||||||
#include <libcockatrice/game/zones/table_zone_logic.h>
|
#include <libcockatrice/game/zones/table_zone_logic.h>
|
||||||
#include <libcockatrice/settings/interface_settings.h>
|
#include <libcockatrice/settings/interface_settings.h>
|
||||||
#include <libcockatrice/utility/zone_names.h>
|
#include <libcockatrice/utility/zone_names.h>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace google
|
namespace google
|
||||||
|
|
@ -118,6 +120,19 @@ bool TableZone::isInverted() const
|
||||||
|
|
||||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||||
{
|
{
|
||||||
|
// The hovered (zoomed) card may spill over this zone: cut it out of every layer
|
||||||
|
// below so washes, indicators, dimming and the land divider never paint over it,
|
||||||
|
// whatever the stacking order is.
|
||||||
|
const std::optional<QPainterPath> hoverHole = hoveredCardHole();
|
||||||
|
const bool clipped = hoverHole.has_value();
|
||||||
|
if (clipped && hoverHole->isEmpty()) {
|
||||||
|
// The zoom covers this zone entirely: there is nothing left of it to paint.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clipped) {
|
||||||
|
painter->setClipPath(*hoverHole);
|
||||||
|
}
|
||||||
|
|
||||||
if (playmatActive) {
|
if (playmatActive) {
|
||||||
// Subtle overlay to distinguish table zone from stack zone
|
// Subtle overlay to distinguish table zone from stack zone
|
||||||
painter->fillRect(boundingRect(), QColor(0, 0, 0, 60));
|
painter->fillRect(boundingRect(), QColor(0, 0, 0, 60));
|
||||||
|
|
@ -142,6 +157,39 @@ void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*opti
|
||||||
}
|
}
|
||||||
|
|
||||||
paintLandDivider(painter);
|
paintLandDivider(painter);
|
||||||
|
|
||||||
|
if (clipped) {
|
||||||
|
painter->setClipping(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This zone's paint area minus the hovered card's painted outline, in zone coordinates.
|
||||||
|
*
|
||||||
|
* @c std::nullopt when no card is hovered or it does not overlap this zone; an *empty* path when
|
||||||
|
* the zoom covers this zone entirely, which means nothing of it is left to paint. Lets every
|
||||||
|
* paint layer dodge the zoomed card instead of painting over it.
|
||||||
|
*/
|
||||||
|
std::optional<QPainterPath> TableZone::hoveredCardHole() const
|
||||||
|
{
|
||||||
|
auto *scene = qobject_cast<GameScene *>(this->scene());
|
||||||
|
if (!scene) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
CardItem *hovered = scene->getHoveredCard();
|
||||||
|
if (!hovered) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
// Cut out the card's painted outline, not its bounding rectangle: the rectangle's corners
|
||||||
|
// are never covered by the artwork (rounded corners, antialiased edges), so they would stay
|
||||||
|
// black around the zoom.
|
||||||
|
const QPainterPath cardOutline = sceneTransform().inverted().map(hovered->sceneTransform().map(hovered->shape()));
|
||||||
|
if (!cardOutline.boundingRect().intersects(boundingRect())) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
QPainterPath zoneArea;
|
||||||
|
zoneArea.addRect(boundingRect());
|
||||||
|
return zoneArea.subtracted(cardOutline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::onPlaymatChanged(bool active)
|
void TableZone::onPlaymatChanged(bool active)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/game/zones/table_zone_logic.h>
|
#include <libcockatrice/game/zones/table_zone_logic.h>
|
||||||
|
#include <optional>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
class CardDragItem;
|
class CardDragItem;
|
||||||
|
|
@ -26,6 +27,7 @@ class CardZoneLogic;
|
||||||
class QColor;
|
class QColor;
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
class QPainterPath;
|
||||||
template <typename T> class QList;
|
template <typename T> class QList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -221,6 +223,13 @@ private:
|
||||||
|
|
||||||
void paintZoneOutline(QPainter *painter);
|
void paintZoneOutline(QPainter *painter);
|
||||||
void paintLandDivider(QPainter *painter);
|
void paintLandDivider(QPainter *painter);
|
||||||
|
/**
|
||||||
|
* @brief This zone's paint area minus the hovered card's painted outline, in zone coordinates.
|
||||||
|
*
|
||||||
|
* @c std::nullopt when no card is hovered or it does not overlap this zone; an *empty* path when
|
||||||
|
* the hovered card covers this zone entirely, in which case nothing of the zone is visible.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] std::optional<QPainterPath> hoveredCardHole() const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Calculates card stack widths so mapping functions work properly
|
Calculates card stack widths so mapping functions work properly
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,10 @@ ZoneViewWidget::ZoneViewWidget(PlayerLogic *_player,
|
||||||
searchEdit.setFocusPolicy(Qt::ClickFocus);
|
searchEdit.setFocusPolicy(Qt::ClickFocus);
|
||||||
searchEdit.setPlaceholderText(tr("Search by card name (or search expressions)"));
|
searchEdit.setPlaceholderText(tr("Search by card name (or search expressions)"));
|
||||||
searchEdit.setClearButtonEnabled(true);
|
searchEdit.setClearButtonEnabled(true);
|
||||||
searchEdit.addAction(loadThemedIcon(QStringLiteral("icons/search")), QLineEdit::LeadingPosition);
|
searchEdit.addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()),
|
||||||
auto help = searchEdit.addAction(loadThemedIcon(QStringLiteral("icons/info")), QLineEdit::TrailingPosition);
|
QLineEdit::LeadingPosition);
|
||||||
|
auto help = searchEdit.addAction(loadThemedIcon(QStringLiteral("icons/info"), IconTint::quiet()),
|
||||||
|
QLineEdit::TrailingPosition);
|
||||||
|
|
||||||
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
|
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -178,9 +178,14 @@ PaletteConfig fromAccent(const QColor &accent, int intensity, const QString &sch
|
||||||
cfg.appColors[AppColor::IconStrong] = ThemeIconInk::forEmphasis(iconInk, iconSurface, IconEmphasis::Primary);
|
cfg.appColors[AppColor::IconStrong] = ThemeIconInk::forEmphasis(iconInk, iconSurface, IconEmphasis::Primary);
|
||||||
cfg.appColors[AppColor::IconSoft] = ThemeIconInk::forEmphasis(iconInk, iconSurface, IconEmphasis::Quiet);
|
cfg.appColors[AppColor::IconSoft] = ThemeIconInk::forEmphasis(iconInk, iconSurface, IconEmphasis::Quiet);
|
||||||
// Semantic roles stay independent of the accent: a generated palette must
|
// Semantic roles stay independent of the accent: a generated palette must
|
||||||
// still paint add/ready green and remove/not-ready red.
|
// still paint add/ready green, remove/not-ready red, information blue,
|
||||||
for (const AppColor::Role role : {AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft,
|
// hidden information violet, marks amber and movement teal.
|
||||||
AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft}) {
|
for (const AppColor::Role role :
|
||||||
|
{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft, AppColor::Negative,
|
||||||
|
AppColor::NegativeStrong, AppColor::NegativeSoft, AppColor::Informational, AppColor::InformationalStrong,
|
||||||
|
AppColor::InformationalSoft, AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft, AppColor::Marked,
|
||||||
|
AppColor::MarkedStrong, AppColor::MarkedSoft, AppColor::Movement, AppColor::MovementStrong,
|
||||||
|
AppColor::MovementSoft}) {
|
||||||
cfg.appColors[role] = defaultAppColor(role, dark);
|
cfg.appColors[role] = defaultAppColor(role, dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,22 @@ static const QMap<AppColor::Role, const char *> APP_ROLE_DESCRIPTIONS = {
|
||||||
QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state and removal actions (not ready, remove, decrement)")},
|
QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state and removal actions (not ready, remove, decrement)")},
|
||||||
{AppColor::NegativeStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state at primary emphasis")},
|
{AppColor::NegativeStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state at primary emphasis")},
|
||||||
{AppColor::NegativeSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state at quiet emphasis")},
|
{AppColor::NegativeSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Negative state at quiet emphasis")},
|
||||||
|
{AppColor::Informational,
|
||||||
|
QT_TRANSLATE_NOOP("PaletteGridWidget",
|
||||||
|
"Informational state that is neither a gain nor a loss (face-down, exile)")},
|
||||||
|
{AppColor::InformationalStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Informational state at primary emphasis")},
|
||||||
|
{AppColor::InformationalSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Informational state at quiet emphasis")},
|
||||||
|
{AppColor::Hidden,
|
||||||
|
QT_TRANSLATE_NOOP("PaletteGridWidget", "Hidden information (face-down play, peek at the card face)")},
|
||||||
|
{AppColor::HiddenStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Hidden information at primary emphasis")},
|
||||||
|
{AppColor::HiddenSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Hidden information at quiet emphasis")},
|
||||||
|
{AppColor::Marked, QT_TRANSLATE_NOOP("PaletteGridWidget", "Marks left on a card (annotation, draw arrow)")},
|
||||||
|
{AppColor::MarkedStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Marks on a card at primary emphasis")},
|
||||||
|
{AppColor::MarkedSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Marks on a card at quiet emphasis")},
|
||||||
|
{AppColor::Movement,
|
||||||
|
QT_TRANSLATE_NOOP("PaletteGridWidget", "Cards moving without a gain or a loss (library placements)")},
|
||||||
|
{AppColor::MovementStrong, QT_TRANSLATE_NOOP("PaletteGridWidget", "Movement at primary emphasis")},
|
||||||
|
{AppColor::MovementSoft, QT_TRANSLATE_NOOP("PaletteGridWidget", "Movement at quiet emphasis")},
|
||||||
};
|
};
|
||||||
|
|
||||||
PaletteGridWidget::PaletteGridWidget(QWidget *parent) : QWidget(parent)
|
PaletteGridWidget::PaletteGridWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,8 @@ QPixmap DropdownIconPixmapGenerator::generatePixmap(int height, bool expanded)
|
||||||
// handing a DPR-1 bitmap to a label that would upscale and blur it on a 2x
|
// handing a DPR-1 bitmap to a label that would upscale and blur it on a 2x
|
||||||
// display.
|
// display.
|
||||||
const QString prefix = QStringLiteral("icons/") + (expanded ? "dropdown_expanded" : "dropdown_collapsed");
|
const QString prefix = QStringLiteral("icons/") + (expanded ? "dropdown_expanded" : "dropdown_collapsed");
|
||||||
const QPixmap pixmap = loadThemedIcon(prefix).pixmap(QSize(height, height), qApp->devicePixelRatio());
|
const QPixmap pixmap =
|
||||||
|
loadThemedIcon(prefix, IconTint::quiet()).pixmap(QSize(height, height), qApp->devicePixelRatio());
|
||||||
pmCache.insert(key, pixmap);
|
pmCache.insert(key, pixmap);
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -482,6 +482,42 @@ QColor defaultAppColor(AppColor::Role role, bool dark)
|
||||||
return QColor(dark ? QStringLiteral("#ff8378") : QStringLiteral("#da0b00"));
|
return QColor(dark ? QStringLiteral("#ff8378") : QStringLiteral("#da0b00"));
|
||||||
case AppColor::NegativeSoft:
|
case AppColor::NegativeSoft:
|
||||||
return QColor(dark ? QStringLiteral("#c79e9b") : QStringLiteral("#935f5c"));
|
return QColor(dark ? QStringLiteral("#c79e9b") : QStringLiteral("#935f5c"));
|
||||||
|
// Informational is the third semantic family: a state that is neither a
|
||||||
|
// gain nor a loss (a face-down play, the exile zone). It carries the
|
||||||
|
// same three-level ladder so its emphasis is authored, not computed.
|
||||||
|
case AppColor::Informational:
|
||||||
|
return QColor(dark ? QStringLiteral("#7aa9f2") : QStringLiteral("#1c64c4"));
|
||||||
|
case AppColor::InformationalStrong:
|
||||||
|
return QColor(dark ? QStringLiteral("#69aeff") : QStringLiteral("#0a4fb5"));
|
||||||
|
case AppColor::InformationalSoft:
|
||||||
|
return QColor(dark ? QStringLiteral("#9db2cd") : QStringLiteral("#526a8a"));
|
||||||
|
// Hidden is the game's hidden-information cluster: a face-down play and
|
||||||
|
// peeking at a card face. Violet keeps it apart from the blue
|
||||||
|
// Informational family, which carries public information (reveal).
|
||||||
|
case AppColor::Hidden:
|
||||||
|
return QColor(dark ? QStringLiteral("#c6a5fa") : QStringLiteral("#6d28d9"));
|
||||||
|
case AppColor::HiddenStrong:
|
||||||
|
return QColor(dark ? QStringLiteral("#c99bff") : QStringLiteral("#4c0f9e"));
|
||||||
|
case AppColor::HiddenSoft:
|
||||||
|
return QColor(dark ? QStringLiteral("#b3a6c9") : QStringLiteral("#6a5a8c"));
|
||||||
|
// Marked is the marks a player leaves on a card: an annotation or a
|
||||||
|
// draw arrow. Amber names a persistent, removable mark rather than a
|
||||||
|
// gain or a loss, so annotation and arrow finally share a colour.
|
||||||
|
case AppColor::Marked:
|
||||||
|
return QColor(dark ? QStringLiteral("#e2a63a") : QStringLiteral("#9a5b05"));
|
||||||
|
case AppColor::MarkedStrong:
|
||||||
|
return QColor(dark ? QStringLiteral("#ffb020") : QStringLiteral("#8a4f02"));
|
||||||
|
case AppColor::MarkedSoft:
|
||||||
|
return QColor(dark ? QStringLiteral("#c2ab7d") : QStringLiteral("#7b6a4a"));
|
||||||
|
// Movement is a card changing position without a gain or a loss: the
|
||||||
|
// library placements (top, bottom, X from top). Teal keeps it apart
|
||||||
|
// from the green "into play" moves and the blue informational states.
|
||||||
|
case AppColor::Movement:
|
||||||
|
return QColor(dark ? QStringLiteral("#4cc2b5") : QStringLiteral("#0e7a72"));
|
||||||
|
case AppColor::MovementStrong:
|
||||||
|
return QColor(dark ? QStringLiteral("#2dd4bf") : QStringLiteral("#096b62"));
|
||||||
|
case AppColor::MovementSoft:
|
||||||
|
return QColor(dark ? QStringLiteral("#a3c1bc") : QStringLiteral("#4a6b67"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@
|
||||||
// beyond what Qt's palette can express.
|
// beyond what Qt's palette can express.
|
||||||
//
|
//
|
||||||
// The icon families carry one role per emphasis level. Icon is the neutral
|
// The icon families carry one role per emphasis level. Icon is the neutral
|
||||||
// glyph ink; IconStrong and IconSoft are its primary and quiet levels. Positive
|
// glyph ink; IconStrong and IconSoft are its primary and quiet levels. Positive,
|
||||||
// and Negative follow the same pattern, so an emphasis never has to be computed
|
// Negative, Informational, Hidden, Marked and Movement follow the same pattern,
|
||||||
// from a hue at paint time: the theme authors all three levels. Naming a variant
|
// so an emphasis never has to be computed from a hue at paint time: the theme
|
||||||
// explicitly (`IconStrong`) pins that level; naming the family (`Icon`) lets the
|
// authors all three levels. Naming a variant explicitly (`IconStrong`) pins that
|
||||||
// caller's emphasis choose.
|
// level; naming the family (`Icon`) lets the caller's emphasis choose.
|
||||||
namespace AppColor
|
namespace AppColor
|
||||||
{
|
{
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
|
|
@ -36,6 +36,18 @@ enum Role
|
||||||
Negative,
|
Negative,
|
||||||
NegativeStrong,
|
NegativeStrong,
|
||||||
NegativeSoft,
|
NegativeSoft,
|
||||||
|
Informational,
|
||||||
|
InformationalStrong,
|
||||||
|
InformationalSoft,
|
||||||
|
Hidden,
|
||||||
|
HiddenStrong,
|
||||||
|
HiddenSoft,
|
||||||
|
Marked,
|
||||||
|
MarkedStrong,
|
||||||
|
MarkedSoft,
|
||||||
|
Movement,
|
||||||
|
MovementStrong,
|
||||||
|
MovementSoft,
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(Role)
|
Q_ENUM_NS(Role)
|
||||||
} // namespace AppColor
|
} // namespace AppColor
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,22 @@ AppColor::Role emphasisRole(AppColor::Role role, IconEmphasis emphasis)
|
||||||
return emphasis == IconEmphasis::Primary ? AppColor::NegativeStrong
|
return emphasis == IconEmphasis::Primary ? AppColor::NegativeStrong
|
||||||
: emphasis == IconEmphasis::Quiet ? AppColor::NegativeSoft
|
: emphasis == IconEmphasis::Quiet ? AppColor::NegativeSoft
|
||||||
: AppColor::Negative;
|
: AppColor::Negative;
|
||||||
|
case AppColor::Informational:
|
||||||
|
return emphasis == IconEmphasis::Primary ? AppColor::InformationalStrong
|
||||||
|
: emphasis == IconEmphasis::Quiet ? AppColor::InformationalSoft
|
||||||
|
: AppColor::Informational;
|
||||||
|
case AppColor::Hidden:
|
||||||
|
return emphasis == IconEmphasis::Primary ? AppColor::HiddenStrong
|
||||||
|
: emphasis == IconEmphasis::Quiet ? AppColor::HiddenSoft
|
||||||
|
: AppColor::Hidden;
|
||||||
|
case AppColor::Marked:
|
||||||
|
return emphasis == IconEmphasis::Primary ? AppColor::MarkedStrong
|
||||||
|
: emphasis == IconEmphasis::Quiet ? AppColor::MarkedSoft
|
||||||
|
: AppColor::Marked;
|
||||||
|
case AppColor::Movement:
|
||||||
|
return emphasis == IconEmphasis::Primary ? AppColor::MovementStrong
|
||||||
|
: emphasis == IconEmphasis::Quiet ? AppColor::MovementSoft
|
||||||
|
: AppColor::Movement;
|
||||||
default:
|
default:
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -683,6 +683,18 @@ QColor ThemeManager::appColor(AppColor::Role role) const
|
||||||
case AppColor::Negative:
|
case AppColor::Negative:
|
||||||
case AppColor::NegativeStrong:
|
case AppColor::NegativeStrong:
|
||||||
case AppColor::NegativeSoft:
|
case AppColor::NegativeSoft:
|
||||||
|
case AppColor::Informational:
|
||||||
|
case AppColor::InformationalStrong:
|
||||||
|
case AppColor::InformationalSoft:
|
||||||
|
case AppColor::Hidden:
|
||||||
|
case AppColor::HiddenStrong:
|
||||||
|
case AppColor::HiddenSoft:
|
||||||
|
case AppColor::Marked:
|
||||||
|
case AppColor::MarkedStrong:
|
||||||
|
case AppColor::MarkedSoft:
|
||||||
|
case AppColor::Movement:
|
||||||
|
case AppColor::MovementStrong:
|
||||||
|
case AppColor::MovementSoft:
|
||||||
// Semantic colors are independent of the accent: a missing role must
|
// Semantic colors are independent of the accent: a missing role must
|
||||||
// not silently paint "remove" in the theme's highlight color.
|
// not silently paint "remove" in the theme's highlight color.
|
||||||
return defaultAppColor(role, isDarkModeActive());
|
return defaultAppColor(role, isDarkModeActive());
|
||||||
|
|
|
||||||
1736
cockatrice/src/interface/widgets/cards/card_hover_widget.cpp
Normal file
1736
cockatrice/src/interface/widgets/cards/card_hover_widget.cpp
Normal file
File diff suppressed because it is too large
Load diff
231
cockatrice/src/interface/widgets/cards/card_hover_widget.h
Normal file
231
cockatrice/src/interface/widgets/cards/card_hover_widget.h
Normal file
|
|
@ -0,0 +1,231 @@
|
||||||
|
/**
|
||||||
|
* @file card_hover_widget.h
|
||||||
|
* @ingroup CardWidgets
|
||||||
|
* @brief Hover popup: zoomed picture plus a vertical icon nav strip beside stacked action pages.
|
||||||
|
*
|
||||||
|
* The board card smooth-zooms first; this panel then swaps in over it with oracle
|
||||||
|
* text and every right-click action, grouped by topic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CARDHOVERWIDGET_H
|
||||||
|
#define CARDHOVERWIDGET_H
|
||||||
|
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QSize>
|
||||||
|
#include <QTransform>
|
||||||
|
#include <functional>
|
||||||
|
#include <libcockatrice/card/printing/exact_card.h>
|
||||||
|
|
||||||
|
class CardInfoPictureWidget;
|
||||||
|
class CardInfoTextWidget;
|
||||||
|
class CardItem;
|
||||||
|
class CardState;
|
||||||
|
class PlayerGraphicsItem;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QHBoxLayout;
|
||||||
|
class QPushButton;
|
||||||
|
class QToolButton;
|
||||||
|
class QButtonGroup;
|
||||||
|
class QStackedWidget;
|
||||||
|
class QIcon;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
class QEnterEvent;
|
||||||
|
class QHideEvent;
|
||||||
|
class QPropertyAnimation;
|
||||||
|
class QResizeEvent;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
|
class CardHoverWidget : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CardHoverWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setCard(CardItem *card, PlayerGraphicsItem *player);
|
||||||
|
void clearCard();
|
||||||
|
bool hasCard() const;
|
||||||
|
CardItem *getCardItem() const
|
||||||
|
{
|
||||||
|
return currentCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
void positionNextTo(const QRectF &cardSceneRect, const QTransform &viewportTransform, const QWidget *viewport);
|
||||||
|
|
||||||
|
void showAnimated();
|
||||||
|
void hideAnimated();
|
||||||
|
|
||||||
|
/** @brief True while the panel is fading out towards a hide. */
|
||||||
|
bool isClosing() const;
|
||||||
|
|
||||||
|
/** @brief Refreshes the PT, counter, and annotation labels from the current card. */
|
||||||
|
void refreshDisplay();
|
||||||
|
|
||||||
|
bool isMouseOverWidget() const
|
||||||
|
{
|
||||||
|
return rect().contains(mapFromGlobal(QCursor::pos()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
void changeEvent(QEvent *event) override;
|
||||||
|
void enterEvent(QEnterEvent *event) override;
|
||||||
|
void leaveEvent(QEvent *event) override;
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
void hideEvent(QHideEvent *event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void hoverEntered();
|
||||||
|
void hoverLeft();
|
||||||
|
/** @brief Asks the scene to dismiss the panel before a modal dialog opens. */
|
||||||
|
void dismissRequested();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onCardChanged();
|
||||||
|
void onCardDestroyed();
|
||||||
|
void applyThemeStyle();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<CardItem> currentCard;
|
||||||
|
QPointer<PlayerGraphicsItem> currentPlayer;
|
||||||
|
ExactCard shownCard;
|
||||||
|
|
||||||
|
// Which side of the card the panel ended up on (drives the image-adjacent layout flip)
|
||||||
|
bool popupOnRight = true;
|
||||||
|
|
||||||
|
// Viewport area the panel covered at its last placement; used to repaint what the
|
||||||
|
// overlay window uncovers when it moves or hides.
|
||||||
|
QRect lastViewportRect;
|
||||||
|
|
||||||
|
// Coalesces rapid state-change bursts into a single refresh
|
||||||
|
QTimer *refreshTimer;
|
||||||
|
|
||||||
|
// Card image area (kept on the card-adjacent side) with overlaid controls
|
||||||
|
QHBoxLayout *mainLayout;
|
||||||
|
QWidget *imageContainer;
|
||||||
|
CardInfoPictureWidget *pic;
|
||||||
|
|
||||||
|
// Name bar overlay (top of card image)
|
||||||
|
QWidget *nameBarOverlay;
|
||||||
|
QLabel *nameLabel;
|
||||||
|
QLineEdit *nameEdit;
|
||||||
|
QLabel *annotationLabel;
|
||||||
|
|
||||||
|
// P/T overlay (bottom-right of card image): a compact value pill at rest that
|
||||||
|
// lifts its control rows out of itself while the P/T area is hovered.
|
||||||
|
QWidget *ptOverlay;
|
||||||
|
QWidget *ptControls;
|
||||||
|
QLabel *ptPillLabel;
|
||||||
|
bool ptExpanded = false;
|
||||||
|
QSize ptCompactSize;
|
||||||
|
QSize ptFullSize;
|
||||||
|
QLabel *ptPowerLabel;
|
||||||
|
QLabel *ptToughLabel;
|
||||||
|
QPushButton *btnIncP;
|
||||||
|
QPushButton *btnDecP;
|
||||||
|
QPushButton *btnIncT;
|
||||||
|
QPushButton *btnDecT;
|
||||||
|
QPushButton *btnSetPT;
|
||||||
|
QPushButton *btnResetPT;
|
||||||
|
|
||||||
|
// Vertical icon nav strip plus stacked content pages (no nested tab bars)
|
||||||
|
QWidget *sideBar;
|
||||||
|
QLabel *navNameLabel;
|
||||||
|
QToolButton *navInfoBtn;
|
||||||
|
QToolButton *navMainBtn;
|
||||||
|
QToolButton *navMoveBtn;
|
||||||
|
QToolButton *navCounterBtn;
|
||||||
|
QToolButton *navTokenBtn;
|
||||||
|
QButtonGroup *navGroup;
|
||||||
|
|
||||||
|
QStackedWidget *contentStack;
|
||||||
|
QWidget *infoPage;
|
||||||
|
QWidget *mainPage;
|
||||||
|
QWidget *movePage;
|
||||||
|
QWidget *counterPage;
|
||||||
|
QWidget *tokenPage;
|
||||||
|
QVBoxLayout *infoPageLayout;
|
||||||
|
QVBoxLayout *mainPageLayout;
|
||||||
|
QVBoxLayout *movePageLayout;
|
||||||
|
QVBoxLayout *counterPageLayout;
|
||||||
|
QVBoxLayout *tokenPageLayout;
|
||||||
|
CardInfoTextWidget *text;
|
||||||
|
|
||||||
|
// Window fade (sole reveal animation: per-layer opacity effects flashed black
|
||||||
|
// on scroll areas, so the whole panel fades as one)
|
||||||
|
QPropertyAnimation *fadeIn;
|
||||||
|
QPropertyAnimation *fadeOut;
|
||||||
|
|
||||||
|
void createImageArea();
|
||||||
|
void createNameBarOverlay();
|
||||||
|
void createPTOverlay();
|
||||||
|
void createNavBar();
|
||||||
|
QToolButton *createNavButton(const QString &title, const QIcon &icon, int pageIndex);
|
||||||
|
void createContentStack();
|
||||||
|
QWidget *makeStackPage(QVBoxLayout *&layout);
|
||||||
|
void showPage(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dismisses the panel, then runs an action that opens a modal dialog.
|
||||||
|
*
|
||||||
|
* A Qt::ToolTip window is always on top and holds the input grab, so a modal
|
||||||
|
* dialog opened from inside the panel lands behind it and cannot be
|
||||||
|
* activated. Hide the panel synchronously, then defer the action so the grab
|
||||||
|
* is released before the dialog's event loop starts.
|
||||||
|
*/
|
||||||
|
void runModalAction(const std::function<void()> &action);
|
||||||
|
|
||||||
|
QLabel *createSectionHeader(const QString &text, QWidget *parent);
|
||||||
|
QLabel *createNoteLabel(const QString &text, QWidget *parent);
|
||||||
|
|
||||||
|
void connectCardSignals();
|
||||||
|
void disconnectCardSignals();
|
||||||
|
void scheduleRefresh();
|
||||||
|
|
||||||
|
void rebuildActionsForZone();
|
||||||
|
/** @brief Whether the local player may edit the current card (own card, judge, writable zone). */
|
||||||
|
bool canModifyCurrentCard() const;
|
||||||
|
void buildMainTab(const QList<CardState *> &cardList, const QString &zoneName, bool canModify);
|
||||||
|
void buildMoveTab(const QList<CardState *> &cardList, const QString &zoneName, bool canModify);
|
||||||
|
void buildCounterTab(const QList<CardState *> &cardList, const QString &zoneName, bool canModify);
|
||||||
|
void buildTokenTab(CardItem *card, bool canModify);
|
||||||
|
void addRelatedViewButtons(QVBoxLayout *layout);
|
||||||
|
void updatePTDisplay();
|
||||||
|
void positionOverlays();
|
||||||
|
/** @brief Shows/hides the P/T control rows; the value pill stays at the bottom. */
|
||||||
|
void setPTExpanded(bool expanded);
|
||||||
|
/** @brief Anchors the pill on the printed P/T box, or the expanded stack above it. */
|
||||||
|
void applyPTOverlayGeometry();
|
||||||
|
/** @brief Resting pill geometry, in @c imageContainer coordinates. */
|
||||||
|
QRect compactPillRect() const;
|
||||||
|
/** @brief Pill plus halo: the only area that opens the rows, in @c pic coordinates. */
|
||||||
|
QRect ptOpenRegion() const;
|
||||||
|
/** @brief Bottom-right band the rows stay open in (never opens them), in @c pic coordinates. */
|
||||||
|
QRect ptHoverRegion() const;
|
||||||
|
/** @brief True while the cursor is over the overlay or the printed P/T area. */
|
||||||
|
bool isCursorOverPTArea() const;
|
||||||
|
/** @brief Re-measures the resting pill from its current text. */
|
||||||
|
QSize measureCompactPTSize() const;
|
||||||
|
/** @brief Repaints the viewport area this window covers and the one it just left. */
|
||||||
|
void invalidateCoveredArea();
|
||||||
|
|
||||||
|
void clearLayout(QLayout *layout);
|
||||||
|
|
||||||
|
QPushButton *createOverlayButton(const QString &text, const QString &tooltip, const std::function<void()> &slot);
|
||||||
|
QToolButton *createGridButton(const QString &text,
|
||||||
|
const QIcon &icon,
|
||||||
|
const std::function<void()> &slot,
|
||||||
|
QWidget *parent,
|
||||||
|
const QString &tooltip = QString());
|
||||||
|
QPushButton *createSmallButton(const QString &text, const std::function<void()> &slot, QWidget *parent = nullptr);
|
||||||
|
QPushButton *createSmallButton(const QString &text,
|
||||||
|
const QString &tooltip,
|
||||||
|
const std::function<void()> &slot,
|
||||||
|
QWidget *parent = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CARDHOVERWIDGET_H
|
||||||
|
|
@ -175,6 +175,8 @@ void CardInfoPictureWidget::setScaleFactor(const int scale)
|
||||||
void CardInfoPictureWidget::updatePixmap()
|
void CardInfoPictureWidget::updatePixmap()
|
||||||
{
|
{
|
||||||
pixmapDirty = true;
|
pixmapDirty = true;
|
||||||
|
// The artwork rect belongs to the pixmap that is about to be loaded.
|
||||||
|
artRectCache = QRect();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,6 +254,24 @@ void CardInfoPictureWidget::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
// Draw the pre-scaled pixmap directly
|
// Draw the pre-scaled pixmap directly
|
||||||
painter.drawPixmap(targetRect, finalPixmap);
|
painter.drawPixmap(targetRect, finalPixmap);
|
||||||
|
|
||||||
|
if (targetRect != artRectCache) {
|
||||||
|
artRectCache = targetRect;
|
||||||
|
// Overlays anchored on the artwork (rather than the widget) re-position on this.
|
||||||
|
emit artRectChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Rect of the drawn artwork inside this widget.
|
||||||
|
*
|
||||||
|
* Mirrors the target rect paintEvent() computes: the pixmap scaled with KeepAspectRatio and
|
||||||
|
* centred, after the optional sideways-layout rotation. Falls back to rect() until the first
|
||||||
|
* paint, which is the right answer for the usual portrait card.
|
||||||
|
*/
|
||||||
|
QRect CardInfoPictureWidget::artRect() const
|
||||||
|
{
|
||||||
|
return artRectCache.isEmpty() ? rect() : artRectCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,14 @@ public:
|
||||||
return exactCard;
|
return exactCard;
|
||||||
}
|
}
|
||||||
[[nodiscard]] QSize sizeHint() const override;
|
[[nodiscard]] QSize sizeHint() const override;
|
||||||
|
/**
|
||||||
|
* @brief Rect of the drawn artwork inside this widget.
|
||||||
|
*
|
||||||
|
* The pixmap is scaled with KeepAspectRatio and centred, and sideways-layout cards may be
|
||||||
|
* rotated, so this is usually smaller than rect(). Callers that overlay the picture (rather
|
||||||
|
* than the widget) must anchor on this. Falls back to rect() until the first paint.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] QRect artRect() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The size a card picture has at @p scaleFactor percent.
|
* @brief The size a card picture has at @p scaleFactor percent.
|
||||||
|
|
@ -60,6 +68,8 @@ signals:
|
||||||
void cardScaleFactorChanged(int _scale);
|
void cardScaleFactorChanged(int _scale);
|
||||||
void cardChanged(const ExactCard &card);
|
void cardChanged(const ExactCard &card);
|
||||||
void cardClicked(QMouseEvent *event, const ExactCard &card);
|
void cardClicked(QMouseEvent *event, const ExactCard &card);
|
||||||
|
/** @brief Emitted when the drawn artwork rect changes (size, scale factor, rotation, card). */
|
||||||
|
void artRectChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
@ -83,6 +93,8 @@ private:
|
||||||
double scaleFactor = 100;
|
double scaleFactor = 100;
|
||||||
QPixmap resizedPixmap;
|
QPixmap resizedPixmap;
|
||||||
bool pixmapDirty;
|
bool pixmapDirty;
|
||||||
|
/// Last drawn artwork rect, in widget coordinates; empty until the first paint.
|
||||||
|
QRect artRectCache;
|
||||||
bool hoverToZoomEnabled;
|
bool hoverToZoomEnabled;
|
||||||
bool raiseOnEnter;
|
bool raiseOnEnter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,10 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(QWidget *parent
|
||||||
searchEdit->setObjectName("searchEdit");
|
searchEdit->setObjectName("searchEdit");
|
||||||
searchEdit->setPlaceholderText(tr("Search by card name (or search expressions)"));
|
searchEdit->setPlaceholderText(tr("Search by card name (or search expressions)"));
|
||||||
searchEdit->setClearButtonEnabled(true);
|
searchEdit->setClearButtonEnabled(true);
|
||||||
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search")), QLineEdit::LeadingPosition);
|
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()),
|
||||||
auto help = searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/info")), QLineEdit::TrailingPosition);
|
QLineEdit::LeadingPosition);
|
||||||
|
auto help = searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/info"), IconTint::quiet()),
|
||||||
|
QLineEdit::TrailingPosition);
|
||||||
|
|
||||||
setFocusProxy(searchEdit);
|
setFocusProxy(searchEdit);
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
|
|
@ -83,7 +85,8 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(QWidget *parent
|
||||||
&DeckEditorDatabaseDisplayWidget::onRelatedCardClicked);
|
&DeckEditorDatabaseDisplayWidget::onRelatedCardClicked);
|
||||||
|
|
||||||
aAddCard = new QAction(QString(), this);
|
aAddCard = new QAction(QString(), this);
|
||||||
aAddCard->setIcon(loadThemedIcon(QStringLiteral("icons/arrow_right"), AppColor::Positive));
|
aAddCard->setIcon(loadThemedIcon(QStringLiteral("icons/arrow_right"),
|
||||||
|
IconTint(AppColor::Positive, IconEmphasis::Primary), IconStyle::Sticker));
|
||||||
connect(aAddCard, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
|
connect(aAddCard, &QAction::triggered, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
|
||||||
auto *tbAddCard = new QToolButton(this);
|
auto *tbAddCard = new QToolButton(this);
|
||||||
tbAddCard->setDefaultAction(aAddCard);
|
tbAddCard->setDefaultAction(aAddCard);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,8 @@ void DeckEditorFilterDockWidget::createFiltersDock()
|
||||||
connect(aClearFilterOne, &QAction::triggered, this, &DeckEditorFilterDockWidget::actClearFilterOne);
|
connect(aClearFilterOne, &QAction::triggered, this, &DeckEditorFilterDockWidget::actClearFilterOne);
|
||||||
|
|
||||||
aClearFilterAll = new QAction(QString(), this);
|
aClearFilterAll = new QAction(QString(), this);
|
||||||
aClearFilterAll->setIcon(loadThemedIcon(QStringLiteral("icons/clearsearch")));
|
aClearFilterAll->setIcon(
|
||||||
|
loadThemedIcon(QStringLiteral("icons/clearsearch"), AppColor::Negative, IconStyle::Sticker));
|
||||||
connect(aClearFilterAll, &QAction::triggered, this, &DeckEditorFilterDockWidget::actClearFilterAll);
|
connect(aClearFilterAll, &QAction::triggered, this, &DeckEditorFilterDockWidget::actClearFilterAll);
|
||||||
|
|
||||||
auto *filterDelOne = new QToolButton();
|
auto *filterDelOne = new QToolButton();
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@ WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
|
||||||
searchField = new LineEditUnfocusable;
|
searchField = new LineEditUnfocusable;
|
||||||
searchField->setObjectName("searchEdit");
|
searchField->setObjectName("searchEdit");
|
||||||
searchField->setPlaceholderText(tr("Search by set name, code, type, or release date"));
|
searchField->setPlaceholderText(tr("Search by set name, code, type, or release date"));
|
||||||
searchField->addAction(loadThemedIcon(QStringLiteral("icons/search")), LineEditUnfocusable::LeadingPosition);
|
searchField->addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()),
|
||||||
|
LineEditUnfocusable::LeadingPosition);
|
||||||
searchField->setClearButtonEnabled(true);
|
searchField->setClearButtonEnabled(true);
|
||||||
setFocusProxy(searchField);
|
setFocusProxy(searchField);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,8 @@ void SettingsView::setupUi()
|
||||||
// Search bar
|
// Search bar
|
||||||
searchEdit = new QLineEdit;
|
searchEdit = new QLineEdit;
|
||||||
searchEdit->setClearButtonEnabled(true);
|
searchEdit->setClearButtonEnabled(true);
|
||||||
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search")), QLineEdit::LeadingPosition);
|
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()),
|
||||||
|
QLineEdit::LeadingPosition);
|
||||||
searchEdit->installEventFilter(this);
|
searchEdit->installEventFilter(this);
|
||||||
connect(searchEdit, &QLineEdit::textChanged, this, &SettingsView::onSearchTextChanged);
|
connect(searchEdit, &QLineEdit::textChanged, this, &SettingsView::onSearchTextChanged);
|
||||||
searchEdit->setObjectName("settingsSearchEdit");
|
searchEdit->setObjectName("settingsSearchEdit");
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,8 @@ static QPixmap composePinBadgePixmap(const QSize &logicalSize, qreal devicePixel
|
||||||
// Inset the glyph so the backdrop reads as a badge around it, not as a border.
|
// Inset the glyph so the backdrop reads as a badge around it, not as a border.
|
||||||
const int inset = qRound(logicalSize.width() * 0.16);
|
const int inset = qRound(logicalSize.width() * 0.16);
|
||||||
const QSize glyphSize = logicalSize - QSize(inset * 2, inset * 2);
|
const QSize glyphSize = logicalSize - QSize(inset * 2, inset * 2);
|
||||||
const QPixmap glyph = loadThemedIcon(QStringLiteral("icons/pin")).pixmap(glyphSize, devicePixelRatio);
|
const QPixmap glyph =
|
||||||
|
loadThemedIcon(QStringLiteral("icons/pin"), AppColor::Marked).pixmap(glyphSize, devicePixelRatio);
|
||||||
if (glyph.isNull()) {
|
if (glyph.isNull()) {
|
||||||
// Let the caller fall back to the textual badge instead of drawing an empty panel.
|
// Let the caller fall back to the textual badge instead of drawing an empty panel.
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,14 @@ enum visualDeckStoragePromptForConversionIndex
|
||||||
visualDeckStoragePromptForConversionIndexAlways
|
visualDeckStoragePromptForConversionIndexAlways
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A corrupt or out-of-range stored trigger would otherwise select index -1 and leave
|
||||||
|
// the row half-hidden; clamp it back into the known trigger range.
|
||||||
|
static int clampHoverTrigger(int trigger)
|
||||||
|
{
|
||||||
|
return qBound(static_cast<int>(CardsDisplaySettings::HoverPanelTriggerHover), trigger,
|
||||||
|
static_cast<int>(CardsDisplaySettings::HoverPanelTriggerOff));
|
||||||
|
}
|
||||||
|
|
||||||
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
{
|
{
|
||||||
// general settings
|
// general settings
|
||||||
|
|
@ -154,6 +162,68 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
animationGroupBox = new QGroupBox;
|
animationGroupBox = new QGroupBox;
|
||||||
animationGroupBox->setLayout(animationGrid);
|
animationGroupBox->setLayout(animationGrid);
|
||||||
|
|
||||||
|
// hover panel settings
|
||||||
|
hoverZoomTriggerSelector.addItem(QString());
|
||||||
|
hoverZoomTriggerSelector.addItem(QString());
|
||||||
|
hoverZoomTriggerSelector.addItem(QString());
|
||||||
|
hoverZoomTriggerSelector.addItem(QString());
|
||||||
|
hoverZoomTriggerSelector.addItem(QString());
|
||||||
|
hoverZoomTriggerSelector.setCurrentIndex(
|
||||||
|
clampHoverTrigger(SettingsCache::instance().cardsDisplay().getHoverZoomTrigger()));
|
||||||
|
connect(&hoverZoomTriggerSelector, &QComboBox::currentIndexChanged, &SettingsCache::instance().cardsDisplay(),
|
||||||
|
&CardsDisplaySettings::setHoverZoomTrigger);
|
||||||
|
|
||||||
|
hoverPanelTriggerSelector.addItem(QString());
|
||||||
|
hoverPanelTriggerSelector.addItem(QString());
|
||||||
|
hoverPanelTriggerSelector.addItem(QString());
|
||||||
|
hoverPanelTriggerSelector.addItem(QString());
|
||||||
|
hoverPanelTriggerSelector.addItem(QString());
|
||||||
|
hoverPanelTriggerSelector.setCurrentIndex(
|
||||||
|
clampHoverTrigger(SettingsCache::instance().cardsDisplay().getHoverPanelTrigger()));
|
||||||
|
connect(&hoverPanelTriggerSelector, &QComboBox::currentIndexChanged, &SettingsCache::instance().cardsDisplay(),
|
||||||
|
&CardsDisplaySettings::setHoverPanelTrigger);
|
||||||
|
|
||||||
|
hoverPanelDoubleConfirmCheckBox.setChecked(SettingsCache::instance().cardsDisplay().getHoverPanelDoubleConfirm());
|
||||||
|
connect(&hoverPanelDoubleConfirmCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().cardsDisplay(),
|
||||||
|
&CardsDisplaySettings::setHoverPanelDoubleConfirm);
|
||||||
|
|
||||||
|
hoverZoomDelayBox.setRange(0, 5000);
|
||||||
|
hoverZoomDelayBox.setSingleStep(50);
|
||||||
|
hoverZoomDelayBox.setSuffix(" ms");
|
||||||
|
hoverZoomDelayBox.setValue(SettingsCache::instance().cardsDisplay().getHoverZoomDelayMs());
|
||||||
|
connect(&hoverZoomDelayBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance().cardsDisplay(),
|
||||||
|
&CardsDisplaySettings::setHoverZoomDelayMs);
|
||||||
|
|
||||||
|
hoverPanelDelayBox.setRange(0, 5000);
|
||||||
|
hoverPanelDelayBox.setSingleStep(50);
|
||||||
|
hoverPanelDelayBox.setSuffix(" ms");
|
||||||
|
hoverPanelDelayBox.setValue(SettingsCache::instance().cardsDisplay().getHoverPanelDelayMs());
|
||||||
|
connect(&hoverPanelDelayBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance().cardsDisplay(),
|
||||||
|
&CardsDisplaySettings::setHoverPanelDelayMs);
|
||||||
|
|
||||||
|
auto *hoverPanelGrid = new QGridLayout;
|
||||||
|
hoverPanelGrid->addWidget(&hoverZoomTriggerLabel, 0, 0);
|
||||||
|
hoverPanelGrid->addWidget(&hoverZoomTriggerSelector, 0, 1);
|
||||||
|
hoverPanelGrid->addWidget(&hoverPanelTriggerLabel, 1, 0);
|
||||||
|
hoverPanelGrid->addWidget(&hoverPanelTriggerSelector, 1, 1);
|
||||||
|
hoverPanelGrid->addWidget(&hoverPanelDoubleConfirmCheckBox, 2, 0, 1, 2);
|
||||||
|
hoverPanelGrid->addWidget(&hoverZoomDelayLabel, 3, 0);
|
||||||
|
hoverPanelGrid->addWidget(&hoverZoomDelayBox, 3, 1);
|
||||||
|
hoverPanelGrid->addWidget(&hoverPanelDelayLabel, 4, 0);
|
||||||
|
hoverPanelGrid->addWidget(&hoverPanelDelayBox, 4, 1);
|
||||||
|
hoverWheelNoteLabel.setWordWrap(true);
|
||||||
|
hoverPanelGrid->addWidget(&hoverWheelNoteLabel, 5, 0, 1, 2);
|
||||||
|
connect(&hoverZoomTriggerSelector, &QComboBox::currentIndexChanged, this,
|
||||||
|
&UserInterfaceSettingsPage::updateHoverPanelUiState);
|
||||||
|
connect(&hoverPanelTriggerSelector, &QComboBox::currentIndexChanged, this,
|
||||||
|
&UserInterfaceSettingsPage::updateHoverPanelUiState);
|
||||||
|
connect(&hoverPanelDoubleConfirmCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
|
||||||
|
&UserInterfaceSettingsPage::updateHoverPanelUiState);
|
||||||
|
updateHoverPanelUiState();
|
||||||
|
|
||||||
|
hoverPanelGroupBox = new QGroupBox;
|
||||||
|
hoverPanelGroupBox->setLayout(hoverPanelGrid);
|
||||||
|
|
||||||
// deck editor settings
|
// deck editor settings
|
||||||
openDeckInNewTabCheckBox.setChecked(SettingsCache::instance().deckEditor().getOpenDeckInNewTab());
|
openDeckInNewTabCheckBox.setChecked(SettingsCache::instance().deckEditor().getOpenDeckInNewTab());
|
||||||
connect(&openDeckInNewTabCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().deckEditor(),
|
connect(&openDeckInNewTabCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance().deckEditor(),
|
||||||
|
|
@ -293,6 +363,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
mainLayout->addWidget(notificationsGroupBox);
|
mainLayout->addWidget(notificationsGroupBox);
|
||||||
mainLayout->addWidget(animationGroupBox);
|
mainLayout->addWidget(animationGroupBox);
|
||||||
|
mainLayout->addWidget(hoverPanelGroupBox);
|
||||||
mainLayout->addWidget(deckEditorGroupBox);
|
mainLayout->addWidget(deckEditorGroupBox);
|
||||||
mainLayout->addWidget(replayGroupBox);
|
mainLayout->addWidget(replayGroupBox);
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
@ -351,6 +422,33 @@ void UserInterfaceSettingsPage::updateCommanderSpellbookUiState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserInterfaceSettingsPage::updateHoverPanelUiState()
|
||||||
|
{
|
||||||
|
// Phase timers only apply to the hover trigger; double-confirm only applies when
|
||||||
|
// both phases share one trigger (repeating it).
|
||||||
|
const auto hoverTrigger = CardsDisplaySettings::HoverPanelTriggerHover;
|
||||||
|
const auto wheelTrigger = CardsDisplaySettings::HoverPanelTriggerWheel;
|
||||||
|
const auto offTrigger = CardsDisplaySettings::HoverPanelTriggerOff;
|
||||||
|
const bool zoomOnHover = hoverZoomTriggerSelector.currentIndex() == hoverTrigger;
|
||||||
|
const bool panelOnHover = hoverPanelTriggerSelector.currentIndex() == hoverTrigger;
|
||||||
|
const bool anyOff =
|
||||||
|
hoverZoomTriggerSelector.currentIndex() == offTrigger || hoverPanelTriggerSelector.currentIndex() == offTrigger;
|
||||||
|
const bool sharedTrigger =
|
||||||
|
!anyOff && hoverZoomTriggerSelector.currentIndex() == hoverPanelTriggerSelector.currentIndex();
|
||||||
|
hoverZoomDelayLabel.setVisible(zoomOnHover);
|
||||||
|
hoverZoomDelayBox.setVisible(zoomOnHover);
|
||||||
|
hoverPanelDelayLabel.setVisible(panelOnHover);
|
||||||
|
hoverPanelDelayBox.setVisible(panelOnHover);
|
||||||
|
hoverPanelDoubleConfirmCheckBox.setEnabled(sharedTrigger);
|
||||||
|
const bool panelAuto = panelOnHover && !(sharedTrigger && hoverPanelDoubleConfirmCheckBox.isChecked());
|
||||||
|
hoverPanelDelayLabel.setEnabled(panelAuto);
|
||||||
|
hoverPanelDelayBox.setEnabled(panelAuto);
|
||||||
|
// The wheel trigger consumes wheel events over cards, so the board cannot scroll there.
|
||||||
|
const bool wheelBound = hoverZoomTriggerSelector.currentIndex() == wheelTrigger ||
|
||||||
|
hoverPanelTriggerSelector.currentIndex() == wheelTrigger;
|
||||||
|
hoverWheelNoteLabel.setVisible(wheelBound);
|
||||||
|
}
|
||||||
|
|
||||||
void UserInterfaceSettingsPage::retranslateUi()
|
void UserInterfaceSettingsPage::retranslateUi()
|
||||||
{
|
{
|
||||||
generalGroupBox->setTitle(tr("General interface settings"));
|
generalGroupBox->setTitle(tr("General interface settings"));
|
||||||
|
|
@ -380,6 +478,22 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
lifeCounterAnimationsCheckBox.setText(tr("Life counter flash"));
|
lifeCounterAnimationsCheckBox.setText(tr("Life counter flash"));
|
||||||
battlefieldFlashCheckBox.setText(tr("Battlefield flash on damage"));
|
battlefieldFlashCheckBox.setText(tr("Battlefield flash on damage"));
|
||||||
|
|
||||||
|
hoverPanelGroupBox->setTitle(tr("Hover panel settings"));
|
||||||
|
hoverPanelTriggerLabel.setText(tr("Show the card panel on:"));
|
||||||
|
hoverZoomTriggerLabel.setText(tr("Zoom the card on:"));
|
||||||
|
for (auto *selector : {&hoverPanelTriggerSelector, &hoverZoomTriggerSelector}) {
|
||||||
|
selector->setItemText(CardsDisplaySettings::HoverPanelTriggerHover, tr("Hover"));
|
||||||
|
selector->setItemText(CardsDisplaySettings::HoverPanelTriggerRightClick, tr("Right-click"));
|
||||||
|
selector->setItemText(CardsDisplaySettings::HoverPanelTriggerWheel, tr("Mouse wheel"));
|
||||||
|
selector->setItemText(CardsDisplaySettings::HoverPanelTriggerShortcut, tr("Keyboard shortcut"));
|
||||||
|
selector->setItemText(CardsDisplaySettings::HoverPanelTriggerOff, tr("Off"));
|
||||||
|
}
|
||||||
|
hoverPanelDoubleConfirmCheckBox.setText(tr("Zoom first; repeat the action to show the panel"));
|
||||||
|
hoverZoomDelayLabel.setText(tr("Time before the zoom kicks in:"));
|
||||||
|
hoverPanelDelayLabel.setText(tr("Time before the tab panel shows up:"));
|
||||||
|
hoverWheelNoteLabel.setText(
|
||||||
|
tr("Note: the mouse wheel action replaces board scrolling over cards; scroll up to zoom back out."));
|
||||||
|
|
||||||
deckEditorGroupBox->setTitle(tr("Deck editor/storage settings"));
|
deckEditorGroupBox->setTitle(tr("Deck editor/storage settings"));
|
||||||
openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default"));
|
openDeckInNewTabCheckBox.setText(tr("Open deck in new tab by default"));
|
||||||
visualDeckEditorShowCardCountsCheckBox.setText(tr("Show card counts in Visual Deck Editor"));
|
visualDeckEditorShowCardCountsCheckBox.setText(tr("Show card counts in Visual Deck Editor"));
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ private slots:
|
||||||
void enableAllAnimations();
|
void enableAllAnimations();
|
||||||
void disableAllAnimations();
|
void disableAllAnimations();
|
||||||
void updateCommanderSpellbookUiState();
|
void updateCommanderSpellbookUiState();
|
||||||
|
void updateHoverPanelUiState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCheckBox doubleClickToPlayCheckBox;
|
QCheckBox doubleClickToPlayCheckBox;
|
||||||
|
|
@ -47,6 +48,17 @@ private:
|
||||||
QCheckBox lifeCounterAnimationsCheckBox;
|
QCheckBox lifeCounterAnimationsCheckBox;
|
||||||
QCheckBox battlefieldFlashCheckBox;
|
QCheckBox battlefieldFlashCheckBox;
|
||||||
|
|
||||||
|
QLabel hoverPanelTriggerLabel;
|
||||||
|
QComboBox hoverPanelTriggerSelector;
|
||||||
|
QLabel hoverZoomTriggerLabel;
|
||||||
|
QComboBox hoverZoomTriggerSelector;
|
||||||
|
QCheckBox hoverPanelDoubleConfirmCheckBox;
|
||||||
|
QLabel hoverZoomDelayLabel;
|
||||||
|
QSpinBox hoverZoomDelayBox;
|
||||||
|
QLabel hoverPanelDelayLabel;
|
||||||
|
QSpinBox hoverPanelDelayBox;
|
||||||
|
QLabel hoverWheelNoteLabel;
|
||||||
|
|
||||||
QCheckBox openDeckInNewTabCheckBox;
|
QCheckBox openDeckInNewTabCheckBox;
|
||||||
QLabel visualDeckStoragePromptForConversionLabel;
|
QLabel visualDeckStoragePromptForConversionLabel;
|
||||||
QComboBox visualDeckStoragePromptForConversionSelector;
|
QComboBox visualDeckStoragePromptForConversionSelector;
|
||||||
|
|
@ -69,6 +81,7 @@ private:
|
||||||
QGroupBox *generalGroupBox;
|
QGroupBox *generalGroupBox;
|
||||||
QGroupBox *notificationsGroupBox;
|
QGroupBox *notificationsGroupBox;
|
||||||
QGroupBox *animationGroupBox;
|
QGroupBox *animationGroupBox;
|
||||||
|
QGroupBox *hoverPanelGroupBox;
|
||||||
QGroupBox *deckEditorGroupBox;
|
QGroupBox *deckEditorGroupBox;
|
||||||
QGroupBox *replayGroupBox;
|
QGroupBox *replayGroupBox;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor,
|
||||||
connect(aDeleteRemoteDeck, &QAction::triggered, this, &TabDeckStorage::actDeleteRemoteDeck);
|
connect(aDeleteRemoteDeck, &QAction::triggered, this, &TabDeckStorage::actDeleteRemoteDeck);
|
||||||
|
|
||||||
aShareDecks = new QAction(this);
|
aShareDecks = new QAction(this);
|
||||||
aShareDecks->setIcon(loadThemedIcon(QStringLiteral("icons/share")));
|
aShareDecks->setIcon(loadThemedIcon(QStringLiteral("icons/share"), AppColor::Informational));
|
||||||
connect(aShareDecks, &QAction::triggered, this, &TabDeckStorage::actShareDecks);
|
connect(aShareDecks, &QAction::triggered, this, &TabDeckStorage::actShareDecks);
|
||||||
|
|
||||||
aPublishDeck = new QAction(this);
|
aPublishDeck = new QAction(this);
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ QGroupBox *TabReplays::createRightLayout()
|
||||||
loadThemedIcon(QStringLiteral("icons/remove_row"), AppColor::Negative, IconStyle::Sticker));
|
loadThemedIcon(QStringLiteral("icons/remove_row"), AppColor::Negative, IconStyle::Sticker));
|
||||||
connect(aDeleteRemoteReplay, &QAction::triggered, this, &TabReplays::actDeleteRemoteReplay);
|
connect(aDeleteRemoteReplay, &QAction::triggered, this, &TabReplays::actDeleteRemoteReplay);
|
||||||
aGetReplayCode = new QAction(this);
|
aGetReplayCode = new QAction(this);
|
||||||
aGetReplayCode->setIcon(loadThemedIcon(QStringLiteral("icons/share")));
|
aGetReplayCode->setIcon(loadThemedIcon(QStringLiteral("icons/share"), AppColor::Informational));
|
||||||
connect(aGetReplayCode, &QAction::triggered, this, &TabReplays::actGetReplayCode);
|
connect(aGetReplayCode, &QAction::triggered, this, &TabReplays::actGetReplayCode);
|
||||||
|
|
||||||
aSubmitReplayCode = new QAction(this);
|
aSubmitReplayCode = new QAction(this);
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,15 @@ VisualDatabaseDisplayFilterToolbarWidget::VisualDatabaseDisplayFilterToolbarWidg
|
||||||
sortGroupBox = new QGroupBox(this);
|
sortGroupBox = new QGroupBox(this);
|
||||||
filterGroupBox = new QGroupBox(this);
|
filterGroupBox = new QGroupBox(this);
|
||||||
|
|
||||||
auto scalePixmap = [](const QString &prefix) { return loadThemedIcon(prefix).pixmap({20, 20}); };
|
auto scalePixmap = [](const QString &prefix, const IconTint &tint = {}) {
|
||||||
|
return loadThemedIcon(prefix, tint).pixmap({20, 20});
|
||||||
|
};
|
||||||
|
|
||||||
sortByLabel = new QLabel(this);
|
sortByLabel = new QLabel(this);
|
||||||
sortByLabel->setPixmap(scalePixmap("icons/sort_arrow_down"));
|
sortByLabel->setPixmap(scalePixmap("icons/sort_arrow_down", AppColor::Informational));
|
||||||
|
|
||||||
filterByLabel = new QLabel(this);
|
filterByLabel = new QLabel(this);
|
||||||
filterByLabel->setPixmap(scalePixmap("icons/filter"));
|
filterByLabel->setPixmap(scalePixmap("icons/filter", AppColor::Informational));
|
||||||
|
|
||||||
sortColumnCombo = new QComboBox(this);
|
sortColumnCombo = new QComboBox(this);
|
||||||
sortColumnCombo->setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy::AdjustToContents);
|
sortColumnCombo->setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy::AdjustToContents);
|
||||||
|
|
@ -90,22 +92,23 @@ VisualDatabaseDisplayFilterToolbarWidget::VisualDatabaseDisplayFilterToolbarWidg
|
||||||
});
|
});
|
||||||
|
|
||||||
quickFilterSaveLoadWidget = new SettingsButtonWidget(this);
|
quickFilterSaveLoadWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterSaveLoadWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/floppy_disk")));
|
quickFilterSaveLoadWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/floppy_disk"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterNameWidget = new SettingsButtonWidget(this);
|
quickFilterNameWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterNameWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/pen_to_square")));
|
quickFilterNameWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/pen_to_square"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterMainTypeWidget = new SettingsButtonWidget(this);
|
quickFilterMainTypeWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterMainTypeWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/circle_half_stroke")));
|
quickFilterMainTypeWidget->setButtonIcon(
|
||||||
|
loadThemedIcon(QStringLiteral("icons/circle_half_stroke"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterSubTypeWidget = new SettingsButtonWidget(this);
|
quickFilterSubTypeWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterSubTypeWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/dragon")));
|
quickFilterSubTypeWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/dragon"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterSetWidget = new SettingsButtonWidget(this);
|
quickFilterSetWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterSetWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scroll")));
|
quickFilterSetWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scroll"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterFormatLegalityWidget = new SettingsButtonWidget(this);
|
quickFilterFormatLegalityWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterFormatLegalityWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scales")));
|
quickFilterFormatLegalityWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scales"), IconTint::primary()));
|
||||||
|
|
||||||
quickFilterTagWidget = new SettingsButtonWidget(this);
|
quickFilterTagWidget = new SettingsButtonWidget(this);
|
||||||
quickFilterTagWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/tags")));
|
quickFilterTagWidget->setButtonIcon(loadThemedIcon(QStringLiteral("icons/tags")));
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,10 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
||||||
searchEdit->setObjectName("searchEdit");
|
searchEdit->setObjectName("searchEdit");
|
||||||
searchEdit->setPlaceholderText(tr("Search by card name (or search expressions)"));
|
searchEdit->setPlaceholderText(tr("Search by card name (or search expressions)"));
|
||||||
searchEdit->setClearButtonEnabled(true);
|
searchEdit->setClearButtonEnabled(true);
|
||||||
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search")), QLineEdit::LeadingPosition);
|
searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()),
|
||||||
auto help = searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/info")), QLineEdit::TrailingPosition);
|
QLineEdit::LeadingPosition);
|
||||||
|
auto help = searchEdit->addAction(loadThemedIcon(QStringLiteral("icons/info"), AppColor::Informational),
|
||||||
|
QLineEdit::TrailingPosition);
|
||||||
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(searchEdit); });
|
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(searchEdit); });
|
||||||
|
|
||||||
setFocusProxy(searchEdit);
|
setFocusProxy(searchEdit);
|
||||||
|
|
@ -156,7 +158,7 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
||||||
|
|
||||||
clearFilterWidget = new QToolButton();
|
clearFilterWidget = new QToolButton();
|
||||||
clearFilterWidget->setFixedSize(32, 32);
|
clearFilterWidget->setFixedSize(32, 32);
|
||||||
clearFilterWidget->setIcon(loadThemedIcon(QStringLiteral("icons/delete"), AppColor::Negative));
|
clearFilterWidget->setIcon(loadThemedIcon(QStringLiteral("icons/delete"), AppColor::Negative, IconStyle::Sticker));
|
||||||
connect(clearFilterWidget, &QToolButton::clicked, this, [this] {
|
connect(clearFilterWidget, &QToolButton::clicked, this, [this] {
|
||||||
filterModel->blockSignals(true);
|
filterModel->blockSignals(true);
|
||||||
filterModel->filterTree()->blockSignals(true);
|
filterModel->filterTree()->blockSignals(true);
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ void VisualDeckDisplayOptionsWidget::updateDisplayTypeButton()
|
||||||
switch (currentDisplayType) {
|
switch (currentDisplayType) {
|
||||||
case DisplayType::Flat:
|
case DisplayType::Flat:
|
||||||
displayTypeButton->setButtonText(tr("Toggle Layout: Flat"));
|
displayTypeButton->setButtonText(tr("Toggle Layout: Flat"));
|
||||||
displayTypeButton->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scroll")));
|
displayTypeButton->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scroll"), IconTint::primary()));
|
||||||
break;
|
break;
|
||||||
case DisplayType::Overlap:
|
case DisplayType::Overlap:
|
||||||
displayTypeButton->setButtonText(tr("Toggle Layout: Overlap"));
|
displayTypeButton->setButtonText(tr("Toggle Layout: Overlap"));
|
||||||
displayTypeButton->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scales")));
|
displayTypeButton->setButtonIcon(loadThemedIcon(QStringLiteral("icons/scales"), IconTint::primary()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,10 @@ VisualDeckStorageSearchWidget::VisualDeckStorageSearchWidget(QWidget *parent) :
|
||||||
searchBar = new QLineEdit(this);
|
searchBar = new QLineEdit(this);
|
||||||
searchBar->setPlaceholderText(tr("Search by filename (or search expression)"));
|
searchBar->setPlaceholderText(tr("Search by filename (or search expression)"));
|
||||||
searchBar->setClearButtonEnabled(true);
|
searchBar->setClearButtonEnabled(true);
|
||||||
searchBar->addAction(loadThemedIcon(QStringLiteral("icons/search")), QLineEdit::LeadingPosition);
|
searchBar->addAction(loadThemedIcon(QStringLiteral("icons/search"), IconTint::quiet()), QLineEdit::LeadingPosition);
|
||||||
|
|
||||||
auto help = searchBar->addAction(loadThemedIcon(QStringLiteral("icons/info")), QLineEdit::TrailingPosition);
|
auto help = searchBar->addAction(loadThemedIcon(QStringLiteral("icons/info"), IconTint::quiet()),
|
||||||
|
QLineEdit::TrailingPosition);
|
||||||
connect(help, &QAction::triggered, this, [this] { createDeckSearchSyntaxHelpWindow(searchBar); });
|
connect(help, &QAction::triggered, this, [this] { createDeckSearchSyntaxHelpWindow(searchBar); });
|
||||||
|
|
||||||
layout->addWidget(searchBar);
|
layout->addWidget(searchBar);
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ VisualDeckStorageWidget::VisualDeckStorageWidget(QWidget *parent) : QWidget(pare
|
||||||
connect(refreshButton, &QPushButton::clicked, this, &VisualDeckStorageWidget::refreshIfPossible);
|
connect(refreshButton, &QPushButton::clicked, this, &VisualDeckStorageWidget::refreshIfPossible);
|
||||||
|
|
||||||
shareButton = new QToolButton(this);
|
shareButton = new QToolButton(this);
|
||||||
shareButton->setIcon(loadThemedIcon(QStringLiteral("icons/share")));
|
shareButton->setIcon(loadThemedIcon(QStringLiteral("icons/share"), AppColor::Informational));
|
||||||
shareButton->setFixedSize(32, 32);
|
shareButton->setFixedSize(32, 32);
|
||||||
shareButton->setVisible(false);
|
shareButton->setVisible(false);
|
||||||
connect(shareButton, &QPushButton::clicked, this, &VisualDeckStorageWidget::shareRequested);
|
connect(shareButton, &QPushButton::clicked, this, &VisualDeckStorageWidget::shareRequested);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public:
|
||||||
[[nodiscard]] virtual bool getArrowDrawAnimation() const = 0;
|
[[nodiscard]] virtual bool getArrowDrawAnimation() const = 0;
|
||||||
[[nodiscard]] virtual bool getAutoRotateSidewaysLayoutCards() const = 0;
|
[[nodiscard]] virtual bool getAutoRotateSidewaysLayoutCards() const = 0;
|
||||||
[[nodiscard]] virtual bool getScaleCards() const = 0;
|
[[nodiscard]] virtual bool getScaleCards() const = 0;
|
||||||
|
[[nodiscard]] virtual int getHoverPanelTrigger() const = 0;
|
||||||
|
[[nodiscard]] virtual int getHoverZoomTrigger() const = 0;
|
||||||
|
[[nodiscard]] virtual bool getHoverPanelDoubleConfirm() const = 0;
|
||||||
|
[[nodiscard]] virtual int getHoverZoomDelayMs() const = 0;
|
||||||
|
[[nodiscard]] virtual int getHoverPanelDelayMs() const = 0;
|
||||||
[[nodiscard]] virtual int getStackCardOverlapPercent() const = 0;
|
[[nodiscard]] virtual int getStackCardOverlapPercent() const = 0;
|
||||||
[[nodiscard]] virtual int getCardInfoViewMode() const = 0;
|
[[nodiscard]] virtual int getCardInfoViewMode() const = 0;
|
||||||
[[nodiscard]] virtual int getVisualDeckStorageCardSize() const = 0;
|
[[nodiscard]] virtual int getVisualDeckStorageCardSize() const = 0;
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,35 @@ bool CardsDisplaySettings::getScaleCards() const
|
||||||
return getValue("scaleCards", QString(), QString(), true).toBool();
|
return getValue("scaleCards", QString(), QString(), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CardsDisplaySettings::getHoverPanelTrigger() const
|
||||||
|
{
|
||||||
|
// Off by default: the panel is new, so it is opt-in.
|
||||||
|
return getValue("hoverPanelTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerOff)).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CardsDisplaySettings::getHoverZoomTrigger() const
|
||||||
|
{
|
||||||
|
// Off by default: the smooth hover zoom is opt-in. With no trigger configured,
|
||||||
|
// hovering keeps the historical 1.1x scale (AbstractCardItem::setHoverHighlighted)
|
||||||
|
// instead of the smooth zoom to the hover panel size.
|
||||||
|
return getValue("hoverZoomTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerOff)).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CardsDisplaySettings::getHoverPanelDoubleConfirm() const
|
||||||
|
{
|
||||||
|
return getValue("hoverPanelDoubleConfirm", QString(), QString(), false).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CardsDisplaySettings::getHoverZoomDelayMs() const
|
||||||
|
{
|
||||||
|
return getValue("hoverZoomDelayMs", QString(), QString(), 400).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CardsDisplaySettings::getHoverPanelDelayMs() const
|
||||||
|
{
|
||||||
|
return getValue("hoverPanelDelayMs", QString(), QString(), 200).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
int CardsDisplaySettings::getStackCardOverlapPercent() const
|
int CardsDisplaySettings::getStackCardOverlapPercent() const
|
||||||
{
|
{
|
||||||
return getValue("verticalCardOverlapPercent", QString(), QString(), 33).toInt();
|
return getValue("verticalCardOverlapPercent", QString(), QString(), 33).toInt();
|
||||||
|
|
@ -188,6 +217,36 @@ void CardsDisplaySettings::setCardScaling(bool _scaleCards)
|
||||||
setValue(_scaleCards, "scaleCards");
|
setValue(_scaleCards, "scaleCards");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardsDisplaySettings::setHoverPanelTrigger(int _trigger)
|
||||||
|
{
|
||||||
|
setValue(_trigger, "hoverPanelTrigger");
|
||||||
|
emit hoverPanelTriggerChanged(_trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardsDisplaySettings::setHoverZoomTrigger(int _trigger)
|
||||||
|
{
|
||||||
|
setValue(_trigger, "hoverZoomTrigger");
|
||||||
|
emit hoverZoomTriggerChanged(_trigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardsDisplaySettings::setHoverPanelDoubleConfirm(bool _doubleConfirm)
|
||||||
|
{
|
||||||
|
setValue(_doubleConfirm, "hoverPanelDoubleConfirm");
|
||||||
|
emit hoverPanelDoubleConfirmChanged(_doubleConfirm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardsDisplaySettings::setHoverZoomDelayMs(int _ms)
|
||||||
|
{
|
||||||
|
setValue(_ms, "hoverZoomDelayMs");
|
||||||
|
emit hoverZoomDelayMsChanged(_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CardsDisplaySettings::setHoverPanelDelayMs(int _ms)
|
||||||
|
{
|
||||||
|
setValue(_ms, "hoverPanelDelayMs");
|
||||||
|
emit hoverPanelDelayMsChanged(_ms);
|
||||||
|
}
|
||||||
|
|
||||||
void CardsDisplaySettings::setStackCardOverlapPercent(int _verticalCardOverlapPercent)
|
void CardsDisplaySettings::setStackCardOverlapPercent(int _verticalCardOverlapPercent)
|
||||||
{
|
{
|
||||||
setValue(_verticalCardOverlapPercent, "verticalCardOverlapPercent");
|
setValue(_verticalCardOverlapPercent, "verticalCardOverlapPercent");
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,18 @@ class CardsDisplaySettings : public SettingsManager, public ICardsDisplaySetting
|
||||||
friend class SettingsCache;
|
friend class SettingsCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// What can summon the hover zoom or panel. Stored as int; values are the
|
||||||
|
/// serialization contract, so never reorder or renumber.
|
||||||
|
enum HoverPanelTrigger
|
||||||
|
{
|
||||||
|
HoverPanelTriggerHover = 0,
|
||||||
|
HoverPanelTriggerRightClick = 1,
|
||||||
|
HoverPanelTriggerWheel = 2,
|
||||||
|
HoverPanelTriggerShortcut = 3,
|
||||||
|
/// Never fires. The hover zoom and panel are opt-in, so this is their default.
|
||||||
|
HoverPanelTriggerOff = 4
|
||||||
|
};
|
||||||
|
|
||||||
[[nodiscard]] bool getDisplayCardNames() const override;
|
[[nodiscard]] bool getDisplayCardNames() const override;
|
||||||
[[nodiscard]] bool getRoundCardCorners() const override;
|
[[nodiscard]] bool getRoundCardCorners() const override;
|
||||||
[[nodiscard]] bool getOverrideAllCardArtWithPersonalPreference() const override;
|
[[nodiscard]] bool getOverrideAllCardArtWithPersonalPreference() const override;
|
||||||
|
|
@ -26,6 +38,16 @@ public:
|
||||||
[[nodiscard]] bool getArrowDrawAnimation() const override;
|
[[nodiscard]] bool getArrowDrawAnimation() const override;
|
||||||
[[nodiscard]] bool getAutoRotateSidewaysLayoutCards() const override;
|
[[nodiscard]] bool getAutoRotateSidewaysLayoutCards() const override;
|
||||||
[[nodiscard]] bool getScaleCards() const override;
|
[[nodiscard]] bool getScaleCards() const override;
|
||||||
|
/// What summons the in-game card hover panel (a HoverPanelTrigger value).
|
||||||
|
[[nodiscard]] int getHoverPanelTrigger() const override;
|
||||||
|
/// What zooms the hovered card (a HoverPanelTrigger value). Zoom and panel triggers are independent.
|
||||||
|
[[nodiscard]] int getHoverZoomTrigger() const override;
|
||||||
|
/// When true, the trigger first only zooms; repeating it shows the panel.
|
||||||
|
[[nodiscard]] bool getHoverPanelDoubleConfirm() const override;
|
||||||
|
/// Hover dwell before the zoom kicks in (ms). Only used with the hover trigger.
|
||||||
|
[[nodiscard]] int getHoverZoomDelayMs() const override;
|
||||||
|
/// Wait after the zoom before the tab panel shows (ms). Hover trigger, one-step only.
|
||||||
|
[[nodiscard]] int getHoverPanelDelayMs() const override;
|
||||||
[[nodiscard]] int getStackCardOverlapPercent() const override;
|
[[nodiscard]] int getStackCardOverlapPercent() const override;
|
||||||
[[nodiscard]] int getCardInfoViewMode() const override;
|
[[nodiscard]] int getCardInfoViewMode() const override;
|
||||||
[[nodiscard]] int getVisualDeckStorageCardSize() const override;
|
[[nodiscard]] int getVisualDeckStorageCardSize() const override;
|
||||||
|
|
@ -49,6 +71,11 @@ public:
|
||||||
void setArrowDrawAnimation(bool _arrowDrawAnimation);
|
void setArrowDrawAnimation(bool _arrowDrawAnimation);
|
||||||
void setAutoRotateSidewaysLayoutCards(bool _autoRotateSidewaysLayoutCards);
|
void setAutoRotateSidewaysLayoutCards(bool _autoRotateSidewaysLayoutCards);
|
||||||
void setCardScaling(bool _scaleCards);
|
void setCardScaling(bool _scaleCards);
|
||||||
|
void setHoverPanelTrigger(int _trigger);
|
||||||
|
void setHoverZoomTrigger(int _trigger);
|
||||||
|
void setHoverPanelDoubleConfirm(bool _doubleConfirm);
|
||||||
|
void setHoverZoomDelayMs(int _ms);
|
||||||
|
void setHoverPanelDelayMs(int _ms);
|
||||||
void setStackCardOverlapPercent(int _verticalCardOverlapPercent);
|
void setStackCardOverlapPercent(int _verticalCardOverlapPercent);
|
||||||
void setCardInfoViewMode(int _viewMode);
|
void setCardInfoViewMode(int _viewMode);
|
||||||
void setVisualDeckStorageCardSize(int _cardSize);
|
void setVisualDeckStorageCardSize(int _cardSize);
|
||||||
|
|
@ -78,6 +105,11 @@ signals:
|
||||||
void sampleHandSizeChanged(int amount);
|
void sampleHandSizeChanged(int amount);
|
||||||
void cardLangChanged(const QString &lang);
|
void cardLangChanged(const QString &lang);
|
||||||
void cardSearchLanguageChanged(int cardSearchLanguage);
|
void cardSearchLanguageChanged(int cardSearchLanguage);
|
||||||
|
void hoverPanelTriggerChanged(int trigger);
|
||||||
|
void hoverZoomTriggerChanged(int trigger);
|
||||||
|
void hoverPanelDoubleConfirmChanged(bool doubleConfirm);
|
||||||
|
void hoverZoomDelayMsChanged(int ms);
|
||||||
|
void hoverPanelDelayMsChanged(int ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CardsDisplaySettings(const QString &settingPath, QObject *parent = nullptr);
|
explicit CardsDisplaySettings(const QString &settingPath, QObject *parent = nullptr);
|
||||||
|
|
|
||||||
|
|
@ -683,6 +683,77 @@ TEST_F(SettingsDefaultsTest, CardsDisplay_ArrowDrawAnimation_Default)
|
||||||
ASSERT_EQ(s.getArrowDrawAnimation(), true);
|
ASSERT_EQ(s.getArrowDrawAnimation(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_Default)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
// Off by default: the panel is opt-in on upgrade.
|
||||||
|
ASSERT_EQ(s.getHoverPanelTrigger(), CardsDisplaySettings::HoverPanelTriggerOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_SetAndGet)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
s.setHoverPanelTrigger(2);
|
||||||
|
ASSERT_EQ(s.getHoverPanelTrigger(), 2);
|
||||||
|
s.setHoverPanelTrigger(0);
|
||||||
|
ASSERT_EQ(s.getHoverPanelTrigger(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_Default)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
// Off by default: the smooth hover zoom is opt-in on upgrade.
|
||||||
|
ASSERT_EQ(s.getHoverZoomTrigger(), CardsDisplaySettings::HoverPanelTriggerOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_SetAndGet)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
s.setHoverZoomTrigger(1);
|
||||||
|
ASSERT_EQ(s.getHoverZoomTrigger(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelDoubleConfirm_Default)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
ASSERT_EQ(s.getHoverPanelDoubleConfirm(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelDoubleConfirm_SetAndGet)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
s.setHoverPanelDoubleConfirm(true);
|
||||||
|
ASSERT_EQ(s.getHoverPanelDoubleConfirm(), true);
|
||||||
|
s.setHoverPanelDoubleConfirm(false);
|
||||||
|
ASSERT_EQ(s.getHoverPanelDoubleConfirm(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomDelayMs_Default)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
ASSERT_EQ(s.getHoverZoomDelayMs(), 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomDelayMs_SetAndGet)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
s.setHoverZoomDelayMs(750);
|
||||||
|
ASSERT_EQ(s.getHoverZoomDelayMs(), 750);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelDelayMs_Default)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
ASSERT_EQ(s.getHoverPanelDelayMs(), 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelDelayMs_SetAndGet)
|
||||||
|
{
|
||||||
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
s.setHoverPanelDelayMs(0);
|
||||||
|
ASSERT_EQ(s.getHoverPanelDelayMs(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(SettingsDefaultsTest, CardsDisplay_CardLang_Default)
|
TEST_F(SettingsDefaultsTest, CardsDisplay_CardLang_Default)
|
||||||
{
|
{
|
||||||
CardsDisplaySettings s(settingsPath, nullptr);
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,12 @@ template <typename Render> QPixmap renderAtDpr(const QSize &logicalSize, qreal d
|
||||||
* @brief Writes one semantic-tint sheet per shipped palette theme.
|
* @brief Writes one semantic-tint sheet per shipped palette theme.
|
||||||
*
|
*
|
||||||
* The theme files are the only place the shipped tones live, so each sheet is
|
* The theme files are the only place the shipped tones live, so each sheet is
|
||||||
* rendered from the palette the theme actually ships: both semantic families,
|
* rendered from the palette the theme actually ships: all three semantic
|
||||||
* three glyphs each, at the two sizes the UI uses, on the window and button
|
* families, three glyphs each, at the two sizes the UI uses, on the window and
|
||||||
* surfaces the contrast is measured against. A disabled row closes each family
|
* button surfaces the contrast is measured against. A disabled row closes each
|
||||||
* so the enabled/disabled order is visible next to the tone that carries it.
|
* family so the enabled/disabled order is visible next to the tone that carries
|
||||||
|
* it. A theme that does not author Informational falls back to the scheme
|
||||||
|
* default, which is what the client paints.
|
||||||
*/
|
*/
|
||||||
TEST(IconTintPreview, WritesOneSheetPerShippedTheme)
|
TEST(IconTintPreview, WritesOneSheetPerShippedTheme)
|
||||||
{
|
{
|
||||||
|
|
@ -100,6 +102,10 @@ TEST(IconTintPreview, WritesOneSheetPerShippedTheme)
|
||||||
const QList<Family> families = {
|
const QList<Family> families = {
|
||||||
{"Positive", AppColor::Positive, {"increment", "ready_start", "arrow_up"}},
|
{"Positive", AppColor::Positive, {"increment", "ready_start", "arrow_up"}},
|
||||||
{"Negative", AppColor::Negative, {"decrement", "not_ready_start", "remove_row"}},
|
{"Negative", AppColor::Negative, {"decrement", "not_ready_start", "remove_row"}},
|
||||||
|
{"Informational", AppColor::Informational, {"arrow_right", "view", "arrow_to_top"}},
|
||||||
|
{"Hidden", AppColor::Hidden, {"view", "arrow_right", "swap"}},
|
||||||
|
{"Marked", AppColor::Marked, {"pencil", "share", "pin"}},
|
||||||
|
{"Movement", AppColor::Movement, {"arrow_to_top", "arrow_to_bottom", "arrow_down"}},
|
||||||
};
|
};
|
||||||
const QStringList themes = {
|
const QStringList themes = {
|
||||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QFontMetrics>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
@ -69,7 +70,7 @@ template <typename Render> QPixmap renderAtDpr(const QSize &logicalSize, qreal d
|
||||||
* @brief Writes one badge/sticker sheet per shipped palette theme.
|
* @brief Writes one badge/sticker sheet per shipped palette theme.
|
||||||
*
|
*
|
||||||
* The treatments are only useful if they read on every palette, so each sheet
|
* The treatments are only useful if they read on every palette, so each sheet
|
||||||
* is rendered from the palette the theme actually ships: both semantic
|
* is rendered from the palette the theme actually ships: all three semantic
|
||||||
* families, three glyphs each, as line glyphs, stickers and badges, at the two
|
* families, three glyphs each, as line glyphs, stickers and badges, at the two
|
||||||
* sizes the UI uses, on the window and button surfaces the contrast is measured
|
* sizes the UI uses, on the window and button surfaces the contrast is measured
|
||||||
* against. A disabled row closes each family: every treatment falls back to the
|
* against. A disabled row closes each family: every treatment falls back to the
|
||||||
|
|
@ -102,9 +103,17 @@ TEST(IconTreatmentPreview, WritesOneSheetPerShippedTheme)
|
||||||
AppColor::Role role;
|
AppColor::Role role;
|
||||||
const char *glyphs[3];
|
const char *glyphs[3];
|
||||||
};
|
};
|
||||||
|
// The hover panel's action grid is the first call site that puts a
|
||||||
|
// treatment on an action glyph, so the sheet renders the glyphs that grid
|
||||||
|
// actually uses: play/clone/hand (Positive), reduce life and graveyard
|
||||||
|
// (Negative), place face down and exile (Informational).
|
||||||
const QList<Family> families = {
|
const QList<Family> families = {
|
||||||
{"Positive", AppColor::Positive, {"increment", "ready_start", "arrow_up"}},
|
{"Positive", AppColor::Positive, {"arrow_right", "increment", "arrow_left"}},
|
||||||
{"Negative", AppColor::Negative, {"decrement", "not_ready_start", "remove_row"}},
|
{"Negative", AppColor::Negative, {"arrow_down", "decrement", "remove_row"}},
|
||||||
|
{"Informational", AppColor::Informational, {"arrow_right", "view", "arrow_to_top"}},
|
||||||
|
{"Hidden", AppColor::Hidden, {"view", "arrow_right", "swap"}},
|
||||||
|
{"Marked", AppColor::Marked, {"pencil", "share", "pin"}},
|
||||||
|
{"Movement", AppColor::Movement, {"arrow_to_top", "arrow_to_bottom", "arrow_down"}},
|
||||||
};
|
};
|
||||||
const QStringList themes = {
|
const QStringList themes = {
|
||||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||||
|
|
@ -246,3 +255,312 @@ TEST(IconTreatmentPreview, WritesOneSheetPerShippedTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
/** @brief One action-grid cell, with the role the panel hands the icon engine. */
|
||||||
|
struct PreviewAction
|
||||||
|
{
|
||||||
|
QString label;
|
||||||
|
const char *glyph;
|
||||||
|
AppColor::Role role;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief One titled section of a hover panel page. */
|
||||||
|
struct PreviewSection
|
||||||
|
{
|
||||||
|
QString title;
|
||||||
|
QList<PreviewAction> actions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief One hover panel page, as the client builds it. */
|
||||||
|
struct PreviewPage
|
||||||
|
{
|
||||||
|
QString title;
|
||||||
|
QList<PreviewSection> sections;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @brief Renders a sentinel SVG in one ink at the requested pixel size. */
|
||||||
|
QPixmap renderInkGlyph(const QByteArray &svg, const QColor &ink, const QSize &size)
|
||||||
|
{
|
||||||
|
QSvgRenderer renderer(resolveSvgColorSentinel(svg, ink.name(QColor::HexRgb).toLatin1()));
|
||||||
|
QPixmap pixmap(size);
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
renderer.render(&painter);
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Writes the hover panel's action grids the way the client paints them.
|
||||||
|
*
|
||||||
|
* The treatment sheets show glyphs in isolation; this renders the real layout —
|
||||||
|
* section headers and two-column cells with the glyph above its label — so the
|
||||||
|
* emphasis split (quiet tabs, primary grid) and the semantic map can be judged
|
||||||
|
* as the set the player actually sees. The roles are the ones the panel passes
|
||||||
|
* to the icon engine, already resolved to the emphasis level it requests, and a
|
||||||
|
* role the theme does not author resolves through the same scheme default the
|
||||||
|
* client paints.
|
||||||
|
*/
|
||||||
|
TEST(IconTreatmentPreview, HoverPanelGridWritesPngsWhenRequested)
|
||||||
|
{
|
||||||
|
const QString outDir = qEnvironmentVariable("COCKATRICE_ICON_PREVIEW_DIR");
|
||||||
|
if (outDir.isEmpty()) {
|
||||||
|
GTEST_SKIP() << "set COCKATRICE_ICON_PREVIEW_DIR to write the preview PNGs";
|
||||||
|
}
|
||||||
|
ensureGuiApplication();
|
||||||
|
ASSERT_TRUE(QDir().mkpath(outDir));
|
||||||
|
|
||||||
|
constexpr int MARGIN = 24;
|
||||||
|
constexpr int COLUMNS = 2;
|
||||||
|
constexpr int CELL_WIDTH = 146;
|
||||||
|
constexpr int CELL_HEIGHT = 62;
|
||||||
|
constexpr int SECTION_HEIGHT = 22;
|
||||||
|
constexpr int PANEL_PADDING = 10;
|
||||||
|
constexpr int PANEL_TITLE = 24;
|
||||||
|
constexpr int GLYPH = 22;
|
||||||
|
constexpr qreal DPR = 2.0;
|
||||||
|
|
||||||
|
// The pages a selected card shows, with every conditional action present
|
||||||
|
// so the whole map is visible at once.
|
||||||
|
const QList<PreviewPage> pages = {
|
||||||
|
PreviewPage{.title = QStringLiteral("Main — on the battlefield"),
|
||||||
|
.sections =
|
||||||
|
{
|
||||||
|
PreviewSection{.title = QStringLiteral("Battlefield"),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("Tap / Untap"),
|
||||||
|
.glyph = "sync",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Skip untapping"),
|
||||||
|
.glyph = "lock",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Clone"),
|
||||||
|
.glyph = "increment",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Attach to card..."),
|
||||||
|
.glyph = "pin",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Draw arrow..."),
|
||||||
|
.glyph = "share",
|
||||||
|
.role = AppColor::MarkedStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Set annotation..."),
|
||||||
|
.glyph = "pencil",
|
||||||
|
.role = AppColor::MarkedStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Turn Over"),
|
||||||
|
.glyph = "swap",
|
||||||
|
.role = AppColor::HiddenStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Peek at card face"),
|
||||||
|
.glyph = "view",
|
||||||
|
.role = AppColor::HiddenStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Unattach"),
|
||||||
|
.glyph = "arrow_undo",
|
||||||
|
.role = AppColor::NegativeStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Reduce life"),
|
||||||
|
.glyph = "arrow_down",
|
||||||
|
.role = AppColor::NegativeStrong},
|
||||||
|
}},
|
||||||
|
PreviewSection{.title = QStringLiteral("Select"),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("Select All"),
|
||||||
|
.glyph = "search",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Select Row"),
|
||||||
|
.glyph = "filter",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
PreviewPage{.title = QStringLiteral("Main — in a zone"),
|
||||||
|
.sections =
|
||||||
|
{
|
||||||
|
PreviewSection{.title = QStringLiteral("Zone"),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("Play"),
|
||||||
|
.glyph = "arrow_right",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Play Face Down"),
|
||||||
|
.glyph = "arrow_right",
|
||||||
|
.role = AppColor::HiddenStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Clone"),
|
||||||
|
.glyph = "increment",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Attach to card..."),
|
||||||
|
.glyph = "pin",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Draw arrow..."),
|
||||||
|
.glyph = "share",
|
||||||
|
.role = AppColor::MarkedStrong},
|
||||||
|
}},
|
||||||
|
PreviewSection{.title = QStringLiteral("Select"),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("Select All"),
|
||||||
|
.glyph = "search",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Select Column"),
|
||||||
|
.glyph = "filter",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
PreviewPage{.title = QStringLiteral("Move — card in a zone"),
|
||||||
|
.sections =
|
||||||
|
{
|
||||||
|
PreviewSection{.title = QStringLiteral("Move to"),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("Top of library"),
|
||||||
|
.glyph = "arrow_to_top",
|
||||||
|
.role = AppColor::MovementStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("X from top..."),
|
||||||
|
.glyph = "search",
|
||||||
|
.role = AppColor::MovementStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Bottom of library"),
|
||||||
|
.glyph = "arrow_to_bottom",
|
||||||
|
.role = AppColor::MovementStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Table"),
|
||||||
|
.glyph = "player",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Hand"),
|
||||||
|
.glyph = "arrow_left",
|
||||||
|
.role = AppColor::PositiveStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Graveyard"),
|
||||||
|
.glyph = "arrow_down",
|
||||||
|
.role = AppColor::NegativeStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Exile"),
|
||||||
|
.glyph = "arrow_right",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
}},
|
||||||
|
PreviewSection{.title = QStringLiteral("Reveal to..."),
|
||||||
|
.actions =
|
||||||
|
{
|
||||||
|
PreviewAction{.label = QStringLiteral("All players"),
|
||||||
|
.glyph = "share",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Alice"),
|
||||||
|
.glyph = "player",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
PreviewAction{.label = QStringLiteral("Bob"),
|
||||||
|
.glyph = "player",
|
||||||
|
.role = AppColor::InformationalStrong},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto rowsIn = [](const PreviewSection §ion) { return (section.actions.size() + COLUMNS - 1) / COLUMNS; };
|
||||||
|
const auto panelHeightFor = [&](const PreviewPage &page) {
|
||||||
|
int height = PANEL_TITLE + PANEL_PADDING;
|
||||||
|
for (const PreviewSection §ion : page.sections) {
|
||||||
|
height += SECTION_HEIGHT + rowsIn(section) * CELL_HEIGHT;
|
||||||
|
}
|
||||||
|
return height + PANEL_PADDING;
|
||||||
|
};
|
||||||
|
|
||||||
|
const int panelWidth = COLUMNS * CELL_WIDTH + 2 * PANEL_PADDING;
|
||||||
|
const int pageCount = static_cast<int>(pages.size());
|
||||||
|
int tallestPanel = 0;
|
||||||
|
for (const PreviewPage &page : pages) {
|
||||||
|
tallestPanel = qMax(tallestPanel, panelHeightFor(page));
|
||||||
|
}
|
||||||
|
const int logicalWidth = 2 * MARGIN + pageCount * panelWidth + (pageCount - 1) * MARGIN;
|
||||||
|
const int logicalHeight = MARGIN + 30 + tallestPanel + MARGIN;
|
||||||
|
|
||||||
|
const QString theme = QStringLiteral("Fabric");
|
||||||
|
for (const bool dark : {false, true}) {
|
||||||
|
const QString file =
|
||||||
|
QDir(QStringLiteral(COCKATRICE_SOURCE_DIR))
|
||||||
|
.absoluteFilePath(QStringLiteral("cockatrice/themes/%1/palette-default-%2.toml")
|
||||||
|
.arg(theme, dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||||
|
const PaletteConfig config = PaletteConfig::fromFile(file);
|
||||||
|
ASSERT_TRUE(config.hasPalette()) << theme.toStdString();
|
||||||
|
|
||||||
|
const QPalette palette = config.apply(QPalette());
|
||||||
|
const QColor window = palette.color(QPalette::Active, QPalette::Window);
|
||||||
|
const QColor text = palette.color(QPalette::Active, QPalette::WindowText);
|
||||||
|
// The panel's cells sit on the popup surface; painting them on the
|
||||||
|
// button color is what a QToolButton shows when it is not hovered.
|
||||||
|
const QColor cell = palette.color(QPalette::Active, QPalette::Button);
|
||||||
|
|
||||||
|
QImage image(QSize(qRound(logicalWidth * DPR), qRound(logicalHeight * DPR)),
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
image.fill(window);
|
||||||
|
QPainter painter(&image);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
|
painter.scale(DPR, DPR);
|
||||||
|
|
||||||
|
painter.setPen(text);
|
||||||
|
painter.setFont(QFont(QStringLiteral("Sans"), 10, QFont::DemiBold));
|
||||||
|
painter.drawText(QPointF(MARGIN, MARGIN),
|
||||||
|
QStringLiteral("%1 — %2 scheme, hover panel action grids")
|
||||||
|
.arg(theme, dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||||
|
|
||||||
|
const auto toneFor = [&](AppColor::Role role) {
|
||||||
|
return config.appColors.value(role, defaultAppColor(role, dark));
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int pageIndex = 0; pageIndex < pageCount; ++pageIndex) {
|
||||||
|
const PreviewPage &page = pages[pageIndex];
|
||||||
|
const qreal panelLeft = MARGIN + static_cast<qreal>(pageIndex) * (panelWidth + MARGIN);
|
||||||
|
const qreal panelTop = MARGIN + 30;
|
||||||
|
const int panelHeight = panelHeightFor(page);
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(cell.darker(dark ? 115 : 103));
|
||||||
|
painter.drawRoundedRect(QRectF(panelLeft, panelTop, panelWidth, panelHeight), 8, 8);
|
||||||
|
|
||||||
|
painter.setPen(text);
|
||||||
|
painter.setFont(QFont(QStringLiteral("Sans"), 9, QFont::DemiBold));
|
||||||
|
painter.drawText(QPointF(panelLeft + PANEL_PADDING, panelTop + 17), page.title);
|
||||||
|
|
||||||
|
qreal y = panelTop + PANEL_TITLE;
|
||||||
|
for (const PreviewSection §ion : page.sections) {
|
||||||
|
painter.setPen(text);
|
||||||
|
painter.setFont(QFont(QStringLiteral("Sans"), 8, QFont::DemiBold));
|
||||||
|
painter.drawText(QPointF(panelLeft + PANEL_PADDING, y + 15), section.title);
|
||||||
|
y += SECTION_HEIGHT;
|
||||||
|
|
||||||
|
const int rows = rowsIn(section);
|
||||||
|
for (int row = 0; row < rows; ++row) {
|
||||||
|
for (int column = 0; column < COLUMNS; ++column) {
|
||||||
|
const int index = row * COLUMNS + column;
|
||||||
|
if (index >= section.actions.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const PreviewAction &action = section.actions.at(index);
|
||||||
|
const QRectF cellRect(panelLeft + PANEL_PADDING + column * CELL_WIDTH, y, CELL_WIDTH - 4,
|
||||||
|
CELL_HEIGHT - 4);
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(cell);
|
||||||
|
painter.drawRoundedRect(cellRect, 5, 5);
|
||||||
|
|
||||||
|
const QByteArray svg = readIconSvg(action.glyph);
|
||||||
|
ASSERT_FALSE(svg.isEmpty()) << action.glyph;
|
||||||
|
const QPixmap pixmap = renderAtDpr(QSize(GLYPH, GLYPH), DPR, [&](const QSize &pixelSize) {
|
||||||
|
return renderInkGlyph(svg, toneFor(action.role), pixelSize);
|
||||||
|
});
|
||||||
|
painter.drawPixmap(QPointF(cellRect.center().x() - GLYPH / 2.0, cellRect.top() + 7), pixmap);
|
||||||
|
|
||||||
|
painter.setPen(text);
|
||||||
|
painter.setFont(QFont(QStringLiteral("Sans"), 7));
|
||||||
|
const QFontMetrics metrics(painter.font());
|
||||||
|
const QString label = metrics.elidedText(action.label, Qt::ElideRight, CELL_WIDTH - 12);
|
||||||
|
painter.drawText(QRectF(cellRect.left(), cellRect.bottom() - 20, cellRect.width(), 16),
|
||||||
|
Qt::AlignHCenter | Qt::AlignVCenter, label);
|
||||||
|
}
|
||||||
|
y += CELL_HEIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.end();
|
||||||
|
const QString path = QDir(outDir).absoluteFilePath(
|
||||||
|
QStringLiteral("hover-panel-map-%1.png").arg(dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||||
|
ASSERT_TRUE(image.save(path)) << path.toStdString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1535,9 +1535,14 @@ TEST_F(ThemeIconRenderTest, EmphasisSelectsTheAuthoredVariant)
|
||||||
AppColor::Role soft;
|
AppColor::Role soft;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const Family &family : {Family{AppColor::Icon, AppColor::IconStrong, AppColor::IconSoft},
|
for (const Family &family :
|
||||||
|
{Family{AppColor::Icon, AppColor::IconStrong, AppColor::IconSoft},
|
||||||
Family{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
|
Family{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
|
||||||
Family{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft}}) {
|
Family{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft},
|
||||||
|
Family{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft},
|
||||||
|
Family{AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft},
|
||||||
|
Family{AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft},
|
||||||
|
Family{AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}}) {
|
||||||
EXPECT_EQ(IconTint(family.base, IconEmphasis::Primary).resolve(QIcon::Normal),
|
EXPECT_EQ(IconTint(family.base, IconEmphasis::Primary).resolve(QIcon::Normal),
|
||||||
themeManager->appColor(family.strong));
|
themeManager->appColor(family.strong));
|
||||||
EXPECT_EQ(IconTint(family.base).resolve(QIcon::Normal), themeManager->appColor(family.base));
|
EXPECT_EQ(IconTint(family.base).resolve(QIcon::Normal), themeManager->appColor(family.base));
|
||||||
|
|
@ -1636,6 +1641,52 @@ TEST_F(ThemeIconRenderTest, EmphasisKeepsASemanticHue)
|
||||||
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||||
EXPECT_GT(ink.red(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
EXPECT_GT(ink.red(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const AppColor::Role role :
|
||||||
|
{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft}) {
|
||||||
|
// Informational may come from the scheme default when the theme
|
||||||
|
// does not author it, so measure the value the client paints.
|
||||||
|
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||||
|
if (!ink.isValid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++checked;
|
||||||
|
EXPECT_GT(ink.blue(), ink.red()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
EXPECT_GT(ink.blue(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const AppColor::Role role : {AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft}) {
|
||||||
|
// Hidden is violet: blue leads, then red, then green.
|
||||||
|
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||||
|
if (!ink.isValid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++checked;
|
||||||
|
EXPECT_GT(ink.blue(), ink.red()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const AppColor::Role role : {AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft}) {
|
||||||
|
// Marked is amber: red leads, then green, then blue.
|
||||||
|
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||||
|
if (!ink.isValid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++checked;
|
||||||
|
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
EXPECT_GT(ink.green(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const AppColor::Role role : {AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}) {
|
||||||
|
// Movement is teal: green leads, then blue, then red.
|
||||||
|
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||||
|
if (!ink.isValid()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++checked;
|
||||||
|
EXPECT_GT(ink.green(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
EXPECT_GT(ink.blue(), ink.red()) << theme.toStdString() << static_cast<int>(role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPECT_GT(checked, 0) << "no shipped theme authored a semantic emphasis level";
|
EXPECT_GT(checked, 0) << "no shipped theme authored a semantic emphasis level";
|
||||||
|
|
@ -1821,7 +1872,11 @@ TEST(IconInk, DefaultSemanticFamilyMeetsTheLadderOnPlatformSurfaces)
|
||||||
for (const Scheme &scheme : schemes) {
|
for (const Scheme &scheme : schemes) {
|
||||||
for (const auto &[base, strong, soft] :
|
for (const auto &[base, strong, soft] :
|
||||||
{std::tuple{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
|
{std::tuple{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
|
||||||
std::tuple{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft}}) {
|
std::tuple{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft},
|
||||||
|
std::tuple{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft},
|
||||||
|
std::tuple{AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft},
|
||||||
|
std::tuple{AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft},
|
||||||
|
std::tuple{AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}}) {
|
||||||
const QColor secondary = defaultAppColor(base, scheme.dark);
|
const QColor secondary = defaultAppColor(base, scheme.dark);
|
||||||
const QColor primary = defaultAppColor(strong, scheme.dark);
|
const QColor primary = defaultAppColor(strong, scheme.dark);
|
||||||
const QColor quiet = defaultAppColor(soft, scheme.dark);
|
const QColor quiet = defaultAppColor(soft, scheme.dark);
|
||||||
|
|
@ -1908,6 +1963,18 @@ TEST_F(ThemeIconRenderTest, EmphasisPreviewWritesPngsWhenRequested)
|
||||||
AppColor::NegativeSoft,
|
AppColor::NegativeSoft,
|
||||||
AppColor::Negative,
|
AppColor::Negative,
|
||||||
AppColor::NegativeStrong},
|
AppColor::NegativeStrong},
|
||||||
|
{"Informational",
|
||||||
|
{"arrow_right", "view", "arrow_to_top"},
|
||||||
|
AppColor::InformationalSoft,
|
||||||
|
AppColor::Informational,
|
||||||
|
AppColor::InformationalStrong},
|
||||||
|
{"Hidden", {"view", "arrow_right", "swap"}, AppColor::HiddenSoft, AppColor::Hidden, AppColor::HiddenStrong},
|
||||||
|
{"Marked", {"pencil", "share", "pin"}, AppColor::MarkedSoft, AppColor::Marked, AppColor::MarkedStrong},
|
||||||
|
{"Movement",
|
||||||
|
{"arrow_to_top", "arrow_to_bottom", "arrow_down"},
|
||||||
|
AppColor::MovementSoft,
|
||||||
|
AppColor::Movement,
|
||||||
|
AppColor::MovementStrong},
|
||||||
};
|
};
|
||||||
const QStringList themes = {
|
const QStringList themes = {
|
||||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||||
|
|
@ -1942,9 +2009,10 @@ TEST_F(ThemeIconRenderTest, EmphasisPreviewWritesPngsWhenRequested)
|
||||||
// The paint path is a lookup now, so the sheet shows the authored
|
// The paint path is a lookup now, so the sheet shows the authored
|
||||||
// rows verbatim rather than a color recomputed from the accent.
|
// rows verbatim rather than a color recomputed from the accent.
|
||||||
const auto toneFor = [&](const Family &family, int level) {
|
const auto toneFor = [&](const Family &family, int level) {
|
||||||
return level == 0 ? palette.roles.value(family.quiet)
|
const AppColor::Role role = level == 0 ? family.quiet : level == 1 ? family.secondary : family.primary;
|
||||||
: level == 1 ? palette.roles.value(family.secondary)
|
// A theme written before the role existed does not author it;
|
||||||
: palette.roles.value(family.primary);
|
// the client paints the scheme default, so the sheet does too.
|
||||||
|
return palette.roles.value(role, defaultAppColor(role, dark));
|
||||||
};
|
};
|
||||||
const auto scheme = dark ? ThemeIconFill::Scheme::Dark : ThemeIconFill::Scheme::Light;
|
const auto scheme = dark ? ThemeIconFill::Scheme::Dark : ThemeIconFill::Scheme::Light;
|
||||||
|
|
||||||
|
|
@ -2100,6 +2168,18 @@ TEST_F(ThemeIconRenderTest, EmphasisTreatmentsPreviewWritesPngsWhenRequested)
|
||||||
AppColor::NegativeSoft,
|
AppColor::NegativeSoft,
|
||||||
AppColor::Negative,
|
AppColor::Negative,
|
||||||
AppColor::NegativeStrong},
|
AppColor::NegativeStrong},
|
||||||
|
{"Informational",
|
||||||
|
{"arrow_right", "view", "arrow_to_top"},
|
||||||
|
AppColor::InformationalSoft,
|
||||||
|
AppColor::Informational,
|
||||||
|
AppColor::InformationalStrong},
|
||||||
|
{"Hidden", {"view", "arrow_right", "swap"}, AppColor::HiddenSoft, AppColor::Hidden, AppColor::HiddenStrong},
|
||||||
|
{"Marked", {"pencil", "share", "pin"}, AppColor::MarkedSoft, AppColor::Marked, AppColor::MarkedStrong},
|
||||||
|
{"Movement",
|
||||||
|
{"arrow_to_top", "arrow_to_bottom", "arrow_down"},
|
||||||
|
AppColor::MovementSoft,
|
||||||
|
AppColor::Movement,
|
||||||
|
AppColor::MovementStrong},
|
||||||
};
|
};
|
||||||
const QStringList themes = {
|
const QStringList themes = {
|
||||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||||
|
|
@ -2184,7 +2264,9 @@ TEST_F(ThemeIconRenderTest, EmphasisTreatmentsPreviewWritesPngsWhenRequested)
|
||||||
for (const Family &family : families) {
|
for (const Family &family : families) {
|
||||||
for (int level = 0; level < 4; ++level) {
|
for (int level = 0; level < 4; ++level) {
|
||||||
const bool disabled = level == 3;
|
const bool disabled = level == 3;
|
||||||
const QColor ink = disabled ? disabledTone : palette.roles.value(roleAt(family, level));
|
const QColor ink = disabled ? disabledTone
|
||||||
|
: palette.roles.value(roleAt(family, level),
|
||||||
|
defaultAppColor(roleAt(family, level), dark));
|
||||||
const QString levelName =
|
const QString levelName =
|
||||||
disabled ? QStringLiteral("Disabled") : QString::fromLatin1(LEVEL_NAMES[level]);
|
disabled ? QStringLiteral("Disabled") : QString::fromLatin1(LEVEL_NAMES[level]);
|
||||||
ASSERT_TRUE(ink.isValid())
|
ASSERT_TRUE(ink.isValid())
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,30 @@ TEST(ThemeAppColorTest, SemanticDefaultsFollowTheScheme)
|
||||||
EXPECT_EQ(defaultAppColor(AppColor::NegativeStrong, true), QColor(QStringLiteral("#ff8378")));
|
EXPECT_EQ(defaultAppColor(AppColor::NegativeStrong, true), QColor(QStringLiteral("#ff8378")));
|
||||||
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, false), QColor(QStringLiteral("#935f5c")));
|
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, false), QColor(QStringLiteral("#935f5c")));
|
||||||
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, true), QColor(QStringLiteral("#c79e9b")));
|
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, true), QColor(QStringLiteral("#c79e9b")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Informational, false), QColor(QStringLiteral("#1c64c4")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Informational, true), QColor(QStringLiteral("#7aa9f2")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::InformationalStrong, false), QColor(QStringLiteral("#0a4fb5")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::InformationalStrong, true), QColor(QStringLiteral("#69aeff")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::InformationalSoft, false), QColor(QStringLiteral("#526a8a")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::InformationalSoft, true), QColor(QStringLiteral("#9db2cd")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Hidden, false), QColor(QStringLiteral("#6d28d9")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Hidden, true), QColor(QStringLiteral("#c6a5fa")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::HiddenStrong, false), QColor(QStringLiteral("#4c0f9e")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::HiddenStrong, true), QColor(QStringLiteral("#c99bff")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::HiddenSoft, false), QColor(QStringLiteral("#6a5a8c")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::HiddenSoft, true), QColor(QStringLiteral("#b3a6c9")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Marked, false), QColor(QStringLiteral("#9a5b05")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Marked, true), QColor(QStringLiteral("#e2a63a")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MarkedStrong, false), QColor(QStringLiteral("#8a4f02")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MarkedStrong, true), QColor(QStringLiteral("#ffb020")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MarkedSoft, false), QColor(QStringLiteral("#7b6a4a")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MarkedSoft, true), QColor(QStringLiteral("#c2ab7d")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Movement, false), QColor(QStringLiteral("#0e7a72")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::Movement, true), QColor(QStringLiteral("#4cc2b5")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MovementStrong, false), QColor(QStringLiteral("#096b62")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MovementStrong, true), QColor(QStringLiteral("#2dd4bf")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MovementSoft, false), QColor(QStringLiteral("#4a6b67")));
|
||||||
|
EXPECT_EQ(defaultAppColor(AppColor::MovementSoft, true), QColor(QStringLiteral("#a3c1bc")));
|
||||||
// Accent and neutral icon roles have no static default: an older theme
|
// Accent and neutral icon roles have no static default: an older theme
|
||||||
// written before the roles existed falls back to deriving them from its
|
// written before the roles existed falls back to deriving them from its
|
||||||
// palette rather than pinning one scheme's ink.
|
// palette rather than pinning one scheme's ink.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue