Sizing a child area to fit its content? --> group with border #1496

Open
opened 2017-12-11 22:36:50 +00:00 by dnotq · 19 comments
dnotq commented 2017-12-11 22:36:50 +00:00 (Migrated from github.com)

The BeginChild() function requires an ImVec2 to specify the size of the child. The problem is, I don't know the size of the content at the point where I have to make the BeginChild() call.

I have tried passing in ImVec2(0,0) and ImVec2(-1,-1), but they both cause the child to size to its parent instead of its content.

What did work was ImVec2(0, -ImGui::GetContentRegionAvail().y) until this morning when I pulled the latest changes. Now I get an Assert error on line imgui.cpp:4523 (IM_ASSERT(window_size_x_set_by_api && window_size_y_set_by_api);).

What I am looking for is just a boarder around some widgets. I don't want any scrolling inside the border (child area), it should just take whatever size it needs and cause its parent to scroll if necessary. Is there a way to do this?

Thanks,
Matthew

The `BeginChild()` function requires an `ImVec2` to specify the size of the child. The problem is, I don't know the size of the content at the point where I have to make the `BeginChild()` call. I have tried passing in `ImVec2(0,0)` and `ImVec2(-1,-1)`, but they both cause the child to size to its parent instead of its content. What did work was `ImVec2(0, -ImGui::GetContentRegionAvail().y)` until this morning when I pulled the latest changes. Now I get an Assert error on line `imgui.cpp:4523` (`IM_ASSERT(window_size_x_set_by_api && window_size_y_set_by_api);`). What I am looking for is just a boarder around some widgets. I don't want any scrolling inside the border (child area), it should just take whatever size it needs and cause its parent to scroll if necessary. Is there a way to do this? Thanks, Matthew
ocornut commented 2017-12-11 22:48:49 +00:00 (Migrated from github.com)

Hello @dnotq,

Interestingly a few people haven't been trying to do the same thing. It's quite overkill to use a child window for that so I'd prefer if we had a better solution. I'll still investigate that changed with this assert.

I haven't thought it very much, but you may try something along the line of:

BeginGroup()
...
EndGroup
GetWindowDrawList()->AddRect(GetItemRectMin(), GetItemRectMin(), IM_COL32(...)) ?

I agree we could ideally have primitive to make that sort of things easier.

(Also linking #1395.)

Hello @dnotq, Interestingly a few people haven't been trying to do the same thing. It's quite overkill to use a child window for that so I'd prefer if we had a better solution. I'll still investigate that changed with this assert. I haven't thought it very much, but you may try something along the line of: ``` BeginGroup() ... EndGroup GetWindowDrawList()->AddRect(GetItemRectMin(), GetItemRectMin(), IM_COL32(...)) ? ``` I agree we could ideally have primitive to make that sort of things easier. (Also linking #1395.)
dnotq commented 2017-12-11 23:39:06 +00:00 (Migrated from github.com)

Thanks for the suggestion, I will try to use a group and then draw a rectangle (hopefully I can get rounded corners?)

I agree, using a child window just to get a border seemed like overkill to me too, but I did not see any other controls that offered a border around other content.

Just for reference, before I pulled the latest changes with the assert change I mentioned, using the negative value for the y coordinate gave the desired result (at least in the y axis, I would still like the x axis to shirk too):

ds01

However, specifying a -y value (other than -1) stopped working after I pulled, and if I specify (0,0) or (-1,-1), I now get this:

ds02

The first area always fills the parent and causes a scroll bar, the other child areas are squashed. I did search the issues here on github before posting and found several posts related to this, but nothing seemed to do what I was looking for. Also, I'm not sure what the ImGuiWindowFlags_AlwaysAutoResize flag is for since it never seemed to do what I expected (i.e. I'm not sure when I would use it, but it made no difference in this case if I passed it along with the call to BeginChild()).

This is for a server of sorts, and when a connection is made each area expands with additional details and other data. I would like the child area to always be fully expanded (never have scroll bars) and only the main parent window should ever scroll.

The functionality I'm after is very similar to the Collapsing Group, however add a border, and lose the title and the ability to close the group.

Matthew

