Build only one window layout, so the eyes stop jumping
Main.qml declared both layouts at once: the small per-object windows and the full-screen overlay. Both of them write the controller's catCenter, which is where the eyes look for the cursor. Two bindings on one property overwrite each other, so catCenter alternated every frame between the cat window's real centre and the hidden overlay's, whose height is zero. look.y flipped between -0.495 and 1.0 sixty times a second and the pupils jumped with it. Each layout now sits behind its own Loader and only the one the platform needs is built. The small windows moved into Desktop.qml so a single component can hold all three of them. Measured in the running app while walking, the eye's vertical travel went from 2.6 px to 0.40 px, and look.y is now a single steady value. It also stops a second, invisible cat from animating in the background. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f28dfec978
commit
9106ce47f4
3 files changed
+43
-17
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ qt_add_executable(tncat
|
|||||||
target_include_directories(tncat PRIVATE src)
|
target_include_directories(tncat PRIVATE src)
|
||||||
|
|
||||||
# QML files live in qml/ but register at the module root (TNCat.Main etc.)
|
# QML files live in qml/ but register at the module root (TNCat.Main etc.)
|
||||||
set(TNCAT_QML Main Cat Chip Cup CatWindow ChipWindow CupWindow OverlayWindow
|
set(TNCAT_QML Main Desktop Cat Chip Cup CatWindow ChipWindow CupWindow OverlayWindow
|
||||||
SettingsWindow AppButton AppSlider AppToggle SettingsGroup CatDefs)
|
SettingsWindow AppButton AppSlider AppToggle SettingsGroup CatDefs)
|
||||||
foreach(qmlfile IN LISTS TNCAT_QML)
|
foreach(qmlfile IN LISTS TNCAT_QML)
|
||||||
set_source_files_properties(qml/${qmlfile}.qml PROPERTIES QT_RESOURCE_ALIAS ${qmlfile}.qml)
|
set_source_files_properties(qml/${qmlfile}.qml PROPERTIES QT_RESOURCE_ALIAS ${qmlfile}.qml)
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import TNCat
|
||||||
|
|
||||||
|
// The layout for platforms that let a client place its own window: one small
|
||||||
|
// window per object, moved around the screen by the app.
|
||||||
|
QtObject {
|
||||||
|
id: desktop
|
||||||
|
|
||||||
|
required property CatController cat
|
||||||
|
required property AppSettings settings
|
||||||
|
|
||||||
|
signal settingsRequested()
|
||||||
|
|
||||||
|
readonly property CatWindow catWindow: CatWindow {
|
||||||
|
cat: desktop.cat
|
||||||
|
settings: desktop.settings
|
||||||
|
visible: true
|
||||||
|
onSettingsRequested: desktop.settingsRequested()
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property ChipWindow chipWindow: ChipWindow {
|
||||||
|
cat: desktop.cat
|
||||||
|
settings: desktop.settings
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property CupWindow cupWindow: CupWindow {
|
||||||
|
cat: desktop.cat
|
||||||
|
settings: desktop.settings
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-16
@@ -2,7 +2,9 @@ pragma ComponentBehavior: Bound
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import TNCat
|
import TNCat
|
||||||
|
|
||||||
// Root is not a window: which windows exist depends on the platform.
|
// Root is not a window. Exactly one of the two layouts is built, because both
|
||||||
|
// of them drive the controller's catCenter; having both alive made the two
|
||||||
|
// bindings overwrite each other every frame and the eyes jumped with them.
|
||||||
QtObject {
|
QtObject {
|
||||||
id: app
|
id: app
|
||||||
|
|
||||||
@@ -15,31 +17,24 @@ QtObject {
|
|||||||
settingsWindow.requestActivate()
|
settingsWindow.requestActivate()
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property CatWindow catWindow: CatWindow {
|
readonly property Loader desktopLoader: Loader {
|
||||||
|
active: !Platform.overlayMode
|
||||||
|
sourceComponent: Desktop {
|
||||||
cat: app.cat
|
cat: app.cat
|
||||||
settings: app.settings
|
settings: app.settings
|
||||||
visible: !Platform.overlayMode
|
|
||||||
onSettingsRequested: app.openSettings()
|
onSettingsRequested: app.openSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property ChipWindow chipWindow: ChipWindow {
|
|
||||||
cat: app.cat
|
|
||||||
settings: app.settings
|
|
||||||
visible: !Platform.overlayMode && app.cat.chipVisible
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property CupWindow cupWindow: CupWindow {
|
readonly property Loader overlayLoader: Loader {
|
||||||
|
active: Platform.overlayMode
|
||||||
|
sourceComponent: OverlayWindow {
|
||||||
cat: app.cat
|
cat: app.cat
|
||||||
settings: app.settings
|
settings: app.settings
|
||||||
visible: !Platform.overlayMode && app.cat.cupVisible
|
overlayActive: true
|
||||||
}
|
|
||||||
|
|
||||||
readonly property OverlayWindow overlayWindow: OverlayWindow {
|
|
||||||
cat: app.cat
|
|
||||||
settings: app.settings
|
|
||||||
overlayActive: Platform.overlayMode
|
|
||||||
onSettingsRequested: app.openSettings()
|
onSettingsRequested: app.openSettings()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
readonly property SettingsWindow settingsWindow: SettingsWindow {
|
readonly property SettingsWindow settingsWindow: SettingsWindow {
|
||||||
cat: app.cat
|
cat: app.cat
|
||||||
|
|||||||
Reference in new issue
Block a user