feat(slider): add tick alignment support for Slider component#592
Merged
18202781743 merged 1 commit intolinuxdeepin:masterfrom Mar 25, 2026
Merged
feat(slider): add tick alignment support for Slider component#59218202781743 merged 1 commit intolinuxdeepin:masterfrom
18202781743 merged 1 commit intolinuxdeepin:masterfrom
Conversation
Add alignToTicks property to Slider, allowing the groove to align with tick marks when enabled. The groove drawing is offset by half the handle width on both ends when alignToTicks is true. 为 Slider 组件添加 alignToTicks 属性,支持滑块槽与刻度标记对齐。 启用时,槽的绘制会在两端偏移半个手柄宽度。 Log: 添加 Slider 刻度对齐功能 PMS: BUG-275271 Influence: 当 TipsSlider 有刻度时,滑块槽会自动与刻度对齐,提升视觉效果。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds an alignToTicks option to the Slider and wires TipsSlider to use it whenever ticks are present, so the groove rendering is horizontally inset by half the handle width at both ends to visually align with tick marks, while keeping vertical behavior unchanged. Class diagram for updated Slider and TipsSlider alignment behaviorclassDiagram
class Slider {
+real dashOffset
+var dashPattern
+bool highlightedPassedGroove
+bool alignToTicks
+bool horizontal
+real leftPadding
+real rightPadding
+Item background
+Item handle
+real implicitWidth
+real implicitHeight
}
class TipsSlider {
+bool horizontal
+TickDirection tickDirection
+var ticks
}
class TickDirection {
<<enumeration>>
Front
Back
}
class SliderGroovePath {
+real startX
+real startY
+real strokeWidth
+real dashOffset
+var dashPattern
+PathLine mainLine
}
class PathLine {
+real x
+real y
}
class Handle {
+real width
+real x
}
TipsSlider *-- Slider : contains __slider
TipsSlider --> TickDirection : uses
Slider *-- SliderGroovePath : draws_groove_with
Slider *-- Handle : uses __handle
SliderGroovePath *-- PathLine : contains
%% Behavior notes modeled as operations on SliderGroovePath
SliderGroovePath : setHorizontalAligned(control_alignToTicks, sliderGroove_width, handle_width)
SliderGroovePath : setHorizontalStart(control_alignToTicks, handle_width)
SliderGroovePath : setHorizontalEnd(control_alignToTicks, sliderGroove_width, handle_width)
%% Logical behavior
Slider : computeGrooveOffsets(horizontal, alignToTicks, handle_width, sliderGroove_width)
TipsSlider : updateAlignToTicks(ticks_length)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
alignToTickslogic repeats the samecontrol.horizontal ? (control.alignToTicks ? __handle.width / 2 : 0) : sliderGroove.width / 2expression in multiple places; consider extracting this into a small helper property (e.g.,grooveStartX) to keep the QML cleaner and reduce the chance of inconsistencies later. - Using
__handle.widthdirectly in the groove start/end calculations assumes the handle is always available and sized; if there are states where the handle is invisible or its width is 0/undefined (e.g., in transitions or alternative styles), it may be safer to guard or default these values to avoid layout glitches.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `alignToTicks` logic repeats the same `control.horizontal ? (control.alignToTicks ? __handle.width / 2 : 0) : sliderGroove.width / 2` expression in multiple places; consider extracting this into a small helper property (e.g., `grooveStartX`) to keep the QML cleaner and reduce the chance of inconsistencies later.
- Using `__handle.width` directly in the groove start/end calculations assumes the handle is always available and sized; if there are states where the handle is invisible or its width is 0/undefined (e.g., in transitions or alternative styles), it may be safer to guard or default these values to avoid layout glitches.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
BLumia
approved these changes
Mar 24, 2026
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add alignToTicks property to Slider, allowing the groove to align with tick marks when enabled. The groove drawing is offset by half the handle width on both ends when alignToTicks is true.
为 Slider 组件添加 alignToTicks 属性,支持滑块槽与刻度标记对齐。
启用时,槽的绘制会在两端偏移半个手柄宽度。
Log: 添加 Slider 刻度对齐功能
PMS: BUG-275271
Influence: 当 TipsSlider 有刻度时,滑块槽会自动与刻度对齐,提升视觉效果。
Summary by Sourcery
Add optional tick-aligned groove rendering to the Slider component and enable it automatically for ticked TipsSlider instances.
New Features:
Enhancements: