yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
split_boundary_drag.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_LAYOUT_LAYOUT_DESIGNER_SPLIT_BOUNDARY_DRAG_H_
2#define YAZE_APP_EDITOR_LAYOUT_LAYOUT_DESIGNER_SPLIT_BOUNDARY_DRAG_H_
3
6#include "imgui/imgui.h"
7
8namespace yaze {
9namespace editor {
10namespace layout_designer {
11
12// Minimum/maximum split_ratio enforced by DockTree::Validate. Exposed here
13// so the drag path clamps before writing back into the tree.
14constexpr float kMinSplitRatio = 0.05f;
15constexpr float kMaxSplitRatio = 0.95f;
16
17// Pixel half-width of the gutter hit zone. Matches ImGui's default dock
18// splitter feel.
19constexpr float kSplitBoundaryTolerance = 4.0f;
20
22 // Split node under the mouse, or nullptr on miss.
23 const DockNode* split_node = nullptr;
24 // true when split axis is X (kLeft/kRight); false for Y.
25 bool horizontal = true;
26};
27
28// Walks `tree` looking for an expanded split whose gutter line is within
29// `tolerance` pixels of `mouse`, with `mouse` also inside the split's
30// bounding rect along the non-axis dimension. Returns the first match
31// (deeper splits win over shallower — children are visited after the
32// current node). Pure geometry; no ImGui context required.
34 const DockTree& tree, const DockTreeLayout& layout, ImVec2 mouse,
35 float tolerance = kSplitBoundaryTolerance);
36
37// Converts a pixel delta along the split's axis into a new split_ratio,
38// clamped to [kMinSplitRatio, kMaxSplitRatio]. `start_ratio` is the
39// ratio captured at drag start and `axis_size_px` is the span of the
40// split's rect along its axis — dividing these out keeps the drag
41// numerically stable across frames.
42float ComputeDraggedSplitRatio(float start_ratio, float axis_delta_px,
43 float axis_size_px);
44
45} // namespace layout_designer
46} // namespace editor
47} // namespace yaze
48
49#endif // YAZE_APP_EDITOR_LAYOUT_LAYOUT_DESIGNER_SPLIT_BOUNDARY_DRAG_H_
SplitBoundaryHit HitTestSplitBoundary(const DockTree &tree, const DockTreeLayout &layout, ImVec2 mouse, float tolerance)
float ComputeDraggedSplitRatio(float start_ratio, float axis_delta_px, float axis_size_px)
Represents a dock node in the layout tree.
Definition dock_tree.h:61