Black Mesa Button Prefix QML Files

From Valve Developer Community
Jump to navigation Jump to search
English (en)Translate (Translate)

This page contains information about button prefix QML Black Mesa Black Mesa files and their code from Resonance Decade Update.

button-carouselnav.qml

button-carouselnav.qml implements the left and right pagination arrow buttons used in the carousel component. It is registered in qmldir as CarouselButton 1.0 and is used exclusively by component-carousel.qml.

Registration

QML type name Version Source file Base type
CarouselButton 1.0 button-carouselnav.qml MouseArea

Properties

Property Type Default Description
direction string "left" Controls which chevron image is displayed. Accepts "left" or "right"; any other value falls through to the right chevron.
scale alias → image.scale (inherited) Exposes the inner Image scale for external manipulation. No consumer sets this property.
buttonHeight int Math.ceil(214 * Theme.widthScale) Computed height of the hit area. Uses Theme.widthScale rather than Theme.heightScale.
buttonWidth int Math.ceil(100 * Theme.widthScale) Computed width of the hit area.

The root MouseArea sets height: buttonHeight, width: buttonWidth, and hoverEnabled: true.

States

The component starts in the "blurred" state. Both states target the inner Image item (id: image).

State Effect
blurred image.opacity = 0.5
focused image.opacity = 1.0

Transitions

Both blurred → focused and focused → blurred animate image.opacity over 150 ms using a NumberAnimation wrapped inside a ParallelAnimation. The ParallelAnimation wrapper contains only a single child animation and is therefore redundant.

Event Handlers

Handler Action
onEntered Sets state to "focused"; plays Theme.sounds.buttonFocused (common/launch_glow1.wav).
onExited Sets state to "blurred".
onReleased Plays Theme.sounds.buttonClicked (bms_objects/clickbeep/beep1.wav).

Note that the click sound is triggered on onReleased, not onClicked. This means the sound fires even if the pointer is released outside the button's bounds after being pressed inside it.

Image Child

The sole visual child is an Image (id: image) centered in the hit area via anchors.centerIn: parent.

Property Value
source direction === "left" ? "image://game/ui/images/chevron-left.png" : "image://game/ui/images/chevron-right.png"
height Math.ceil(sourceSize.height * Theme.widthScale)
width Math.ceil(sourceSize.width * Theme.widthScale)
fillMode Image.PreserveAspectFit

Both image dimensions are scaled by Theme.widthScale. The height dimension does not use Theme.heightScale, which is inconsistent with the scaling convention used by most other UI components.

Usage in component-carousel.qml

component-carousel.qml instantiates two CarouselButton items — one on each side of the clipping mask (id: mask).

Instance direction Anchor Visibility condition Click action
Left button "left" anchors.right: mask.left showLeft changePagination(-1)
Right button "right" anchors.left: mask.right showRight changePagination(1)

Each instance is hidden and disabled when its corresponding direction has no more items: enabled: showLeft / opacity: showLeft ? 1.0 : 0.0. The opacity fade is handled externally by a Behavior on opacity in the parent, independent of the internal state-based opacity on the image. This creates two stacked opacity layers: the button-level fade (parent-controlled) and the image-level hover fade (state-controlled).

Technical Notes

1. buttonHeight uses Theme.widthScale. The height dimension is computed as Math.ceil(214 * Theme.widthScale) rather than Math.ceil(214 * Theme.heightScale). On non-16:9 displays where widthScale and heightScale differ, the button hit area will not scale correctly in the vertical axis.

2. Image height also uses Theme.widthScale. The inner Image height is Math.ceil(sourceSize.height * Theme.widthScale). Combined with fillMode: Image.PreserveAspectFit, the image will not be distorted, but the computed height value passed to the layout engine is incorrect on non-16:9 displays.

3. scale alias is dead code. The scale property is aliased to image.scale and exposed as a public API, but no consumer in the codebase sets it. It is likely a leftover from an earlier design.

4. ParallelAnimation wraps a single child. Both transitions use a ParallelAnimation containing exactly one NumberAnimation. The parallel wrapper provides no benefit and adds unnecessary nesting.

5. onReleased vs onClicked for sound. The click sound is played in onReleased rather than onClicked. onClicked fires only when the press and release both occur within the MouseArea; onReleased fires unconditionally on any release. This is inconsistent with button-default.qml and button-letterbox.qml, which use onClicked.

6. No objectName. Unlike DefaultButton (objectName: "ui:btn:action[...]") and LetterboxButton, CarouselButton has no objectName. The BlackMesaUtils.traverseUIElements traversal called after carousel pagination in component-carousel.qml will not identify these buttons by name.

7. No disabled property. The button has no internal disabled state. Disabling is handled entirely by the parent setting enabled: false, which suppresses all MouseArea events but does not change the visual appearance beyond the parent-controlled opacity fade.

8. id: carouselButton is unused internally. The root id is declared but never referenced by any child element or internal binding within the file.

button-cta.qml

button-cta.qml implements the Call-to-Action (CTA) button variant used throughout the UI. It is a minimal subclass of DefaultButton that overrides three properties to produce a visually distinct primary-action button. Registered in qmldir as CTAButton 1.0.

Inheritance

Base class File
DefaultButton button-default.qml

CTAButton does not define any new properties, signals, functions, or child items. It consists entirely of three property overrides on DefaultButton.

Property Overrides

