Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Walnut/Platform/GUI/Walnut/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,20 @@ namespace Walnut::UI {
return ImGui::Button(label);
}

bool ButtonLeft(const char* label, const ImVec2& size)
{
ImGuiStyle& style = ImGui::GetStyle();

float actualSize = ImGui::CalcTextSize(label).x + style.FramePadding.x * 2.0f;
float avail = ImGui::GetContentRegionAvail().x;

float off = (avail - actualSize);
if (off > 0.0f)
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + off);

return ImGui::Button(label);
}

void DrawBorder(ImRect rect, float thickness, float rounding, float offsetX, float offsetY)
{
auto min = rect.Min;
Expand Down
1 change: 1 addition & 0 deletions Walnut/Platform/GUI/Walnut/UI/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace Walnut::UI {
void EndMenubar();

bool ButtonCentered(const char* label, const ImVec2& size = ImVec2(0, 0));
bool ButtonLeft(const char* label, const ImVec2& size = ImVec2(0, 0));

// Utilities
class ScopedStyle
Expand Down