From 477e2b314a0f1cdc9206be16a03bd7404f4c7880 Mon Sep 17 00:00:00 2001 From: attilaz Date: Sat, 17 Jun 2017 20:14:44 +0200 Subject: [PATCH] 11-fontsdf converted to dear imgui (#1166) --- examples/11-fontsdf/fontsdf.cpp | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/examples/11-fontsdf/fontsdf.cpp b/examples/11-fontsdf/fontsdf.cpp index e22d0e13e..0ce30759b 100644 --- a/examples/11-fontsdf/fontsdf.cpp +++ b/examples/11-fontsdf/fontsdf.cpp @@ -131,42 +131,43 @@ class ExampleFontSDF : public entry::AppI , uint16_t(m_width) , uint16_t(m_height) ); - - const int32_t guiPanelWidth = 250; + + const int32_t guiPanelWidth = 325; const int32_t guiPanelHeight = 200; - - imguiBeginScrollArea("Text Area" - , m_width - guiPanelWidth - 10 - , 10 - , guiPanelWidth - , guiPanelHeight - , &m_scrollArea - ); - imguiSeparatorLine(); + + ImGui::SetNextWindowPos(ImVec2(m_width - guiPanelWidth - 10.0f, 10.0f) ); + ImGui::Begin("Text Area" + , NULL + , ImVec2(guiPanelWidth, guiPanelHeight) + , ImGuiWindowFlags_AlwaysAutoResize + ); + + ImGui::Separator(); bool recomputeVisibleText = false; - recomputeVisibleText |= imguiSlider("Number of lines", m_visibleLineCount, 1.0f, 177.0f , 1.0f); - if (imguiSlider("Font size", m_textSize, 6.0f, 64.0f , 1.0f) ) + recomputeVisibleText |= ImGui::SliderFloat("Number of lines", &m_visibleLineCount, 1.0f, 177.0f); + + if (ImGui::SliderFloat("Font size", &m_textSize, 6.0f, 64.0f) ) { m_fontManager->destroyFont(m_fontScaled); m_fontScaled = m_fontManager->createScaledFontToPixelSize(m_fontSdf, (uint32_t) m_textSize); m_metrics = TextLineMetrics(m_fontManager->getFontInfo(m_fontScaled) ); recomputeVisibleText = true; } - - recomputeVisibleText |= imguiSlider("Scroll", m_textScroll, 0.0f, (m_lineCount-m_visibleLineCount) , 1.0f); - imguiSlider("Rotate", m_textRotation, 0.0f, bx::kPi*2.0f , 0.1f); - recomputeVisibleText |= imguiSlider("Scale", m_textScale, 0.1f, 10.0f , 0.1f); - + + recomputeVisibleText |= ImGui::SliderFloat("Scroll", &m_textScroll, 0.0f, (m_lineCount-m_visibleLineCount)); + ImGui::SliderFloat("Rotate", &m_textRotation, 0.0f, bx::kPi*2.0f); + recomputeVisibleText |= ImGui::SliderFloat("Scale", &m_textScale, 0.1f, 10.0f); + if (recomputeVisibleText) { m_textBufferManager->clearTextBuffer(m_scrollableBuffer); m_metrics.getSubText(m_bigText,(uint32_t)m_textScroll, (uint32_t)(m_textScroll+m_visibleLineCount), m_textBegin, m_textEnd); m_textBufferManager->appendText(m_scrollableBuffer, m_fontScaled, m_textBegin, m_textEnd); } - - imguiEndScrollArea(); - + + ImGui::End(); + imguiEndFrame(); // Set view 0 default viewport.