Skip to content
Merged
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
10 changes: 7 additions & 3 deletions raylib_widgets/src/CompassRuler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ namespace raylib_widgets
{
const float compassSize = 200.0f;
const float originX = compassSize * 0.5f;
const float originY = static_cast<float>(GetScreenHeight()) - bottomInset - compassSize * 0.5f;
// Lay out from the bottom edge up so the ruler label stays inside the window.
const int labelFontSize = 14;
const float labelMargin = 4.0f;
const float labelGap = 6.0f;
const float rulerY = static_cast<float>(GetScreenHeight()) - bottomInset - labelMargin - labelFontSize - labelGap;
const float originY = rulerY - compassSize * 0.45f;
const float axisPixelLength = compassSize * 0.35f;

struct Axis
Expand Down Expand Up @@ -53,11 +58,10 @@ namespace raylib_widgets
else
snprintf(label, sizeof(label), "<1 [cm]");

float rulerY = originY + compassSize * 0.45f;
DrawLineEx(Vector2{ originX - 40.f, rulerY }, Vector2{ originX + 40.f, rulerY }, 2.f, rulerColor);
DrawLineEx(Vector2{ originX - 40.f, rulerY - 5.f }, Vector2{ originX - 40.f, rulerY + 5.f }, 2.f, rulerColor);
DrawLineEx(Vector2{ originX + 40.f, rulerY - 5.f }, Vector2{ originX + 40.f, rulerY + 5.f }, 2.f, rulerColor);
DrawText(label, (int)originX - 20, (int)rulerY + 6, 14, rulerColor);
DrawText(label, (int)(originX - MeasureText(label, labelFontSize) * 0.5f), (int)(rulerY + labelGap), labelFontSize, rulerColor);
}

} // namespace raylib_widgets
Loading