Skip to content

Commit

Permalink
Added a boolean and a setter to be able to ignore ImGui Begin/End Child
Browse files Browse the repository at this point in the history
  • Loading branch information
berdal84 committed Jun 2, 2019
1 parent 65d9b66 commit 947e6a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TextEditor::TextEditor()
, mLastClick(-1.0f)
, mHandleKeyboardInputs(true)
, mHandleMouseInputs(true)
, mIgnoreImGuiChild(false)
{
SetPalette(GetDarkPalette());
SetLanguageDefinition(LanguageDefinition::HLSL());
Expand Down Expand Up @@ -838,7 +839,8 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)

ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, ImGui::ColorConvertU32ToFloat4(mPalette[(int)PaletteIndex::Background]));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove);
if( !mIgnoreImGuiChild)
ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NoMove);

if (mHandleKeyboardInputs) {
HandleKeyboardInputs();
Expand All @@ -852,6 +854,7 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)

if (mHandleKeyboardInputs) ImGui::PopAllowKeyboardFocus();

if( !mIgnoreImGuiChild) ImGui::EndChild();
ImGui::PopStyleVar();
ImGui::PopStyleColor();

Expand Down
3 changes: 3 additions & 0 deletions TextEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class TextEditor

void SetHandleMouseInputs (bool aValue){ mHandleMouseInputs = aValue;}
void SetHandleKeyboardInputs (bool aValue){ mHandleKeyboardInputs = aValue;}
void SetImGuiChildIgnored (bool aValue){ mIgnoreImGuiChild = aValue;}

void InsertText(const std::string& aValue);
void InsertText(const char* aValue);

Expand Down Expand Up @@ -339,6 +341,7 @@ class TextEditor
SelectionMode mSelectionMode;
bool mHandleKeyboardInputs;
bool mHandleMouseInputs;
bool mIgnoreImGuiChild;

Palette mPaletteBase;
Palette mPalette;
Expand Down

0 comments on commit 947e6a8

Please sign in to comment.