Coder Social home page Coder Social logo

Comments (8)

ElectroidDes avatar ElectroidDes commented on September 17, 2024

How to get resizable child in window?

enum ImGuiChildFlags_
{
    ImGuiChildFlags_None                    = 0,
    ImGuiChildFlags_Border                  = 1 << 0,   // Show an outer border and enable WindowPadding. (IMPORTANT: this is always == 1 == true for legacy reason)
    ImGuiChildFlags_AlwaysUseWindowPadding  = 1 << 1,   // Pad with style.WindowPadding even if no border are drawn (no padding by default for non-bordered child windows because it makes more sense)
    ImGuiChildFlags_ResizeX                 = 1 << 2,   // Allow resize from right border (layout direction). Enable .ini saving (unless ImGuiWindowFlags_NoSavedSettings passed to window flags)
    ImGuiChildFlags_ResizeY                 = 1 << 3,   // Allow resize from bottom border (layout direction). "
    ImGuiChildFlags_AutoResizeX             = 1 << 4,   // Enable auto-resizing width. Read "IMPORTANT: Size measurement" details above.
    ImGuiChildFlags_AutoResizeY             = 1 << 5,   // Enable auto-resizing height. Read "IMPORTANT: Size measurement" details above.
    ImGuiChildFlags_AlwaysAutoResize        = 1 << 6,   // Combined with AutoResizeX/AutoResizeY. Always measure size even when child is hidden, always return true, always disable clipping optimization! NOT RECOMMENDED.
    ImGuiChildFlags_FrameStyle              = 1 << 7,   // Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding.
};

Use flags: ImGuiChildFlags_ResizeX and ImGuiChildFlags_ResizeY

from imgui.

fghoussen avatar fghoussen commented on September 17, 2024

Use flags: ImGuiChildFlags_ResizeX and ImGuiChildFlags_ResizeY

Just tried: same behavior / problem.

from imgui.

ElectroidDes avatar ElectroidDes commented on September 17, 2024
        bool open = true;
        ImGui::Begin("Viewport", &open);

        ImGui::BeginChild("Viewport", { 100,100 }, ImGuiChildFlags_Border| ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_None);

        ImGui::EndChild();

        ImGui::End();

Try it. It works for me, guaranteed.

from imgui.

fghoussen avatar fghoussen commented on September 17, 2024

Trying suppressing image and adding border to see child frontiers:

  bool open = true;
  ImGui::Begin("Viewport", &open);
  ImGui::BeginChild("Viewport", size, ImGuiChildFlags_Border | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY,
  //                                    ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
                                      ImGuiWindowFlags_None);
  //ImGui::Image(reinterpret_cast<void*>(tex), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
  ImGui::EndChild();
  ImGui::End();

And get:

image

from imgui.

ocornut avatar ocornut commented on September 17, 2024

Your question is ambiguous. The child window in your picture should be user resizable, which is what you have asked for. I don’t understand what you are expecting.

from imgui.

fghoussen avatar fghoussen commented on September 17, 2024

I expected the child borders to stick to the ones of the parent window. I guess I misunderstood the meaning of the resize options.

from imgui.

ocornut avatar ocornut commented on September 17, 2024

If you use BeginChild() with the default 0,0 size it will fill all available space. Size=0,0 is the same as using GetContentRegionAvail().

However if you have a window with only a child filling all space inside, then the child window is not necessary.

from imgui.

ocornut avatar ocornut commented on September 17, 2024

Closing as answered, let us know if you have another issue.!

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.