mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-13 05:20:00 -08:00
Enable hover zoom and the hover panel by default
Both hover triggers now default to Hover, with the existing 400 ms zoom delay and 200 ms panel delay. The Off trigger remains available for users who want the old behavior.
This commit is contained in:
parent
83e451959f
commit
e12cc195d2
4 changed files with 12 additions and 18 deletions
|
|
@ -48,8 +48,8 @@ class QSizeF;
|
||||||
// Width the hovered card smooth-zooms to: exactly the hover panel picture size, so
|
// 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.
|
// all four corners coincide when the panel swaps in over it.
|
||||||
static constexpr qreal HOVER_ZOOM_WIDTH = 270.0;
|
static constexpr qreal HOVER_ZOOM_WIDTH = 270.0;
|
||||||
// The pre-panel hover enlargement. The smooth zoom is opt-in, so this stays the hover
|
// The pre-panel hover enlargement. This stays the hover behavior when the smooth zoom is
|
||||||
// behavior whenever no zoom trigger is configured (see setHoverHighlighted).
|
// turned off (see setHoverHighlighted).
|
||||||
static constexpr qreal LEGACY_HOVER_SCALE = 1.1;
|
static constexpr qreal LEGACY_HOVER_SCALE = 1.1;
|
||||||
static constexpr int HOVER_ZOOM_IN_MS = 220;
|
static constexpr int HOVER_ZOOM_IN_MS = 220;
|
||||||
static constexpr int HOVER_ZOOM_OUT_MS = 140;
|
static constexpr int HOVER_ZOOM_OUT_MS = 140;
|
||||||
|
|
@ -356,11 +356,9 @@ void AbstractCardItem::setHoverHighlighted(bool highlighted)
|
||||||
setZValue(ZValues::HOVERED_CARD);
|
setZValue(ZValues::HOVERED_CARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to the historical hover scale: the smooth hover zoom is opt-in and its
|
// Fallback to the historical hover scale when the smooth hover zoom is turned off and
|
||||||
// trigger defaults to Off, so when hovering drives neither the zoom nor the panel
|
// the panel is not driven by hover: contact alone must still enlarge the card to the
|
||||||
// (zoom trigger Off, panel not on hover) contact alone must still enlarge the card
|
// old 1.1x while scaleCards is on.
|
||||||
// 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();
|
auto &display = SettingsCache::instance().cardsDisplay();
|
||||||
const bool legacyHoverScale = display.getScaleCards() &&
|
const bool legacyHoverScale = display.getScaleCards() &&
|
||||||
display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerOff &&
|
display.getHoverZoomTrigger() == CardsDisplaySettings::HoverPanelTriggerOff &&
|
||||||
|
|
|
||||||
|
|
@ -70,16 +70,14 @@ bool CardsDisplaySettings::getScaleCards() const
|
||||||
|
|
||||||
int CardsDisplaySettings::getHoverPanelTrigger() const
|
int CardsDisplaySettings::getHoverPanelTrigger() const
|
||||||
{
|
{
|
||||||
// Off by default: the panel is new, so it is opt-in.
|
return getValue("hoverPanelTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerHover)).toInt();
|
||||||
return getValue("hoverPanelTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerOff)).toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CardsDisplaySettings::getHoverZoomTrigger() const
|
int CardsDisplaySettings::getHoverZoomTrigger() const
|
||||||
{
|
{
|
||||||
// Off by default: the smooth hover zoom is opt-in. With no trigger configured,
|
// Hover is the default: hovering first zooms the card, then the tab panel shows up.
|
||||||
// hovering keeps the historical 1.1x scale (AbstractCardItem::setHoverHighlighted)
|
// Either trigger can still be changed or turned off in the interface settings.
|
||||||
// instead of the smooth zoom to the hover panel size.
|
return getValue("hoverZoomTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerHover)).toInt();
|
||||||
return getValue("hoverZoomTrigger", QString(), QString(), static_cast<int>(HoverPanelTriggerOff)).toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CardsDisplaySettings::getHoverPanelDoubleConfirm() const
|
bool CardsDisplaySettings::getHoverPanelDoubleConfirm() const
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
HoverPanelTriggerRightClick = 1,
|
HoverPanelTriggerRightClick = 1,
|
||||||
HoverPanelTriggerWheel = 2,
|
HoverPanelTriggerWheel = 2,
|
||||||
HoverPanelTriggerShortcut = 3,
|
HoverPanelTriggerShortcut = 3,
|
||||||
/// Never fires. The hover zoom and panel are opt-in, so this is their default.
|
/// Never fires when selected; lets the user turn the hover zoom and panel off.
|
||||||
HoverPanelTriggerOff = 4
|
HoverPanelTriggerOff = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -686,8 +686,7 @@ TEST_F(SettingsDefaultsTest, CardsDisplay_ArrowDrawAnimation_Default)
|
||||||
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_Default)
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_Default)
|
||||||
{
|
{
|
||||||
CardsDisplaySettings s(settingsPath, nullptr);
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
// Off by default: the panel is opt-in on upgrade.
|
ASSERT_EQ(s.getHoverPanelTrigger(), CardsDisplaySettings::HoverPanelTriggerHover);
|
||||||
ASSERT_EQ(s.getHoverPanelTrigger(), CardsDisplaySettings::HoverPanelTriggerOff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_SetAndGet)
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_SetAndGet)
|
||||||
|
|
@ -702,8 +701,7 @@ TEST_F(SettingsDefaultsTest, CardsDisplay_HoverPanelTrigger_SetAndGet)
|
||||||
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_Default)
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_Default)
|
||||||
{
|
{
|
||||||
CardsDisplaySettings s(settingsPath, nullptr);
|
CardsDisplaySettings s(settingsPath, nullptr);
|
||||||
// Off by default: the smooth hover zoom is opt-in on upgrade.
|
ASSERT_EQ(s.getHoverZoomTrigger(), CardsDisplaySettings::HoverPanelTriggerHover);
|
||||||
ASSERT_EQ(s.getHoverZoomTrigger(), CardsDisplaySettings::HoverPanelTriggerOff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_SetAndGet)
|
TEST_F(SettingsDefaultsTest, CardsDisplay_HoverZoomTrigger_SetAndGet)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue