21 float* pane_width,
float min_width,
23 bool resize_from_left_edge,
24 float collapse_threshold) {
29 bool collapse_requested =
false;
31 const ImVec2 splitter_pos = ImGui::GetCursorScreenPos();
32 ImGui::InvisibleButton(
id, ImVec2(splitter_width, std::max(height, 1.0f)));
33 const bool hovered = ImGui::IsItemHovered();
34 const bool active = ImGui::IsItemActive();
35 if (hovered || active) {
36 ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
38 if (hovered && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
39 *pane_width = ClampWorkbenchPaneWidth(*pane_width, min_width, max_width);
42 const float delta = ImGui::GetIO().MouseDelta.x;
43 const float proposed =
44 resize_from_left_edge ? (*pane_width - delta) : (*pane_width + delta);
45 if (proposed < collapse_threshold) {
46 collapse_requested =
true;
47 *pane_width = min_width;
48 ImGui::SetTooltip(tr(
"Collapse pane"));
50 *pane_width = ClampWorkbenchPaneWidth(proposed, min_width, max_width);
51 ImGui::SetTooltip(tr(
"Width: %.0f px"), *pane_width);
56 splitter_color.w = active ? 0.95f : (hovered ? 0.72f : 0.35f);
57 ImGui::GetWindowDrawList()->AddLine(
58 ImVec2(splitter_pos.x + splitter_width * 0.5f, splitter_pos.y),
59 ImVec2(splitter_pos.x + splitter_width * 0.5f, splitter_pos.y + height),
60 ImGui::GetColorU32(splitter_color), active ? 2.0f : 1.0f);
61 return collapse_requested;
bool DrawDungeonWorkbenchVerticalSplitter(const char *id, float height, float *pane_width, float min_width, float max_width, bool resize_from_left_edge, float collapse_threshold)