Thanks for the suggestion, I will try to use a group and then draw a rectangle (hopefully I can get rounded corners?) I agree, using a child window just to get a border seemed like overkill to me too, but I did not see any other controls that offered a border around other content. Just for reference, before I pulled the latest changes with the assert change I mentioned, using the negative value for the y coordinate gave the desired result (at least in the y axis, I would still like the x axis to shirk too): ![ds01](https://user-images.githubusercontent.com/24464925/33859295-0993ef8c-de88-11e7-9158-e22f7496e814.png) However, specifying a -y value (other than -1) stopped working after I pulled, and if I specify (0,0) or (-1,-1), I now get this: ![ds02](https://user-images.githubusercontent.com/24464925/33859300-0e4c8bd8-de88-11e7-9a0f-148224a95c4b.png) The first area always fills the parent and causes a scroll bar, the other child areas are squashed. I did search the issues here on github before posting and found several posts related to this, but nothing seemed to do what I was looking for. Also, I'm not sure what the `ImGuiWindowFlags_AlwaysAutoResize` flag is for since it never seemed to do what I expected (i.e. I'm not sure when I would use it, but it made no difference in this case if I passed it along with the call to `BeginChild()`). This is for a server of sorts, and when a connection is made each area expands with additional details and other data. I would like the child area to always be fully expanded (never have scroll bars) and only the main parent window should ever scroll. The functionality I'm after is very similar to the Collapsing Group, however add a border, and lose the title and the ability to close the group. Matthew
armadillu commented 2018-07-27 00:11:51 +00:00 (Migrated from github.com)

@dnotq did you find a good way? I'm also looking for some sort of auto-sized panels that enclose their contents in a box growing/shrinking dynamically; ideally with collapsible header too.

I'm trying the suggested aproach Begin/EndGroup() + AddRect(); and with some extra padding around the returned rectangle I can get a nice area; but I can't really add a background color to the panel; I can only draw on top of all the existing gui? Is there a way to reverse drawing order?

screen shot 2018-07-26 at 20 05 09

Maybe there's a way to "run" the layout part of what's inside the Begin/EndGroup() without actually drawing, just to get the final height beforehand? The problem is a lot of these panels offer different gui sliders / options depending on other panels / values in or out of the panel, so its quite hard to nail down the height without actually running all the imgui code.

Edit: Full GUI shot to get a sense of what I'm trying to do here; visually nesting these "panels" would be super useful.

screen shot 2018-07-26 at 20 14 16

@dnotq did you find a good way? I'm also looking for some sort of auto-sized panels that enclose their contents in a box growing/shrinking dynamically; ideally with collapsible header too. I'm trying the suggested aproach Begin/EndGroup() + AddRect(); and with some extra padding around the returned rectangle I can get a nice area; but I can't really add a background color to the panel; I can only draw on top of all the existing gui? Is there a way to reverse drawing order? ![screen shot 2018-07-26 at 20 05 09](https://user-images.githubusercontent.com/167057/43294809-3c98e52e-910f-11e8-8e8c-1d2d67b77d8a.png) Maybe there's a way to "run" the layout part of what's inside the Begin/EndGroup() without actually drawing, just to get the final height beforehand? The problem is a lot of these panels offer different gui sliders / options depending on other panels / values in or out of the panel, so its quite hard to nail down the height without actually running all the imgui code. Edit: Full GUI shot to get a sense of what I'm trying to do here; visually nesting these "panels" would be super useful. ![screen shot 2018-07-26 at 20 14 16](https://user-images.githubusercontent.com/167057/43295104-dc76fb5c-9110-11e8-9a14-13a285459c02.png)
dnotq commented 2018-07-30 07:20:57 +00:00 (Migrated from github.com)

I don't remember what I ended up doing, it has been a while since I messed with that code. I think the group might have done the trick, but I'm not sure (I don't have access to that code right now). I seem to recall realizing that I did not need a full-blown child window. Sorry I can't me of more help.

Matthew

I don't remember what I ended up doing, it has been a while since I messed with that code. I think the group might have done the trick, but I'm not sure (I don't have access to that code right now). I seem to recall realizing that I did not need a full-blown child window. Sorry I can't me of more help. Matthew
sumeet commented 2019-07-25 02:41:29 +00:00 (Migrated from github.com)

i just discovering this now, with a similar need to @armadillu. i hacked around it by drawing twice, first to get the measurements, then blanking it out with a rectangle, then drawing over it again. not totally ideal but it works for me, so i thought i'd share if anyone found this thread looking to do the same thing 😃

i just discovering this now, with a similar need to @armadillu. i hacked around it by drawing twice, first to get the measurements, then blanking it out with a rectangle, then drawing over it again. not totally ideal but it works for me, so i thought i'd share if anyone found this thread looking to do the same thing 😃
otse commented 2019-11-25 09:31:23 +00:00 (Migrated from github.com)

Hello @dnotq,

Interestingly a few people haven't been trying to do the same thing. It's quite overkill to use a child window for that so I'd prefer if we had a better solution. I'll still investigate that changed with this assert.

I haven't thought it very much, but you may try something along the line of:

BeginGroup()
...
EndGroup
GetWindowDrawList()->AddRect(GetItemRectMin(), GetItemRectMin(), IM_COL32(...)) ?

I agree we could ideally have primitive to make that sort of things easier.

(Also linking #1395.)

Could you fix this reply with GetItemRectMax()

> Hello @dnotq, > > Interestingly a few people haven't been trying to do the same thing. It's quite overkill to use a child window for that so I'd prefer if we had a better solution. I'll still investigate that changed with this assert. > > I haven't thought it very much, but you may try something along the line of: > > ``` > BeginGroup() > ... > EndGroup > GetWindowDrawList()->AddRect(GetItemRectMin(), GetItemRectMin(), IM_COL32(...)) ? > ``` > > I agree we could ideally have primitive to make that sort of things easier. > > (Also linking #1395.) Could you fix this reply with GetItemRectMax()
rlalance commented 2019-12-29 01:30:32 +00:00 (Migrated from github.com)

Well, I spend a fairly large amount of time on a similar issue.
I wanted to bunch up a few widgets into sections, but I wanted the frame background or another background.
None of the solution I have seen here work.

Best I could do is to put a white rectangle on top of the elements.

            ImGui::BeginGroup();
            ImGui::Text("Hello from another window!");
            ImGui::Text("Hello from another window!");
            ImGui::Text("Hello from another window!");
            ImGui::EndGroup();
            ImVec2 v = ImVec2(ImGui::GetItemRectMax().x * 1.5, ImGui::GetItemRectMax().y * 1.5);
            ImGui::GetForegroundDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255, 255, 255, 255));

            if (ImGui::CollapsingHeader("header", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed))
            {
                ImGui::Text("Hello from another window!");
                ImGui::Text("Hello from another window!");
                ImGui::Text("Hello from another window!");
            }

Using the GetBackgroundDrawList() instead, showed to rectangles at all.

image

Well, I spend a fairly large amount of time on a similar issue. I wanted to bunch up a few widgets into sections, but I wanted the frame background or another background. None of the solution I have seen here work. Best I could do is to put a white rectangle on top of the elements. ``` ImGui::BeginGroup(); ImGui::Text("Hello from another window!"); ImGui::Text("Hello from another window!"); ImGui::Text("Hello from another window!"); ImGui::EndGroup(); ImVec2 v = ImVec2(ImGui::GetItemRectMax().x * 1.5, ImGui::GetItemRectMax().y * 1.5); ImGui::GetForegroundDrawList()->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255, 255, 255, 255)); if (ImGui::CollapsingHeader("header", ImGuiTreeNodeFlags_DefaultOpen | ImGuiTreeNodeFlags_Framed)) { ImGui::Text("Hello from another window!"); ImGui::Text("Hello from another window!"); ImGui::Text("Hello from another window!"); } ``` Using the GetBackgroundDrawList() instead, showed to rectangles at all. ![image](https://user-images.githubusercontent.com/1323032/71551268-254d6200-29b1-11ea-984b-a81e52e89e1d.png)
thedmd commented 2019-12-31 09:02:29 +00:00 (Migrated from github.com)

Edit: Version without line trough text is here https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353
image

My 3 cents:
image

    ImGui::BeginGroupPanel(ICON_MDI_GPU " Renderer", ImVec2(-1.0f, 0.0f));
    // m_RendererSelector->Draw(); boils down to:
    if (ImGui::BeginThinCombo("Backend:##Backend", currentBackendName.c_str(), ImGuiComboFlags_HeightLarge))
    {
        // ... few calls to: ImGui::Selectable(backendName.c_str(), isSelected)
        ImGui::EndThinCombo();
    }
    m_ResolutionSelector->Draw();
    ImGui::EndGroupPanel();

I end up with something I think looks decent enough and keep other widgets in bay.
Borders is drawn in the middle of the frame and frame is based on ImGui::GetFrameHeight(). Top has more spacing because of the group name.

void ImGui::BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(-1.0f, -1.0f))
{
    ImGui::BeginGroup();

    auto cursorPos = ImGui::GetCursorScreenPos();
    auto itemSpacing = ImGui::GetStyle().ItemSpacing;
    ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
    ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));

    auto frameHeight = ImGui::GetFrameHeight();
    ImGui::BeginGroup();

    ImVec2 effectiveSize = size;
    if (size.x < 0.0f)
        effectiveSize.x = ImGui::GetContentRegionAvail().x;
    else
        effectiveSize.x = size.x;
    ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f));

    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::BeginGroup();
    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::TextUnformatted(name);
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y));
    ImGui::BeginGroup();

    ImGui::PopStyleVar(2);

    ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->WorkRect.Max.x          -= frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->Size.x                  -= frameHeight;

    ImGui::PushItemWidth(effectiveSize.x - frameHeight);
}