Property CTAButton value DefaultButton default Resolved value
bold true false Uses Theme.fonts.bold (NotoSans Bold / NotoSansCJK Bold) instead of Theme.fonts.regular
boxColor Theme.colors.highlight Theme.colors.buttonText #e47125 (orange) instead of white
focusedTextColor Theme.colors.buttonText Theme.colors.highlight white instead of #e47125 (orange)

The net effect is an inversion of the DefaultButton color scheme: where DefaultButton uses a white border/fill with orange focused text, CTAButton uses an orange border/fill with white focused text.

Effective Visual States

All state logic is inherited from DefaultButton. The overridden properties change the resolved colors as follows:

State Border color focusShape fill Text color focusShape height
blurred #e47125 #e47125 white Math.ceil(8 * Theme.heightScale) (bottom bar only)
focused #e47125 #e47125 white Full button height (solid orange fill)
disabled #888888 #888888 #888888 Math.ceil(8 * Theme.heightScale) (bottom bar only)

In the blurred state the button appears as an orange-bordered rectangle with a thin orange bottom bar and white text. In the focused state the entire button fills with orange and the text remains white. The disabled state is identical to DefaultButton: all elements use Theme.colors.dimmedText (#888888).

The blurredTextColor property is not overridden, so blurred text color remains Theme.colors.buttonText (white), which is the same as focusedTextColor. Text color does not change between blurred and focused states in CTAButton.

Consumers

File Instances Button labels (L10n key)
routeview-index.qml 5 buttons.quicksave, buttons.saveGame, buttons.disconnect (in-game variant); buttons.startGame (new-game variant); buttons.resume (continue variant)
routeview-bindings.qml 4 Apply Changes, Discard Changes, and binding-related actions
component-optionslist.qml 2 buttons.applyChanges (primary apply); secondary action
routeview-audio.qml 2 Apply/Discard Changes
routeview-savebeforequit.qml 2 buttons.cancel, buttons.dontSave
routeview-video.qml 2 Apply/Discard Changes
routeview-host.qml 1 Start Server action
routeview-quit.qml 1 buttons.quit

Notable Observations

1. focusedTextColor override is redundant. DefaultButton sets focusedTextColor: Theme.colors.highlight (orange). CTAButton overrides it to Theme.colors.buttonText (white). However, since blurredTextColor is also white and text color does not animate between blurred and focused states in CTAButton, the override has no visible effect — the text is white in both states regardless. The override is nonetheless necessary to prevent orange text from appearing on the orange focusShape fill during the focused state.

2. Semantic inversion in quit/save-before-quit dialogs. In routeview-quit.qml, CTAButton is used for the destructive "Quit" action and DefaultButton for the safe "Cancel" action. In routeview-savebeforequit.qml, CTAButton is used for "Cancel" and "Don't Save" while DefaultButton is used for "Save". The CTA styling (orange, bold) does not consistently indicate a constructive or safe action — it marks the contextually primary action, which may be destructive.

3. The file is 8 lines including imports. The entire implementation is three property assignments. All layout, animation, state, and interaction logic is inherited from DefaultButton without modification.

4. No objectName is set at the type level. Individual instances set objectName (e.g. "ui:btn:action[apply]", "ui:btn:action[cancel]") at the call site. The type itself provides no default objectName, consistent with DefaultButton and WarningButton.

5. bold: true is the only typographic override. All font size, capitalization (Font.AllUppercase), and family fallback logic remain in DefaultButton. The bold weight is the only typographic distinction between CTAButton and an unstyled DefaultButton.

button-default.qml

button-default.qml is the base button component for the UI. It is registered as DefaultButton 1.0 and serves as the supertype for CTAButton and WarningButton. All three types are used throughout the UI wherever a labelled action button is required.

Registration

qmldir name Version File
DefaultButton 1.0 button-default.qml
CTAButton 1.0 button-cta.qml
WarningButton 1.0 button-warning.qml

Root Element

The root element is a MouseArea (id: button). This is the outer interactive surface. A second, nested MouseArea (id: mouseArea) is declared inside it to own the state machine and hover/click handlers. The outer MouseArea handles only onDisabledChanged and provides propagateComposedEvents: true so that click events can reach parent items.

Properties

Appearance
Property Type Default Notes
text string "DEFAULT TEXT" Displayed label; always rendered Font.AllUppercase.
bold bool false Selects Theme.fonts.bold vs Theme.fonts.regular.
boxColor color Theme.colors.buttonText (white) Color of the border rectangle and the focusShape fill.
disabledBoxColor color Theme.colors.dimmedText (#888888) boxColor override when disabled.
blurredTextColor color Theme.colors.buttonText (white) Text color in the blurred state.
focusedTextColor color Theme.colors.highlight (#e47125) Text color in the focused state.
disabledTextColor color Theme.colors.dimmedText (#888888) Text color in the disabled state.
Dimensions
Property Type Default
buttonHeight int Math.ceil(46 * Theme.heightScale)
buttonWidth int Math.ceil(buttonText.contentWidth + 46 * Theme.heightScale)
borderWidth int Math.ceil(2 * Theme.widthScale)
fontSize int Math.ceil(16 * Theme.heightScale)
focusShapeHeightBlurred int Math.ceil(8 * Theme.heightScale)
buttonTextVerticalCenterOffsetBlurred int Math.ceil(-4 * Theme.heightScale)
Behaviour
Property Type Default Notes
disabled bool false Suppresses hover/click and applies disabled styling.
clickedSoundPath string Theme.sounds.buttonClicked "bms_objects/clickbeep/beep1.wav"
focusedSoundPath string Theme.sounds.buttonFocused "common/launch_glow1.wav"

Visual Structure

Three child items are declared directly under the outer MouseArea:

border (Rectangle)
Fills the parent. Transparent fill; colored border of width borderWidth using boxColor. Has a standalone Behavior on border.color (ColorAnimation, 150 ms) that runs independently of the state machine.
focusShape (Rectangle)
Anchored to the bottom, left, and right of the parent. Its height animates between focusShapeHeightBlurred (8 px scaled, blurred/disabled) and parent.height (full fill, focused). Color is boxColor or disabledBoxColor. This produces the "fill from bottom" hover effect.
buttonText (Text)
Centered in the parent. Text is Font.AllUppercase. In the blurred state its anchors.verticalCenterOffset is set to buttonTextVerticalCenterOffsetBlurred (−4 px scaled), shifting it slightly upward above the focusShape underline. On focus the offset returns to 0.

State Machine

The state machine is owned by the inner mouseArea. Its initial state is button.disabled ? "disabled" : "blurred".

State focusShape height focusShape color Text color Text vertical offset Side effect
blurred focusShapeHeightBlurred boxColor blurredTextColor buttonTextVerticalCenterOffsetBlurred —
focused parent.height boxColor focusedTextColor 0 Plays focusedSoundPath via StateChangeScript
disabled focusShapeHeightBlurred disabledBoxColor disabledTextColor buttonTextVerticalCenterOffsetBlurred —
Transitions
From To Reversible Animated properties Easing
blurred focused Yes Text color, focusShape height, text verticalCenterOffset Easing.OutQuint, 150 ms
blurred disabled Yes Text color, focusShape color Linear, 150 ms
focused disabled Yes Text color, focusShape color, focusShape height, text verticalCenterOffset Easing.OutQuint, 150 ms

There is no explicit focused → blurred transition entry; the blurred → focused transition covers the reverse direction via reversible: true.

Event Handlers

Inner mouseArea
onEntered
If state is not "disabled", sets state to "focused".
onExited
If state is not "disabled", sets state to "blurred".
onClicked
If not disabled, plays button.clickedSoundPath and sets mouse.accepted = false (propagates the event). If disabled, sets mouse.accepted = true inside the else branch, but this is immediately overwritten by the unconditional mouse.accepted = false on the next line. See Known Issues.
Outer button
onDisabledChanged
Directly sets mouseArea.state. If disabled is true, forces state to "disabled". Otherwise, checks button.containsMouse to decide between "focused" and "blurred".

Subclasses

Both subclasses override three properties and add no new logic.

Type bold boxColor focusedTextColor Semantic use
CTAButton true Theme.colors.highlight (#e47125) Theme.colors.buttonText (white) Primary / call-to-action
WarningButton true Theme.colors.warning (#c72424) Theme.colors.buttonText (white) Destructive actions

Usage

DefaultButton, CTAButton, and WarningButton are used in Alert buttons models and in OptionsList footers throughout the UI. Representative usages:

File Type used Context
routeview-quit.qml CTAButton, DefaultButton Quit confirmation dialog (Quit / Cancel)
routeview-savebeforequit.qml CTAButton, DefaultButton Save-before-quit dialog (Cancel / Don't Save / Save)
component-optionslist.qml WarningButton, CTAButton Batch-update footer (Discard Changes / Apply Changes)
routeview-index.qml CTAButton In-game index: Quicksave, Save Game, Resume, New Game
routeview-savegame.qml CTAButton, WarningButton Save game / delete save confirmation
routeview-loadgame.qml WarningButton Delete save confirmation
routeview-audio.qml CTAButton, WarningButton Audio options apply / reset defaults
routeview-video.qml CTAButton, WarningButton Video options apply / reset defaults
routeview-bindings.qml CTAButton, WarningButton, DefaultButton Bindings page: Edit Binding, Clear Binding, Reset All Defaults
routeview-host.qml CTAButton Host game start button

All instances set objectName to a string of the form "ui:btn:action[<role>]" (e.g. "ui:btn:action[apply]", "ui:btn:action[cancel]", "ui:btn:action[discard]"). This naming convention is consumed by utils.qml during UI traversal for keyboard/controller navigation.

Known Issues and Observations

1. Disabled click suppression is broken. The onClicked handler sets mouse.accepted = true inside the else (disabled) branch, but the unconditional mouse.accepted = false immediately following overwrites it. Clicks always propagate to parent items regardless of the disabled state.

2. buttonWidth uses heightScale for horizontal padding. The formula is Math.ceil(buttonText.contentWidth + 46 * Theme.heightScale). The 46-pixel padding is scaled by heightScale rather than widthScale, making the button narrower than expected on displays where the two scale factors differ (non-16:9 resolutions). borderWidth correctly uses widthScale.

3. Nested MouseArea pattern. The root element is itself a MouseArea (button), and a second MouseArea (mouseArea) is nested inside it. The outer area serves only as a container and onDisabledChanged handler; all interactive logic lives in the inner area. This is an unusual pattern that could cause unexpected event routing if the outer area's own onClicked were ever connected.

4. StateChangeScript fires on programmatic state changes. The focusedScript in the focused state plays the hover sound whenever the state becomes "focused", including when onDisabledChanged programmatically sets mouseArea.state = "focused" because the cursor happens to be over the button at the moment it is re-enabled.

5. Behavior on border.color is independent of the state machine. The border rectangle has a standalone Behavior that animates its border.color over 150 ms. The state machine also sets border.color via PropertyChanges. Both mechanisms run concurrently, which can cause the border color to animate twice or produce a double-transition artifact when states change rapidly.

6. No objectName on the root element. Unlike most interactive components in the codebase (e.g. component-carousel-item.qml with objectName: "ui:carousel-item"), button-default.qml does not set an objectName on the root. Individual instances set their own objectName values (e.g. "ui:btn:action[apply]"), so the base type is not independently identifiable during UI traversal.

button-letterbox.qml

button-letterbox.qml implements the letterbox-style navigation button used throughout the Black Mesa main menu. It is registered in qmldir as LetterboxButton 1.0 and is the base type for MainNavButton (button-mainnav.qml). Direct consumers include component-footer.qml, component-header.qml (sub-nav delegate), and routeview-translators.qml.

Root Element

The root element is a MouseArea (id: button). This is an unusual choice — most button components in the codebase use Item or FocusScope as the root. The outer MouseArea does not handle mouse events directly; it exists to expose the containsMouse property used in onSelectedChanged and onDisabledChanged, and to serve as the QML type root that consumers attach onClicked handlers to. All actual mouse event handling is delegated to an inner MouseArea (id: mouseArea).

Properties

Property Type Default Description
text alias — Alias to buttonText.text. Consumers set this to the button label.
selected bool false Whether the button is in the selected (active route) state.
disabled bool false Disables hover and click interaction.
focusedSoundPath string Theme.sounds.buttonFocused Sound played on hover. Resolves to common/launch_glow1.wav.
clickedSoundPath string Theme.sounds.buttonClicked Sound played on selection. Resolves to bms_objects/clickbeep/beep1.wav.
focusedColor color Theme.colors.highlight (#e47125) Text color in the selected state. Despite the name, this is not the hover color.
blurredColor color Theme.colors.buttonText (white) Text color in the blurred (idle) state.
selectedColor color Theme.colors.buttonText (white) Text color in the focused (hover) state. Despite the name, this is not the selected color.
disabledColor color Theme.colors.dimmedText (#888888) Text color in the disabled state.
focusShapeOpacity real 0.75 Opacity of the focusShape rectangle. MainNavButton overrides this to 1.
buttonWidth int Math.ceil(buttonText.contentWidth + 40 * Theme.heightScale) Auto-sized to text content plus horizontal padding. Uses heightScale for horizontal padding (see Observations).
buttonHeight int Math.ceil(63 * Theme.heightScale) Default height. MainNavButton overrides this to Math.ceil(64 * Theme.heightScale).
buttonTextFontSize int Math.ceil(16 * Theme.heightScale) Font size of the button label.
barHeight int Math.ceil(8 * Theme.heightScale) Height of the focusShape in the selected state (the bottom bar indicator).
focusShapeWidthFocused int Math.ceil(button.width - 10 * Theme.heightScale) Width of the focusShape when focused or selected. Uses heightScale for a width offset (see Observations).
focusShapeMargin int Math.ceil(5 * Theme.heightScale) Left margin of the focusShape from the button edge. Uses heightScale for a horizontal margin (see Observations).

Children

Navigation Highlight Rectangle

An anonymous Rectangle (lines 44–51) is positioned at the same x-coordinate and width as focusShape, spanning the full button height. It is visible only when button.selected && button.activeFocus. Its color is Theme.colors.navigationHighlight (#e88849) at opacity: 0.4. This provides a visual distinction between a selected button that has keyboard/controller focus and one that is selected but not focused — the lighter orange tint overlays the focusShape bar only when the button is actively focused by the input system.

Focus Shape

Rectangle (id: focusShape) is anchored to the bottom-left of the button with a left margin of focusShapeMargin. Its color is button.focusedColor and its opacity is button.focusShapeOpacity. Its width and height are animated by the state machine:

  • In blurred and disabled: width 0, height 0 (invisible).
  • In focused: width focusShapeWidthFocused, height button.height (full-height vertical bar).
  • In selected: width focusShapeWidthFocused, height barHeight (thin bottom bar).
Button Text

Text (id: buttonText) is centered in the button via anchors.centerIn: parent, uses Theme.fonts.regular, font.pixelSize: buttonTextFontSize, and font.capitalization: Font.AllUppercase. Its color and font.bold are controlled by the state machine.

Inner Mouse Area

MouseArea (id: mouseArea) fills the button. Key properties:

  • hoverEnabled: !button.disabled — hover events are suppressed when disabled.
  • scrollGestureEnabled: false — prevents scroll gesture capture.
  • propagateComposedEvents: !button.disabled — click events propagate to the parent (the outer button MouseArea) only when not disabled.

State Machine

States are defined on mouseArea. Initial state is set in Component.onCompleted based on button.disabled and button.selected.

State buttonText.color buttonText.font.bold focusShape width focusShape height Side effect
blurred blurredColor (white) false 0 0 —
focused selectedColor (white) false focusShapeWidthFocused button.height Plays focusedSoundPath via StateChangeScript
selected focusedColor (orange) true focusShapeWidthFocused barHeight (8 px scaled) Plays clickedSoundPath via StateChangeScript
disabled disabledColor (#888888) false 0 0 —
Transitions
From → To Animation Duration Easing
blurred → focused Sequential: instant width snap (1 ms), then parallel ColorAnimation + height NumberAnimation 250 ms Easing.OutQuint
focused → blurred Sequential: parallel ColorAnimation + height NumberAnimation, then instant width collapse (1 ms) 250 ms Easing.OutQuint
focused → selected Parallel: height NumberAnimation + ColorAnimation 150 ms Easing.OutQuint
selected → blurred Sequential: parallel height NumberAnimation + ColorAnimation, then instant width collapse (1 ms) 100 ms Easing.Linear (no easing specified)

The width of focusShape is always snapped instantly (1 ms NumberAnimation) rather than animated, so the visible animation is the vertical grow/shrink of the bar. The sequential structure ensures the width collapses only after the height animation completes, preventing a visual artifact where a zero-height bar remains at full width momentarily.

Event Handlers

On the outer button (MouseArea root)
  • onSelectedChanged: sets mouseArea.state to "selected" or, if deselected, to "focused" if button.containsMouse, otherwise "blurred".
  • onDisabledChanged: sets mouseArea.state to "disabled" or, if re-enabled, to "focused" if button.containsMouse, otherwise "blurred".
On the inner mouseArea
  • onEntered: transitions to "focused" if not selected or disabled.
  • onExited: transitions to "blurred" if not selected or disabled.
  • onClicked: if not selected or disabled, sets mouse.accepted = false (propagates the click to the outer button MouseArea, where consumers attach their onClicked handlers); otherwise sets mouse.accepted = true (consumes the event).

Consumers

File Usage objectName type property
component-footer.qml id_btn_quit — Quit button; selected when current route is Routes.quit. id_btn_back — Back / Back to Game button; visible conditionally. "ui:btn:action[quit]", "ui:btn:action[back]" —
component-header.qml Sub-nav delegate in the sub-navigation ListView; selected when currentRoute.path.split('.')[1] === routeName. "ui:tab" "sub"
routeview-translators.qml Two tab buttons (Proofreaders / Translators); selected drives activeTab integer. "ui:tab" "sub-nav"
button-mainnav.qml Subtype; overrides focusedColor, selectedColor, focusShapeOpacity, and height. — —

Observations

1. focusedColor and selectedColor are semantically swapped. focusedColor (orange) is applied in the selected state; selectedColor (white) is applied in the focused (hover) state. This naming inversion is inherited by MainNavButton, which sets focusedColor: Theme.colors.buttonText and selectedColor: Theme.colors.highlight — the opposite of the base defaults — to achieve the correct visual result for main-nav buttons.

2. Three horizontal dimension properties use Theme.heightScale. buttonWidth, focusShapeWidthFocused, and focusShapeMargin all multiply by Theme.heightScale instead of Theme.widthScale. On non-16:9 displays where the two scale factors differ, the button width and focus shape will not scale correctly relative to the horizontal axis.

3. The root element is a MouseArea. The outer MouseArea (button) is used solely to expose containsMouse for state recovery in onSelectedChanged and onDisabledChanged, and to serve as the click target for consumers. All interaction logic lives in the inner mouseArea. Using Item as the root with an explicit containsMouse property would be cleaner and avoid the ambiguity of two nested MouseArea elements.

4. No selected → focused transition. When a button is deselected while the mouse is hovering, onSelectedChanged sets the state directly to "focused" without an animated transition. The focusShape jumps from bar height to full height instantly.

5. selected → blurred uses Easing.Linear. All other transitions specify Easing.OutQuint. The deselection animation (100 ms, linear) is noticeably faster and less smooth than the focus-in animation (250 ms, OutQuint).

6. onClicked and StateChangeScript both reference sound playback, but the direct calls are commented out. The onEntered handler has a commented-out Sound.playEffect(button.focusedSoundPath) call, and onClicked has a commented-out Sound.playEffect(button.clickedSoundPath) call. Sound is played exclusively through the StateChangeScript blocks inside the focused and selected states. The commented-out calls are dead code.

7. buttonHeight defaults to 63 px (scaled), not 64 px. The 1 px discrepancy is acknowledged in component-header.qml with a TODO comment noting that the logo image is 63 px and should be 64 px. MainNavButton overrides height to Math.ceil(64 * Theme.heightScale) to match the intended header height.

button-mainnav.qml

button-mainnav.qml defines the MainNavButton type, the top-level navigation tab button used in the main navigation bar of the Black Mesa Qt/QML UI. It is a thin subclass of LetterboxButton (button-letterbox.qml) that overrides four properties to produce the specific visual behaviour required for primary navigation tabs.

Registration

Registered in qmldir as:

MainNavButton 1.0    button-mainnav.qml  
 

Base Type

MainNavButton extends LetterboxButton, which is itself a MouseArea root. All interaction logic, state machine, animation, and child elements are inherited from LetterboxButton. button-mainnav.qml contains no additional properties, signals, functions, or child elements of its own.

Property Overrides

Property Base default MainNavButton value Effect
focusedColor Theme.colors.highlight (#e47125, orange) Theme.colors.buttonText (white) The focusShape rectangle is rendered white instead of orange. In the selected state, the text color is also driven by focusedColor, so selected-tab text is white.
selectedColor Theme.colors.buttonText (white) Theme.colors.highlight (#e47125, orange) In the focused state, text color is driven by selectedColor, so hovered-tab text turns orange.
focusShapeOpacity 0.75 1 The focusShape rectangle is fully opaque rather than 75% opaque.
height Math.ceil(63 * Theme.heightScale) Math.ceil(64 * Theme.heightScale) One scaled pixel taller than the base class default. The base class has a TODO comment noting the 63 px value is a hack because the logo image is 63 px rather than 64 px.

Inherited State Machine

All four states are defined in LetterboxButton and are unmodified by MainNavButton. The effective visual result for each state, given the overrides above, is:

State Text color focusShape geometry Trigger
blurred Theme.colors.buttonText (white) width 0, height 0 (hidden) Mouse leaves button; button not selected
focused Theme.colors.highlight (orange) Full button width, full button height (white bar, opacity 1) Mouse enters button; button not selected
selected Theme.colors.buttonText (white, bold) Full button width, Math.ceil(8 * Theme.heightScale) height (thin white underline bar) selected property set to true by consumer
disabled Theme.colors.dimmedText (#888888) width 0, height 0 (hidden) disabled property set to true by consumer

An additional Rectangle (color: Theme.colors.navigationHighlight, #e88849, opacity 0.4) is rendered at full button height when the button is simultaneously selected and has activeFocus. This provides a visual indicator for keyboard/controller navigation over the currently active tab.

Transition Animations

Inherited from LetterboxButton:

Transition Animation Duration
blurred → focused focusShape width snaps to target in 1 ms, then height and text color animate in parallel 250 ms, Easing.OutQuint
focused → blurred Height and text color animate in parallel, then width snaps to 0 250 ms, Easing.OutQuint
focused → selected focusShape height and text color animate in parallel (bar collapses from full height to 8 px) 150 ms, Easing.OutQuint
selected → blurred Height and text color animate in parallel, then width snaps to 0 100 ms (no easing)

No transition is defined for blurred → selected or selected → focused. These transitions fall back to immediate property changes.

Click Behaviour

Inherited from LetterboxButton: if the button is in the selected or disabled state when clicked, mouse.accepted is set to true (event consumed). Otherwise mouse.accepted is set to false, allowing the event to propagate to the parent ListView delegate, which connects onClicked to header.routeRequest(routeName).

Sound Effects

Inherited from LetterboxButton:

  • Focus sound: Theme.sounds.buttonFocused (common/launch_glow1.wav), played on entry to the focused state via StateChangeScript.
  • Click sound: Theme.sounds.buttonClicked (bms_objects/clickbeep/beep1.wav), played on entry to the selected state via StateChangeScript.

Both the onEntered hover sound call and the onClicked click sound call in LetterboxButton are commented out; sounds are played exclusively through StateChangeScript entries in the state definitions.

Usage

MainNavButton is used in exactly one location: the mainNavListView delegate inside component-header.qml.

  
delegate: MainNavButton {  
    readonly property string type: "main"  
    objectName: "ui:tab"  
    text: label  
    selected: currentRoute && currentRoute.path.split('.')[0] === routeName  
    onClicked: header.routeRequest(routeName)  
}

The selected binding compares the first path segment of the current route (e.g. options from options.video) against the button's routeName model role. This means all sub-routes under a top-level section keep the corresponding main nav tab highlighted.

Technical Notes

1. focusedColor and blurredColor produce the same text color in blurred state. blurredColor is not overridden and remains Theme.colors.buttonText (white). focusedColor is also set to Theme.colors.buttonText (white). The text color therefore does not change between blurred and focused states — only the focusShape geometry animates. The visual distinction between blurred and focused is entirely the white background bar appearing behind the text.

2. The focused state renders white text on a white background. In the focused state, focusShape expands to full button height with color: button.focusedColor (white) and opacity: 1. The text color is selectedColor (orange). The result is orange text on a white background bar, which is the intended hover appearance.

3. height override is 1 px taller than buttonHeight. LetterboxButton defines buttonHeight: Math.ceil(63 * Theme.heightScale) and sets height: buttonHeight. MainNavButton overrides height directly to Math.ceil(64 * Theme.heightScale), bypassing buttonHeight. The buttonHeight property still exists on the instance with its original value of 63 scaled px, creating a silent discrepancy between buttonHeight and the actual rendered height.

4. No blurred → selected transition. When the router sets a route on startup (Component.onCompleted), the button transitions directly from blurred to selected with no animation. This is correct behaviour for initial load but means the first navigation after startup also has no animation if the button was never hovered.

5. type: "main" is a readonly inline property. The type property set on the delegate is not declared on MainNavButton or LetterboxButton; it is an ad-hoc property added at the instantiation site. It is used by utils.qml to identify main-nav buttons during keyboard/controller UI traversal.

button-triangle.qml

button-triangle.qml implements a small directional arrow button rendered as a rotated triangle. It is registered in qmldir as TriangleButton 1.0 and is the sole interactive consumer of the Triangle 1.0 primitive (triangle.qml). Its only consumer in the codebase is component-optionslist-input-select.qml, where it appears as the left and right navigation arrows of the select input widget.

Registration

File Registered type Version
button-triangle.qml TriangleButton 1.0
triangle.qml Triangle 1.0

Root element

The root element is a MouseArea (id: container). It does not extend DefaultButton; it is an independent implementation. Default dimensions are height: parent.height and width: 30 (hardcoded, unscaled pixels). hoverEnabled is true.

Properties

Property Type Default Description
directions readonly QtObject — Namespace object exposing the two canonical rotation values: left (-45) and right (135).
focusedColor color Theme.colors.highlight Triangle fill color when hovered (#e47125).
blurredColor color Theme.colors.buttonText Triangle fill color at rest (white).
triangleHeight int 20 Height passed to the child Triangle item. Unscaled by default.
triangleWidth int 20 Width passed to the child Triangle item. Unscaled by default.
direction int directions.left Rotation angle (degrees) applied to the child Triangle item. Defaults to -45 (left-pointing).

Triangle child

A single Triangle (id: triangle) is instantiated with:

  • height: triangleHeight, width: triangleWidth
  • rotation: direction
  • anchors.centerIn: parent
  • anchors.horizontalCenterOffset: direction === directions.left ? 5 : -5

The horizontal offset compensates for the visual asymmetry introduced by the rotated-rectangle clipping technique used inside triangle.qml (see below).

triangle.qml internals

triangle.qml renders a triangle by placing a square Rectangle at a corner of a clipping Item and rotating it 45°. The clip: true property on the root Item reveals only the triangular portion of the rotated square.

Property Value Notes
corner int, default 0 Selects which corner of the Item the rectangle is anchored to (0–3, clockwise from top-left). Never set by TriangleButton; always remains 0.
color alias to rect.color Exposed as a direct property alias.
rect.width Math.min(component.width, component.height) Square side equal to the smaller Item dimension.
rect.rotation 45 Fixed internal rotation to form the triangle shape.
rect.scale 1.4 * Theme.heightScale Scales the rectangle to ensure it fills the corner at all display scales.

The orientation of the triangle is controlled entirely by the rotation property set on the Triangle item from TriangleButton, not by the corner property.

States

State Trigger Effect
blurred Default; onExited; onEnabledChanged when disabled triangle.color: blurredColor (white)
focused onEntered triangle.color: focusedColor (#e47125); plays Theme.sounds.buttonFocused

Transitions

Both blurred → focused and focused → blurred use a ColorAnimation on triangle with duration: 75.

Consumer: component-optionslist-input-select.qml

TriangleButton is instantiated twice in component-optionslist-input-select.qml:

Instance id direction visible condition onClicked action
Left arrow leftArrow leftArrow.directions.left selectedIndex !== 0 Emits requestSettingsChange(model, model.options.get(selectedIndex - 1).value)
Right arrow rightArrow rightArrow.directions.right selectedIndex !== model.options.count - 1 Emits requestSettingsChange(model, model.options.get(selectedIndex + 1).value)

Both instances override the default dimensions:

  • width: Math.ceil(40 * Theme.widthScale)
  • triangleWidth: Math.ceil(20 * Theme.heightScale)
  • triangleHeight: Math.ceil(20 * Theme.heightScale)
  • enabled: !model.disabled
  • opacity: enabled ? 1.0 : 0.0 with a 350 ms NumberAnimation behavior

The click sound (Theme.sounds.buttonClicked) is played by the consumer's onClicked handler, not by TriangleButton itself.

Notable observations

1. No disabled state. DefaultButton has an explicit disabled state with dimmed colors. TriangleButton only handles onEnabledChanged by forcing the state to blurred, leaving the triangle white rather than dimmed. The consumer hides the button entirely via opacity: 0 when disabled, so this is not visible in practice, but the component itself provides no disabled visual feedback.

2. No click sound. TriangleButton plays Theme.sounds.buttonFocused on hover but emits no sound on click. The consumer is responsible for playing Theme.sounds.buttonClicked in its own onClicked handler. This is the inverse of DefaultButton, which plays the click sound internally.

3. Default dimensions are unscaled. width: 30, triangleHeight: 20, and triangleWidth: 20 are all raw pixel values with no Theme.widthScale or Theme.heightScale multiplication. Every consumer must override these properties to achieve correct scaling.

4. Double-scaling risk on triangle.qml. The Rectangle inside triangle.qml applies scale: 1.4 * Theme.heightScale. If the consumer also scales triangleHeight and triangleWidth by Theme.heightScale, the rendered triangle is effectively scaled twice: once by the Item dimensions and once by the internal scale factor. At heightScale values significantly above 1.0 this may cause the triangle to overflow its clipping bounds.

5. corner property on Triangle is dead code in this context. TriangleButton never sets corner; it always remains 0 (top-left). All four orientations are achieved by rotating the entire Triangle item via rotation: direction. The corner property exists on triangle.qml for potential standalone use but is unused by its only registered consumer.

6. direction accepts any integer. The directions QtObject provides named constants, but direction is a plain writable int. Passing an arbitrary angle produces a triangle pointing in that direction, which is a valid use case but is undocumented.

7. anchors.horizontalCenterOffset is hardcoded to ±5. The offset is not scaled by Theme.widthScale. At high display scales the visual centering of the triangle within the button area will be slightly off.

button-warning.qml

button-warning.qml defines the WarningButton type, a destructive-action variant of DefaultButton styled with a red color scheme. It is registered in qmldir as WarningButton 1.0 button-warning.qml and is used exclusively inside Alert dialog button rows to represent irreversible or potentially harmful actions.

Registration

Key Value
Type name WarningButton
Version 1.0
Source file button-warning.qml
Base type DefaultButton (button-default.qml)

File Contents

The file is 8 lines and contains only three property overrides on the DefaultButton base:

Property Overridden value Inherited default Effect
bold true false Button label uses Theme.fonts.bold instead of Theme.fonts.regular.
boxColor Theme.colors.warning Theme.colors.buttonText Sets the border color and focusShape fill color to #c72424 (red).
focusedTextColor Theme.colors.buttonText Theme.colors.highlight Sets the focused-state text color to white (#ffffff), overriding the default orange (#e47125).

All other DefaultButton properties are inherited unchanged.

Base Class Behavior (DefaultButton)

DefaultButton (button-default.qml) is a MouseArea root with four child elements:

Child id Type Role
border Rectangle Draws the outer border using boxColor; fill is transparent.
focusShape Rectangle Fills from the bottom of the button; height animates between a small bar (blurred) and full button height (focused).
buttonText Text Displays the text property; font weight controlled by bold.
mouseArea MouseArea Manages hover, click, and disabled state transitions.

The inner mouseArea has three states:

State focusShape height focusShape color Text color Text vertical offset
blurred Math.ceil(8 * Theme.heightScale) boxColor blurredTextColor Math.ceil(-4 * Theme.heightScale)
focused Full button height boxColor focusedTextColor 0
disabled Math.ceil(8 * Theme.heightScale) disabledBoxColor disabledTextColor Math.ceil(-4 * Theme.heightScale)

Transitions between blurred and focused animate focusShape height, text color, and text vertical offset over 150 ms with Easing.OutQuint. The blurred↔disabled and focused↔disabled transitions animate colors only.

Visual Appearance of WarningButton

Combining the overrides with the inherited defaults:

State Border color Fill color Text color Text weight
Blurred #c72424 (red) #c72424 (red, small bar) #ffffff (white) Bold
Focused #c72424 (red) #c72424 (red, full height) #ffffff (white) Bold
Disabled #888888 (gray) #888888 (gray, small bar) #888888 (gray) Bold

Because blurredTextColor (inherited as Theme.colors.buttonText = #ffffff) and focusedTextColor (explicitly set to Theme.colors.buttonText = #ffffff) are identical, the text color does not change between blurred and focused states. The only visible focus indicator is the focusShape expanding to fill the button.

Usage

WarningButton is used in six files, always as a button inside an Alert dialog's VisualItemModel buttons list, or as a standalone action button:

File Context objectName Label Action
routeview-audio.qml Unsaved changes alert ui:btn:action[discard] L10n.strings.buttons.discard Navigates away without applying pending audio option changes.
routeview-video.qml Unsaved changes alert ui:btn:action[discard] L10n.strings.buttons.discard Navigates away without applying pending video option changes.
routeview-savegame.qml Overwrite save confirmation alert ui:btn:action[apply] L10n.strings.buttons.overwriteSave Calls saveGame.saveGameRequest(selectedModel.savename).
routeview-savegame.qml Delete save confirmation alert ui:btn:action[apply] L10n.strings.buttons.deleteSave Calls BlackMesaEngine.removeSaveEntry() and clears the carousel model.
routeview-loadgame.qml Delete save confirmation alert ui:btn:action[apply] L10n.strings.buttons.deleteSave Calls BlackMesaEngine.removeSaveEntry() and clears the carousel model.
routeview-bindings.qml Binding list action row ui:btn:action[clear] L10n.strings.buttons.clearBinding Clears the selected key binding via InputBindingsManager.
component-optionslist.qml Options list footer ui:btn:action[reset] L10n.strings.buttons.resetAllDefaults Resets all options in the current list to defaults and emits settingsReset().

In all alert contexts, WarningButton occupies the "confirm destructive action" position, paired with a DefaultButton for cancel. In the unsaved-changes alerts (audio, video), it is the middle button in a three-button row: CTAButton (apply) → WarningButton (discard) → DefaultButton (cancel).

Notable Issues

1. Text color is identical in blurred and focused states. The explicit override focusedTextColor: Theme.colors.buttonText sets the focused text color to white, which is the same as the inherited blurredTextColor. The only visual change on hover is the focusShape fill expanding. In DefaultButton, the focused text color is Theme.colors.highlight (orange), which provides a distinct color cue; WarningButton suppresses this. The intent is presumably to keep white text readable against the red fill, but it eliminates the text-color transition animation entirely.

2. bold is hardcoded and cannot be overridden by consumers. QML property bindings set in a subtype can be overridden by the instantiating parent, but since bold: true is a direct assignment in the component definition, any consumer that sets bold: false will override it. In practice no consumer does this, but the property is not readonly, so the hardcoding is implicit rather than enforced.

3. Disabled appearance is identical to a disabled DefaultButton. The disabledBoxColor and disabledTextColor properties are not overridden, so a disabled WarningButton renders in #888888 gray — the same as any other disabled button. There is no visual indication that the disabled button was a warning-type action.

4. No id on the root element. Consistent with DefaultButton, the root MouseArea has id: button in the base class, but button-warning.qml does not re-declare an id. Child elements of WarningButton instances cannot reference the root by a WarningButton-specific id.

5. boxColor is not readonly. Consumers can override boxColor after instantiation, which would change the border and fill color away from red. No consumer currently does this, but the warning semantics of the type are not structurally enforced.