chore: sync workspace state
This commit is contained in:
@@ -15,6 +15,7 @@ struct PropertyLayoutSpec {
|
||||
float controlColumnStart = InspectorPropertyControlColumnStart();
|
||||
float labelControlGap = InspectorPropertyLabelControlGap();
|
||||
float controlTrailingInset = InspectorPropertyControlTrailingInset();
|
||||
float minimumRowHeight = 0.0f;
|
||||
};
|
||||
|
||||
struct PropertyLayoutMetrics {
|
||||
@@ -32,6 +33,15 @@ inline PropertyLayoutSpec MakePropertyLayout() {
|
||||
return PropertyLayoutSpec{};
|
||||
}
|
||||
|
||||
inline float CalcPropertyRowHeightForFramePadding(const ImVec2& framePadding) {
|
||||
return ImGui::GetFontSize() + framePadding.y * 2.0f + ControlRowHeightOffset();
|
||||
}
|
||||
|
||||
inline PropertyLayoutSpec WithMinimumRowHeight(PropertyLayoutSpec spec, float minimumRowHeight) {
|
||||
spec.minimumRowHeight = std::max(spec.minimumRowHeight, minimumRowHeight);
|
||||
return spec;
|
||||
}
|
||||
|
||||
inline void PushPropertyLayoutStyles() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ControlFramePadding());
|
||||
}
|
||||
@@ -58,6 +68,15 @@ inline void AlignPropertyControlToRight(
|
||||
}
|
||||
}
|
||||
|
||||
inline void AlignPropertyControlVertically(
|
||||
const PropertyLayoutMetrics& layout,
|
||||
float height) {
|
||||
const float offset = std::max((layout.rowHeight - height) * 0.5f, 0.0f);
|
||||
if (offset > 0.0f) {
|
||||
ImGui::SetCursorPosY(layout.cursorPos.y + offset);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DrawControlFn>
|
||||
inline auto DrawPropertyRow(
|
||||
const char* label,
|
||||
@@ -72,7 +91,9 @@ inline auto DrawPropertyRow(
|
||||
const ImVec2 rowCursorPos = ImGui::GetCursorPos();
|
||||
const ImVec2 rowScreenPos = ImGui::GetCursorScreenPos();
|
||||
const float rowWidth = std::max(ImGui::GetContentRegionAvail().x, 1.0f);
|
||||
const float rowHeight = ImGui::GetFrameHeight() + ControlRowHeightOffset();
|
||||
const float rowHeight = std::max(
|
||||
ImGui::GetFrameHeight() + ControlRowHeightOffset(),
|
||||
spec.minimumRowHeight);
|
||||
const float labelInset = std::max(spec.labelInset, 0.0f);
|
||||
const float controlColumnStart = std::clamp(
|
||||
std::max(spec.controlColumnStart, 0.0f),
|
||||
|
||||
Reference in New Issue
Block a user