void ImGui::EndGroupPanel()
{
    ImGui::PopItemWidth();

    auto itemSpacing = ImGui::GetStyle().ItemSpacing;

    ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
    ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));

    auto frameHeight = ImGui::GetFrameHeight();

    // workaround for incorrect capture of columns/table width by placing
    // zero-sized dummy element in the same group, this ensure
    // max X cursor position is updated correctly
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::Dummy(ImVec2(0.0f, 0.0f));

    ImGui::EndGroup();

    //ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64), 4.0f);

    ImGui::EndGroup();

    ImGui::SameLine(0.0f, 0.0f);
    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y));

    ImGui::EndGroup();

    auto itemMin = ImGui::GetItemRectMin();
    auto itemMax = ImGui::GetItemRectMax();
    //ImGui::GetWindowDrawList()->AddRectFilled(itemMin, itemMax, IM_COL32(255, 0, 0, 64), 4.0f);

    ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f;
    ImGui::GetWindowDrawList()->AddRect(
        itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f),
        ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)),
        halfFrame.x);

    ImGui::PopStyleVar(2);

    ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->WorkRect.Max.x          += frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->Size.x                  += frameHeight;

    ImGui::Dummy(ImVec2(0.0f, 0.0f));

    ImGui::EndGroup();
}
**Edit:** Version without line trough text is here https://github.com/ocornut/imgui/issues/1496#issuecomment-655048353 ![image](https://user-images.githubusercontent.com/1197433/86826863-91f89600-c091-11ea-9e38-1304eb1f2e16.png) My 3 cents: ![image](https://user-images.githubusercontent.com/1197433/71615634-7aa49180-2bb2-11ea-8379-f370a31daa62.png) ```cpp ImGui::BeginGroupPanel(ICON_MDI_GPU " Renderer", ImVec2(-1.0f, 0.0f)); // m_RendererSelector->Draw(); boils down to: if (ImGui::BeginThinCombo("Backend:##Backend", currentBackendName.c_str(), ImGuiComboFlags_HeightLarge)) { // ... few calls to: ImGui::Selectable(backendName.c_str(), isSelected) ImGui::EndThinCombo(); } m_ResolutionSelector->Draw(); ImGui::EndGroupPanel(); ``` I end up with something I think looks decent enough and keep other widgets in bay. Borders is drawn in the middle of the frame and frame is based on `ImGui::GetFrameHeight()`. Top has more spacing because of the group name. ```cpp void ImGui::BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(-1.0f, -1.0f)) { ImGui::BeginGroup(); auto cursorPos = ImGui::GetCursorScreenPos(); auto itemSpacing = ImGui::GetStyle().ItemSpacing; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); auto frameHeight = ImGui::GetFrameHeight(); ImGui::BeginGroup(); ImVec2 effectiveSize = size; if (size.x < 0.0f) effectiveSize.x = ImGui::GetContentRegionAvail().x; else effectiveSize.x = size.x; ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f)); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); ImGui::BeginGroup(); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); ImGui::TextUnformatted(name); ImGui::SameLine(0.0f, 0.0f); ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y)); ImGui::BeginGroup(); ImGui::PopStyleVar(2); ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f; ImGui::GetCurrentWindow()->WorkRect.Max.x -= frameHeight * 0.5f; ImGui::GetCurrentWindow()->Size.x -= frameHeight; ImGui::PushItemWidth(effectiveSize.x - frameHeight); } void ImGui::EndGroupPanel() { ImGui::PopItemWidth(); auto itemSpacing = ImGui::GetStyle().ItemSpacing; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); auto frameHeight = ImGui::GetFrameHeight(); // workaround for incorrect capture of columns/table width by placing // zero-sized dummy element in the same group, this ensure // max X cursor position is updated correctly ImGui::SameLine(0.0f, 0.0f); ImGui::Dummy(ImVec2(0.0f, 0.0f)); ImGui::EndGroup(); //ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64), 4.0f); ImGui::EndGroup(); ImGui::SameLine(0.0f, 0.0f); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y)); ImGui::EndGroup(); auto itemMin = ImGui::GetItemRectMin(); auto itemMax = ImGui::GetItemRectMax(); //ImGui::GetWindowDrawList()->AddRectFilled(itemMin, itemMax, IM_COL32(255, 0, 0, 64), 4.0f); ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f; ImGui::GetWindowDrawList()->AddRect( itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f), ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)), halfFrame.x); ImGui::PopStyleVar(2); ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f; ImGui::GetCurrentWindow()->WorkRect.Max.x += frameHeight * 0.5f; ImGui::GetCurrentWindow()->Size.x += frameHeight; ImGui::Dummy(ImVec2(0.0f, 0.0f)); ImGui::EndGroup(); } ```
rlalance commented 2019-12-31 16:58:26 +00:00 (Migrated from github.com)

You do have a background that looks decent!
Thanks a bunch! Will try that ASAP.

You do have a background that looks decent! Thanks a bunch! Will try that ASAP.
rlalance commented 2019-12-31 17:26:08 +00:00 (Migrated from github.com)

The weird thing about this is that the collapsible header already supports all this correctly IMO.

The weird thing about this is that the collapsible header already supports all this correctly IMO.
gamelaster commented 2020-07-07 11:52:28 +00:00 (Migrated from github.com)

I tried @thedmd solution, it looks fine, but the line is crossing the text (text needs background cover)
image

I tried @thedmd solution, it looks fine, but the line is crossing the text (text needs background cover) ![image](https://user-images.githubusercontent.com/1665373/86777104-0b27c700-c059-11ea-8053-4695f774b3b8.png)
thedmd commented 2020-07-07 18:37:05 +00:00 (Migrated from github.com)

Edit: Update to work with ImGui 1.14 WIP (17301)

@gamelaster I solved that:

image

void BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(0.0f, 0.0f));
void EndGroupPanel();
#define IMGUI_DEFINE_MATH_OPERATORS
#include "imgui_internal.h"

static ImVector<ImRect> s_GroupPanelLabelStack;

void ImGui::BeginGroupPanel(const char* name, const ImVec2& size)
{
    ImGui::BeginGroup();

    auto cursorPos = ImGui::GetCursorScreenPos();
    auto itemSpacing = ImGui::GetStyle().ItemSpacing;
    ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
    ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));

    auto frameHeight = ImGui::GetFrameHeight();
    ImGui::BeginGroup();

    ImVec2 effectiveSize = size;
    if (size.x < 0.0f)
        effectiveSize.x = ImGui::GetContentRegionAvailWidth();
    else
        effectiveSize.x = size.x;
    ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f));

    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::BeginGroup();
    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::TextUnformatted(name);
    auto labelMin = ImGui::GetItemRectMin();
    auto labelMax = ImGui::GetItemRectMax();
    ImGui::SameLine(0.0f, 0.0f);
    ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y));
    ImGui::BeginGroup();

    //ImGui::GetWindowDrawList()->AddRect(labelMin, labelMax, IM_COL32(255, 0, 255, 255));

    ImGui::PopStyleVar(2);

#if IMGUI_VERSION_NUM >= 17301
    ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->WorkRect.Max.x          -= frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->InnerRect.Max.x         -= frameHeight * 0.5f;
#else
    ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x -= frameHeight * 0.5f;
#endif
    ImGui::GetCurrentWindow()->Size.x                   -= frameHeight;

    auto itemWidth = ImGui::CalcItemWidth();
    ImGui::PushItemWidth(ImMax(0.0f, itemWidth - frameHeight));

    s_GroupPanelLabelStack.push_back(ImRect(labelMin, labelMax));
}

void ImGui::EndGroupPanel()
{
    ImGui::PopItemWidth();

    auto itemSpacing = ImGui::GetStyle().ItemSpacing;

    ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f));
    ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));

    auto frameHeight = ImGui::GetFrameHeight();

    ImGui::EndGroup();

    //ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64), 4.0f);

    ImGui::EndGroup();

    ImGui::SameLine(0.0f, 0.0f);
    ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f));
    ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y));

    ImGui::EndGroup();

    auto itemMin = ImGui::GetItemRectMin();
    auto itemMax = ImGui::GetItemRectMax();
    //ImGui::GetWindowDrawList()->AddRectFilled(itemMin, itemMax, IM_COL32(255, 0, 0, 64), 4.0f);

    auto labelRect = s_GroupPanelLabelStack.back();
    s_GroupPanelLabelStack.pop_back();

    ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f;
    ImRect frameRect = ImRect(itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f));
    labelRect.Min.x -= itemSpacing.x;
    labelRect.Max.x += itemSpacing.x;
    for (int i = 0; i < 4; ++i)
    {
        switch (i)
        {
            // left half-plane
            case 0: ImGui::PushClipRect(ImVec2(-FLT_MAX, -FLT_MAX), ImVec2(labelRect.Min.x, FLT_MAX), true); break;
            // right half-plane
            case 1: ImGui::PushClipRect(ImVec2(labelRect.Max.x, -FLT_MAX), ImVec2(FLT_MAX, FLT_MAX), true); break;
            // top
            case 2: ImGui::PushClipRect(ImVec2(labelRect.Min.x, -FLT_MAX), ImVec2(labelRect.Max.x, labelRect.Min.y), true); break;
            // bottom
            case 3: ImGui::PushClipRect(ImVec2(labelRect.Min.x, labelRect.Max.y), ImVec2(labelRect.Max.x, FLT_MAX), true); break;
        }

        ImGui::GetWindowDrawList()->AddRect(
            frameRect.Min, frameRect.Max,
            ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)),
            halfFrame.x);

        ImGui::PopClipRect();
    }

    ImGui::PopStyleVar(2);

#if IMGUI_VERSION_NUM >= 17301
    ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->WorkRect.Max.x          += frameHeight * 0.5f;
    ImGui::GetCurrentWindow()->InnerRect.Max.x         += frameHeight * 0.5f;
#else
    ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x += frameHeight * 0.5f;
#endif
    ImGui::GetCurrentWindow()->Size.x                   += frameHeight;

    ImGui::Dummy(ImVec2(0.0f, 0.0f));

    ImGui::EndGroup();
}
**Edit:** Update to work with ImGui 1.14 WIP (17301) @gamelaster I solved that: ![image](https://user-images.githubusercontent.com/1197433/86826863-91f89600-c091-11ea-9e38-1304eb1f2e16.png) ```cpp void BeginGroupPanel(const char* name, const ImVec2& size = ImVec2(0.0f, 0.0f)); void EndGroupPanel(); ``` ```cpp #define IMGUI_DEFINE_MATH_OPERATORS #include "imgui_internal.h" static ImVector<ImRect> s_GroupPanelLabelStack; void ImGui::BeginGroupPanel(const char* name, const ImVec2& size) { ImGui::BeginGroup(); auto cursorPos = ImGui::GetCursorScreenPos(); auto itemSpacing = ImGui::GetStyle().ItemSpacing; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); auto frameHeight = ImGui::GetFrameHeight(); ImGui::BeginGroup(); ImVec2 effectiveSize = size; if (size.x < 0.0f) effectiveSize.x = ImGui::GetContentRegionAvailWidth(); else effectiveSize.x = size.x; ImGui::Dummy(ImVec2(effectiveSize.x, 0.0f)); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); ImGui::BeginGroup(); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::SameLine(0.0f, 0.0f); ImGui::TextUnformatted(name); auto labelMin = ImGui::GetItemRectMin(); auto labelMax = ImGui::GetItemRectMax(); ImGui::SameLine(0.0f, 0.0f); ImGui::Dummy(ImVec2(0.0, frameHeight + itemSpacing.y)); ImGui::BeginGroup(); //ImGui::GetWindowDrawList()->AddRect(labelMin, labelMax, IM_COL32(255, 0, 255, 255)); ImGui::PopStyleVar(2); #if IMGUI_VERSION_NUM >= 17301 ImGui::GetCurrentWindow()->ContentRegionRect.Max.x -= frameHeight * 0.5f; ImGui::GetCurrentWindow()->WorkRect.Max.x -= frameHeight * 0.5f; ImGui::GetCurrentWindow()->InnerRect.Max.x -= frameHeight * 0.5f; #else ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x -= frameHeight * 0.5f; #endif ImGui::GetCurrentWindow()->Size.x -= frameHeight; auto itemWidth = ImGui::CalcItemWidth(); ImGui::PushItemWidth(ImMax(0.0f, itemWidth - frameHeight)); s_GroupPanelLabelStack.push_back(ImRect(labelMin, labelMax)); } void ImGui::EndGroupPanel() { ImGui::PopItemWidth(); auto itemSpacing = ImGui::GetStyle().ItemSpacing; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f)); auto frameHeight = ImGui::GetFrameHeight(); ImGui::EndGroup(); //ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64), 4.0f); ImGui::EndGroup(); ImGui::SameLine(0.0f, 0.0f); ImGui::Dummy(ImVec2(frameHeight * 0.5f, 0.0f)); ImGui::Dummy(ImVec2(0.0, frameHeight - frameHeight * 0.5f - itemSpacing.y)); ImGui::EndGroup(); auto itemMin = ImGui::GetItemRectMin(); auto itemMax = ImGui::GetItemRectMax(); //ImGui::GetWindowDrawList()->AddRectFilled(itemMin, itemMax, IM_COL32(255, 0, 0, 64), 4.0f); auto labelRect = s_GroupPanelLabelStack.back(); s_GroupPanelLabelStack.pop_back(); ImVec2 halfFrame = ImVec2(frameHeight * 0.25f, frameHeight) * 0.5f; ImRect frameRect = ImRect(itemMin + halfFrame, itemMax - ImVec2(halfFrame.x, 0.0f)); labelRect.Min.x -= itemSpacing.x; labelRect.Max.x += itemSpacing.x; for (int i = 0; i < 4; ++i) { switch (i) { // left half-plane case 0: ImGui::PushClipRect(ImVec2(-FLT_MAX, -FLT_MAX), ImVec2(labelRect.Min.x, FLT_MAX), true); break; // right half-plane case 1: ImGui::PushClipRect(ImVec2(labelRect.Max.x, -FLT_MAX), ImVec2(FLT_MAX, FLT_MAX), true); break; // top case 2: ImGui::PushClipRect(ImVec2(labelRect.Min.x, -FLT_MAX), ImVec2(labelRect.Max.x, labelRect.Min.y), true); break; // bottom case 3: ImGui::PushClipRect(ImVec2(labelRect.Min.x, labelRect.Max.y), ImVec2(labelRect.Max.x, FLT_MAX), true); break; } ImGui::GetWindowDrawList()->AddRect( frameRect.Min, frameRect.Max, ImColor(ImGui::GetStyleColorVec4(ImGuiCol_Border)), halfFrame.x); ImGui::PopClipRect(); } ImGui::PopStyleVar(2); #if IMGUI_VERSION_NUM >= 17301 ImGui::GetCurrentWindow()->ContentRegionRect.Max.x += frameHeight * 0.5f; ImGui::GetCurrentWindow()->WorkRect.Max.x += frameHeight * 0.5f; ImGui::GetCurrentWindow()->InnerRect.Max.x += frameHeight * 0.5f; #else ImGui::GetCurrentWindow()->ContentsRegionRect.Max.x += frameHeight * 0.5f; #endif ImGui::GetCurrentWindow()->Size.x += frameHeight; ImGui::Dummy(ImVec2(0.0f, 0.0f)); ImGui::EndGroup(); } ```
PcChip commented 2020-07-16 01:37:50 +00:00 (Migrated from github.com)

I get several errors about "ContentsRegionRect" not being available - was this deprecated?
I'm really looking for this effect and would love to use the code provided by @thedmd , any ideas?

edit: looks like it was just a typo, I'm assuming he meant "ContentRegionRect"

edit2: it's mostly working, although it cuts off the text for "InputDouble" fields - https://i.imgur.com/4Gge2jY.png

edit3: fix seems to be SetNextItemWidth - https://i.imgur.com/fRFt4sE.png

I'll leave these edits up in case it helps the next person :)

I get several errors about "ContentsRegionRect" not being available - was this deprecated? I'm really looking for this effect and would love to use the code provided by @thedmd , any ideas? edit: looks like it was just a typo, I'm assuming he meant "ContentRegionRect" edit2: it's mostly working, although it cuts off the text for "InputDouble" fields - https://i.imgur.com/4Gge2jY.png edit3: fix seems to be SetNextItemWidth - https://i.imgur.com/fRFt4sE.png I'll leave these edits up in case it helps the next person :)
thedmd commented 2020-07-22 18:47:37 +00:00 (Migrated from github.com)

@PcChip I updated code to work with current ImGui

@PcChip I updated code to work with current ImGui
GasimGasimzada commented 2022-07-30 09:51:08 +00:00 (Migrated from github.com)

Hello, I have been trying to get this this working using Begin/EndGroup and adding Filled Rectangle using DrawList API. Because I am using filled rectangle, the Rect gets drawn on top of the content. Is there a way to change it below the content?

ImGui::BeginGroup();
  if (ImGui::CollapsingHeader("Test")) {
      ImGui::Text("Hello world");
      ImGui::Text("Hello world");
      ImGui::Text("Hello world");
      ImGui::Text("Hello world");
      ImGui::Text("Hello world");
      ImGui::Text("Hello world");
  }
ImGui::EndGroup();

float windowWidth = ImGui::GetContentRegionAvail().x;
auto panelMin = ImGui::GetItemRectMin();
auto panelMax = ImVec2(panelMin.x + windowWidth, ImGui::GetItemRectMax().y);
ImGui::GetWindowDrawList()->AddRectFilled(panelMin, panelMax,
                                          ImColor(255, 255, 0, 255), 2.0f);

Screenshot (Text is below the Rect):

Screenshot

I solved it by separating the draw list channels into two parts and writing the rectangle to channel 0:

ImGui::GetWindowDrawList()->ChannelsSplit(2);
ImGui::GetWindowDrawList()->ChannelsSetCurrent(1);
ImGui::BeginGroup();
...
ImGui::EndGroup();

// Draw below
ImGui::GetWindowDrawList()->ChannelsSetCurrent(0);
float windowWidth = ImGui::GetContentRegionAvail().x;
auto panelMin = ImGui::GetItemRectMin();
auto panelMax = ImVec2(panelMin.x + windowWidth, ImGui::GetItemRectMax().y);
ImGui::GetWindowDrawList()->AddRectFilled(panelMin, panelMax,
                                          ImColor(255, 255, 0, 255), 2.0f);
Hello, I have been trying to get this this working using `Begin/EndGroup` and adding Filled Rectangle using DrawList API. Because I am using filled rectangle, the Rect gets drawn on top of the content. Is there a way to change it below the content? ```cpp ImGui::BeginGroup(); if (ImGui::CollapsingHeader("Test")) { ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); } ImGui::EndGroup(); float windowWidth = ImGui::GetContentRegionAvail().x; auto panelMin = ImGui::GetItemRectMin(); auto panelMax = ImVec2(panelMin.x + windowWidth, ImGui::GetItemRectMax().y); ImGui::GetWindowDrawList()->AddRectFilled(panelMin, panelMax, ImColor(255, 255, 0, 255), 2.0f); ``` Screenshot (Text is below the Rect): ![Screenshot](https://user-images.githubusercontent.com/807231/181905735-c9c5085f-6b79-4f43-bb90-529b0193ce12.png) I solved it by separating the draw list channels into two parts and writing the rectangle to channel 0: ```cpp ImGui::GetWindowDrawList()->ChannelsSplit(2); ImGui::GetWindowDrawList()->ChannelsSetCurrent(1); ImGui::BeginGroup(); ... ImGui::EndGroup(); // Draw below ImGui::GetWindowDrawList()->ChannelsSetCurrent(0); float windowWidth = ImGui::GetContentRegionAvail().x; auto panelMin = ImGui::GetItemRectMin(); auto panelMax = ImVec2(panelMin.x + windowWidth, ImGui::GetItemRectMax().y); ImGui::GetWindowDrawList()->AddRectFilled(panelMin, panelMax, ImColor(255, 255, 0, 255), 2.0f); ```
GasimGasimzada commented 2022-07-30 11:44:40 +00:00 (Migrated from github.com)

After playing around with this API for my use-case, I do not think adding rectangle is the way to go. I need to support two things

  • Adding padding around the content
  • Adding maximum height that stops growing the box and adds scrollbars

Instead of reinventing the wheel here, I want to create a widget based on child windows that autogrows to content instead of autogrowing to parent. So, I wrote a logic that calculates the height based on group and sets the window size using ImGui::SetWindowSize. By debugging, I can see that the height is correct inside ImGui::EndChild; however, the height of the window does not change. Here is the code that I got:

// Setting the height value to disable the auto align axis
ImGui::BeginChild("test child", ImVec2(0.0, 10.0f), true); 

ImGui::BeginGroup();
ImGui::Text("Hello world");
ImGui::Text("Hello world");
ImGui::Text("Hello world");
ImGui::Text("Hello world");
ImGui::EndChild();

auto groupHeight = = ImGui::GetItemRectMax().y - ImGui::GetItemRectMin().y;
// Make sure to autogrow the width component
ImGui::SetWindowSize(ImVec2(0.0f, groupHeight));

// Testing with a fixed value but window size does not change
// ImGui::SetWindowSize(ImVec2(0.0f, 50.0f));

ImGui::EndChild();

Is this not possible to resize the child window while rendering the contents of it? (similar to resizing a normal window).


EDIT: After trying with both windows and groups + draw list API, and for the time being I went with the groups + draw list API for no reason other than it was faster to implemen this:

static XBounds calculateSectionBoundsX(float padding) {
  auto *window = ImGui::GetCurrentWindow();
  float windowStart = ImGui::GetWindowPos().x;

  return {windowStart + window->WindowPadding.x + padding,
          windowStart + ImGui::GetWindowWidth() - window->WindowPadding.x -
              padding};
}

bool beginSection(const char *title) {
  ImGui::GetWindowDrawList()->ChannelsSplit(2);

  // Draw content above the rectangle
  ImGui::GetWindowDrawList()->ChannelsSetCurrent(1);

  auto padding = ImGui::GetStyle().WindowPadding;

  auto *window = ImGui::GetCurrentWindow();
  float windowWidth = ImGui::GetWindowWidth();

  auto boundsX = calculateSectionBoundsX(padding.x);

  // Title will be clipped till the middle
  // because I am going to have a collapsing
  // header there
  const float midPoint = boundsX.start + (boundsX.end - boundsX.start) / 2.0f;

  // Start from padding position
  ImGui::SetCursorPosY(ImGui::GetCursorPosY() + padding.y);
  ImGui::BeginGroup();
  if (padding.x > 0) {
    ImGui::Indent(padding.x);
  }

  ImGui::PushClipRect(ImVec2(boundsX.start, window->ClipRect.Min.y),
                      ImVec2(midPoint, window->ClipRect.Max.y), false);
  ImGui::Text("%s", title);
  ImGui::PopClipRect();

  // Setting clip rectangle for the group contents;
  // so, that text does not overflow outside this widget
  // the parent window is resized
  ImGui::PushClipRect(ImVec2(boundsX.start, window->ClipRect.Min.y),
                      ImVec2(boundsX.end, window->ClipRect.Max.y), false);

  return true;
}

void endSection() {
  auto padding = ImGui::GetStyle().WindowPadding;

  ImGui::PopClipRect();
  if (padding.x > 0) {
    ImGui::Unindent(padding.x);
  }
  ImGui::EndGroup();

  // Essentially, the content is drawn with padding
  // while the rectangle is drawn without padding
  auto boundsX = calculateSectionBoundsX(0.0f);

  // GetItemRectMin is going to include the padding
  // as well; so, remove it
  auto panelMin = ImVec2(boundsX.start, ImGui::GetItemRectMin().y - padding.y);
  auto panelMax = ImVec2(boundsX.end, ImGui::GetItemRectMax().y + padding.y);

  // Draw rectangle below
  ImGui::GetWindowDrawList()->ChannelsSetCurrent(0);
  ImGui::GetWindowDrawList()->AddRectFilled(
      panelMin, panelMax,
      ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg)),
      Theme::getStyle(ThemeStyle::SectionRounding).x);
  ImGui::GetWindowDrawList()->ChannelsMerge();

  // Since rectangle is bigger than the box, move the cursor;
  // so, it starts outside the box
  ImGui::SetCursorPosY(ImGui::GetCursorPosY() + padding.y);

  // Then, add default spacing
  ImGui::Spacing();
}

The only thing that I want to figure out for this is to add scrolling and allow providing a maximum height. One caveat of this approach is that, I cannot nest this widget within itself because the width is always calculated according to the window, not parent widget; however it is something that does not bother me at the moment.

