29 float* pane_width,
float min_width,
31 bool resize_from_left_edge,
32 float collapse_threshold) {
37 bool collapse_requested =
false;
39 const ImVec2 splitter_pos = ImGui::GetCursorScreenPos();
40 ImGui::InvisibleButton(
id, ImVec2(splitter_width, std::max(height, 1.0f)));
41 const bool hovered = ImGui::IsItemHovered();
42 const bool active = ImGui::IsItemActive();
43 if (hovered || active) {
44 ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
46 if (hovered && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
47 *pane_width = ClampWorkbenchPaneWidth(*pane_width, min_width, max_width);
50 const float delta = ImGui::GetIO().MouseDelta.x;
51 const float proposed =
52 resize_from_left_edge ? (*pane_width - delta) : (*pane_width + delta);
53 if (proposed < collapse_threshold) {
54 collapse_requested =
true;
55 *pane_width = min_width;
56 ImGui::SetTooltip(tr(
"Collapse pane"));
58 *pane_width = ClampWorkbenchPaneWidth(proposed, min_width, max_width);
59 ImGui::SetTooltip(tr(
"Width: %.0f px"), *pane_width);
64 splitter_color.w = active ? 0.95f : (hovered ? 0.72f : 0.35f);
65 ImGui::GetWindowDrawList()->AddLine(
66 ImVec2(splitter_pos.x + splitter_width * 0.5f, splitter_pos.y),
67 ImVec2(splitter_pos.x + splitter_width * 0.5f, splitter_pos.y + height),
68 ImGui::GetColorU32(splitter_color), active ? 2.0f : 1.0f);
69 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)