Skip to content

Commit

Permalink
AA branch: added style.AntiAliasedLines, style.AntiAliasedShapes (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Jul 6, 2015
1 parent 19e5942 commit 56553f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ ImGuiStyle::ImGuiStyle()
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
DisplayWindowPadding = ImVec2(22,22); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
DisplaySafeAreaPadding = ImVec2(4,4); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
AntiAliasedShapes = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)

Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
Expand Down Expand Up @@ -9103,6 +9105,8 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
return;

const ImVec2 uv = GImGui->FontTexUvWhitePixel;
anti_aliased &= GImGui->Style.AntiAliasedLines;
//if (ImGui::GetIO().KeyCtrl) anti_aliased = false;

int start = 0, count = points_count;
if (!closed)
Expand All @@ -9111,8 +9115,6 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
count = points_count-1;
}

//if (ImGui::GetIO().KeyCtrl) anti_aliased = false;

if (anti_aliased)
{
// Anti-aliased stroke
Expand Down Expand Up @@ -9221,7 +9223,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col, bool anti_aliased)
{
const ImVec2 uv = GImGui->FontTexUvWhitePixel;

anti_aliased &= GImGui->Style.AntiAliasedShapes;
//if (ImGui::GetIO().KeyCtrl) anti_aliased = false;

if (anti_aliased)
Expand Down Expand Up @@ -10821,6 +10823,13 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)

ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.55f);

if (ImGui::TreeNode("Rendering"))
{
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
ImGui::Checkbox("Anti-aliased shapes", &style.AntiAliasedShapes);
ImGui::TreePop();
}

if (ImGui::TreeNode("Sizes"))
{
ImGui::SliderFloat("Alpha", &style.Alpha, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI. But application code could have a toggle to switch between zero and non-zero.
Expand Down
2 changes: 2 additions & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ struct ImGuiStyle
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
ImVec2 DisplayWindowPadding; // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
bool AntiAliasedLines; // Enable anti-aliasing on lines/borders. Disable if you are really tight on CPU/GPU.
bool AntiAliasedShapes; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
ImVec4 Colors[ImGuiCol_COUNT];

IMGUI_API ImGuiStyle();
Expand Down

0 comments on commit 56553f3

Please sign in to comment.