After playing around with this API for my use-case, I do not think adding rectangle is the way to go. I need to support two things - Adding padding around the content - Adding maximum height that stops growing the box and adds scrollbars Instead of reinventing the wheel here, I want to create a widget based on child windows that autogrows to content instead of autogrowing to parent. So, I wrote a logic that calculates the height based on group and sets the window size using `ImGui::SetWindowSize`. By debugging, I can see that the height is correct inside `ImGui::EndChild`; however, the height of the window does not change. Here is the code that I got: ```cpp // Setting the height value to disable the auto align axis ImGui::BeginChild("test child", ImVec2(0.0, 10.0f), true); ImGui::BeginGroup(); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::Text("Hello world"); ImGui::EndChild(); auto groupHeight = = ImGui::GetItemRectMax().y - ImGui::GetItemRectMin().y; // Make sure to autogrow the width component ImGui::SetWindowSize(ImVec2(0.0f, groupHeight)); // Testing with a fixed value but window size does not change // ImGui::SetWindowSize(ImVec2(0.0f, 50.0f)); ImGui::EndChild(); ``` Is this not possible to resize the child window while rendering the contents of it? (similar to resizing a normal window). --- **EDIT:** After trying with both windows and groups + draw list API, and for the time being I went with the groups + draw list API for no reason other than it was faster to implemen this: ```cpp static XBounds calculateSectionBoundsX(float padding) { auto *window = ImGui::GetCurrentWindow(); float windowStart = ImGui::GetWindowPos().x; return {windowStart + window->WindowPadding.x + padding, windowStart + ImGui::GetWindowWidth() - window->WindowPadding.x - padding}; } bool beginSection(const char *title) { ImGui::GetWindowDrawList()->ChannelsSplit(2); // Draw content above the rectangle ImGui::GetWindowDrawList()->ChannelsSetCurrent(1); auto padding = ImGui::GetStyle().WindowPadding; auto *window = ImGui::GetCurrentWindow(); float windowWidth = ImGui::GetWindowWidth(); auto boundsX = calculateSectionBoundsX(padding.x); // Title will be clipped till the middle // because I am going to have a collapsing // header there const float midPoint = boundsX.start + (boundsX.end - boundsX.start) / 2.0f; // Start from padding position ImGui::SetCursorPosY(ImGui::GetCursorPosY() + padding.y); ImGui::BeginGroup(); if (padding.x > 0) { ImGui::Indent(padding.x); } ImGui::PushClipRect(ImVec2(boundsX.start, window->ClipRect.Min.y), ImVec2(midPoint, window->ClipRect.Max.y), false); ImGui::Text("%s", title); ImGui::PopClipRect(); // Setting clip rectangle for the group contents; // so, that text does not overflow outside this widget // the parent window is resized ImGui::PushClipRect(ImVec2(boundsX.start, window->ClipRect.Min.y), ImVec2(boundsX.end, window->ClipRect.Max.y), false); return true; } void endSection() { auto padding = ImGui::GetStyle().WindowPadding; ImGui::PopClipRect(); if (padding.x > 0) { ImGui::Unindent(padding.x); } ImGui::EndGroup(); // Essentially, the content is drawn with padding // while the rectangle is drawn without padding auto boundsX = calculateSectionBoundsX(0.0f); // GetItemRectMin is going to include the padding // as well; so, remove it auto panelMin = ImVec2(boundsX.start, ImGui::GetItemRectMin().y - padding.y); auto panelMax = ImVec2(boundsX.end, ImGui::GetItemRectMax().y + padding.y); // Draw rectangle below ImGui::GetWindowDrawList()->ChannelsSetCurrent(0); ImGui::GetWindowDrawList()->AddRectFilled( panelMin, panelMax, ImGui::GetColorU32(ImGui::GetStyleColorVec4(ImGuiCol_ChildBg)), Theme::getStyle(ThemeStyle::SectionRounding).x); ImGui::GetWindowDrawList()->ChannelsMerge(); // Since rectangle is bigger than the box, move the cursor; // so, it starts outside the box ImGui::SetCursorPosY(ImGui::GetCursorPosY() + padding.y); // Then, add default spacing ImGui::Spacing(); } ``` The only thing that I want to figure out for this is to add scrolling and allow providing a maximum height. One caveat of this approach is that, I cannot nest this widget within itself because the width is always calculated according to the window, not parent widget; however it is something that does not bother me at the moment.
TheGondos commented 2022-10-22 10:10:57 +00:00 (Migrated from github.com)

@thedmd : thanks for the solution, it's a perfect fit and begs to be copy/pasted ; however it is not clear to me what license applies to code posted in here since it's not part of a PR (I'm assuming the CLA applies to PRs, but not code posted inside issues).
Could you clarify the licensing for this code ?
Thanks

@thedmd : thanks for the solution, it's a perfect fit and begs to be copy/pasted ; however it is not clear to me what license applies to code posted in here since it's not part of a PR (I'm assuming the CLA applies to PRs, but not code posted inside issues). Could you clarify the licensing for this code ? Thanks
thedmd commented 2022-10-22 12:00:31 +00:00 (Migrated from github.com)

It is free to use. I put it in public domain.

You can apply any license you wish after making your own copy. If necessary, this can treated also as permission to do exactly that.

Does this solve your problem?

It is free to use. I put it in public domain. You can apply any license you wish after making your own copy. If necessary, this can treated also as permission to do exactly that. Does this solve your problem?
TheGondos commented 2022-10-22 12:43:36 +00:00 (Migrated from github.com)

It is free to use. I put it in public domain.

You can apply any license you wish after making your own copy. If necessary, this can treated also as permission to do exactly that.

Does this solve your problem?

Yes, thank you very much :-)

> It is free to use. I put it in public domain. > > You can apply any license you wish after making your own copy. If necessary, this can treated also as permission to do exactly that. > > Does this solve your problem? Yes, thank you very much :-)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#1496
No description provided.