Skip to content

Commit

Permalink
add topWindow.style_scrollbarSize
Browse files Browse the repository at this point in the history
  • Loading branch information
tope99 committed Dec 8, 2023
1 parent 660e9fd commit 2c3f89f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
37 changes: 30 additions & 7 deletions src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ void TopWindow::Draw(UIContext& ctx)
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, style_border.eval_px(ctx));
if (style_rounding.has_value())
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, style_rounding.eval_px(ctx));
if (style_scrollbarSize.has_value())
ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarSize, style_scrollbarSize.eval_px(ctx));
if (!style_bg.empty())
ImGui::PushStyleColor(ImGuiCol_WindowBg, style_bg.eval(ctx));
if (!style_menuBg.empty())
Expand Down Expand Up @@ -593,6 +595,8 @@ void TopWindow::Draw(UIContext& ctx)
ImGui::PopStyleColor();
if (!style_menuBg.empty())
ImGui::PopStyleColor();
if (style_scrollbarSize.has_value())
ImGui::PopStyleVar();
if (style_rounding.has_value())
ImGui::PopStyleVar();
if (style_border.has_value())
Expand Down Expand Up @@ -674,6 +678,11 @@ void TopWindow::Export(std::ostream& os, UIContext& ctx)
os << ((kind == Popup || kind == ModalPopup) ? "ImGuiStyleVar_PopupBorderSize" : "ImGuiStyleVar_WindowBorderSize");
os << ", " << style_border.to_arg(ctx.unit) << ");\n";
}
if (style_scrollbarSize.has_value())
{
os << ctx.ind << "ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarSize, "
<< style_scrollbarSize.to_arg(ctx.unit) << ");\n";
}

if (kind == MainWindow)
{
Expand Down Expand Up @@ -869,6 +878,8 @@ void TopWindow::Export(std::ostream& os, UIContext& ctx)
os << ctx.ind << "}\n";
}

if (style_scrollbarSize.has_value())
os << ctx.ind << "ImGui::PopStyleVar();\n";
if (style_border.has_value() || kind == Activity)
os << ctx.ind << "ImGui::PopStyleVar();\n";
if (style_rounding.has_value())
Expand Down Expand Up @@ -957,6 +968,8 @@ void TopWindow::Import(cpp::stmt_iterator& sit, UIContext& ctx)
style_rounding.set_from_arg(sit->params[1]);
else if (sit->params[0] == "ImGuiStyleVar_WindowBorderSize" || sit->params[0] == "ImGuiStyleVar_PopupBorderSize")
style_border.set_from_arg(sit->params[1]);
else if (sit->params[0] == "ImGuiStyleVar_ScrollbarSize")
style_scrollbarSize.set_from_arg(sit->params[1]);
}
else if (sit->kind == cpp::CallExpr && sit->callee == "ImGui::SetNextWindowPos")
{
Expand Down Expand Up @@ -1131,6 +1144,7 @@ TopWindow::Properties()
{ "top.@style.padding", &style_padding },
{ "top.@style.rounding", &style_rounding },
{ "top.@style.border", &style_border },
{ "top.@style.scrollbarSize", &style_scrollbarSize },
{ "top.@style.spacing", &style_spacing },
{ "top.@style.font", &style_font },
{ "top.flags", nullptr },
Expand Down Expand Up @@ -1205,20 +1219,28 @@ bool TopWindow::PropertyUI(int i, UIContext& ctx)
break;
}
case 6:
{
ImGui::Text("scrollbarSize");
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputDirectVal("##style_scrbs", &style_scrollbarSize, ctx);
break;
}
case 7:
{
ImGui::Text("spacing");
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputDirectVal("##style_spacing", &style_spacing, ctx);
break;
}
case 7:
case 8:
ImGui::Text("font");
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputFont("##font", &style_font, ctx);
break;
case 8:
case 9:
TreeNodeProp("flags", "...", [&] {
ImGui::TableNextColumn();
ImGui::Spacing();
Expand All @@ -1231,31 +1253,31 @@ bool TopWindow::PropertyUI(int i, UIContext& ctx)
children.erase(children.begin());
});
break;
case 9:
case 10:
ImGui::Text("title");
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputBindable("##title", &title, ctx);
ImGui::SameLine(0, 0);
BindingButton("title", &title, ctx);
break;
case 10:
case 11:
ImGui::Text("size_x");
ImGui::TableNextColumn();
ImGui::BeginDisabled((flags & ImGuiWindowFlags_AlwaysAutoResize) || (kind == MainWindow && placement == Maximize));
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputBindable("##size_x", &size_x, {}, ctx);
ImGui::EndDisabled();
break;
case 11:
case 12:
ImGui::Text("size_y");
ImGui::TableNextColumn();
ImGui::BeginDisabled((flags & ImGuiWindowFlags_AlwaysAutoResize) || (kind == MainWindow && placement == Maximize));
ImGui::SetNextItemWidth(-ImGui::GetFrameHeight());
changed = InputBindable("##size_y", &size_y, {}, ctx);
ImGui::EndDisabled();
break;
case 12:
case 13:
{
ImGui::Text("placement");
ImGui::TableNextColumn();
Expand Down Expand Up @@ -1283,7 +1305,7 @@ bool TopWindow::PropertyUI(int i, UIContext& ctx)
changed = placement != tmp;
break;
}
case 13:
case 14:
ImGui::BeginDisabled(kind != Popup && kind != ModalPopup);
ImGui::Text("animate");
ImGui::TableNextColumn();
Expand Down Expand Up @@ -1315,6 +1337,7 @@ void TopWindow::ScaleDimensions(float scale)
style_spacing.scale_dimension(scale);
style_rounding.scale_dimension(scale);
style_border.scale_dimension(scale);
style_scrollbarSize.scale_dimension(scale);
}

//-------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ struct TopWindow : UINode
direct_val<pzdimension2> style_spacing;
direct_val<pzdimension> style_border;
direct_val<pzdimension> style_rounding;
direct_val<pzdimension> style_scrollbarSize;
bindable<color32> style_bg;
bindable<color32> style_menuBg;
direct_val<Placement> placement = None;
Expand Down

0 comments on commit 2c3f89f

Please # to comment.