Skip to content

Commit

Permalink
Reorganize toolbar icons
Browse files Browse the repository at this point in the history
  • Loading branch information
tpecholt committed Jan 18, 2025
1 parent 960e83a commit 95d9811
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
40 changes: 20 additions & 20 deletions src/imrad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,24 +1171,6 @@ void ToolbarUI()
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);

ImGui::SameLine();
bool showHelper = activeTab >= 0 &&
ctx.selected.size() >= 1 &&
(ctx.selected[0]->Behavior() & UINode::SnapSides);
ImGui::BeginDisabled(!showHelper);
if (ImGui::Button(ICON_FA_LEFT_RIGHT))
{
horizLayout.root = fileTabs[activeTab].rootNode.get();
HorizLayout::ExpandSelection(ctx.selected, horizLayout.root);
horizLayout.selected = ctx.selected;
horizLayout.ctx = &ctx;
horizLayout.OpenPopup();
}
ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
ImGui::SetTooltip("Table Layout Helper");
ImGui::SameLine();

ImGui::SameLine();
ImGui::BeginDisabled(activeTab < 0);
if (ImGui::Button(ICON_FA_BOLT) || // ICON_FA_BOLT, ICON_FA_RIGHT_TO_BRACKET) ||
Expand All @@ -1209,6 +1191,24 @@ void ToolbarUI()
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
ImGui::SetTooltip("Class Wizard");

ImGui::SameLine();
bool showHelper = activeTab >= 0 &&
ctx.selected.size() >= 1 &&
(ctx.selected[0]->Behavior() & UINode::SnapSides);
ImGui::BeginDisabled(!showHelper);
if (ImGui::Button(ICON_FA_BORDER_NONE))
{
horizLayout.root = fileTabs[activeTab].rootNode.get();
HorizLayout::ExpandSelection(ctx.selected, horizLayout.root);
horizLayout.selected = ctx.selected;
horizLayout.ctx = &ctx;
horizLayout.OpenPopup();
}
ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))
ImGui::SetTooltip("Table Layout Helper");
ImGui::SameLine();

ImGui::EndDisabled();

ImGui::SameLine();
Expand Down Expand Up @@ -1236,8 +1236,8 @@ void ToolbarUI()
}

ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);

float defHeight = ImGui::GetFrameHeightWithSpacing();
ImGui::Dummy(ImGui::CalcItemSize({ -defHeight, 1 }, 0, 0));
ImGui::SameLine();
if (ImGui::Button(ICON_FA_CIRCLE_INFO) ||
ImGui::Shortcut(ImGuiKey_F1, ImGuiInputFlags_RouteGlobal))
Expand Down
19 changes: 11 additions & 8 deletions src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,21 +1860,21 @@ bool Widget::EventUI(int i, UIContext& ctx)

void Widget::TreeUI(UIContext& ctx)
{
std::string label;
std::string label, typeLabel;
const auto props = Properties();
for (const auto& p : props) {
if (p.kbdInput && p.property->c_str()) {
label = cpp::to_draw_str(p.property->c_str());
}
}
if (label.empty()) {
label = typeid(*this).name();
auto i = label.find(' ');
typeLabel = typeid(*this).name();
auto i = typeLabel.find(' ');
if (i != std::string::npos)
label.erase(0, i + 1);
auto it = stx::find_if(label, [](char c) { return isalpha(c); });
if (it != label.end())
label.erase(0, it - label.begin());
typeLabel.erase(0, i + 1);
auto it = stx::find_if(typeLabel, [](char c) { return isalpha(c); });
if (it != typeLabel.end())
typeLabel.erase(0, it - typeLabel.begin());
}
std::string icon = ICON_FA_BARS;
if (GetIcon()) {
Expand Down Expand Up @@ -1918,7 +1918,10 @@ void Widget::TreeUI(UIContext& ctx)
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[selected ? ImGuiCol_ButtonHovered : ImGuiCol_Text]);
ImGui::SameLine();
ImGui::PushFont(ctx.defaultFont);
ImGui::Text("%s", label.c_str());
if (label != "")
ImGui::Text("\"%s\"", label.c_str());
else
ImGui::Text("%s", typeLabel.c_str());
ImGui::PopFont();
ImGui::PopStyleColor();
ImGui::SameLine();
Expand Down

0 comments on commit 95d9811

Please sign in to comment.