AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.11k stars 127 forks source link

g.Label("very long ........ text") is not shown completely #781

Closed francmarx closed 3 months ago

francmarx commented 3 months ago

What happend?

if you put some very long text string into g.Label(), string is not shown completely, only the first 3000 chars

Code example

simply try this:

g.Label(strings.Repeat("testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest\n", 40)),

Version

master

OS

linux

AllenDang commented 3 months ago

The limitation comes from upstream imgui.

francmarx commented 3 months ago

In the earlier versions (imgui-go), labels with strings >3000 were possible, was anything changed in the upstream imgui?

gucio321 commented 3 months ago

strange, something with imgui has to be broken... I'll check this when my local cimgui compiles :smile:

gucio321 commented 3 months ago

in cimgui that seems to work... image

I'll check in giu as I compile it

gucio321 commented 3 months ago

in giu it works as well image @francmarx did you use Label(...).Wrapped(true)?

francmarx commented 3 months ago

@AllenDang no, I don't use Wrapped(true).

try much more then 3000 characters:

g.Label(strings.Repeat("testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest\n", 50))

gives left side, but should look like right side:

image

gucio321 commented 3 months ago

I see, could you check if it also happens in C++ imgui?

gucio321 commented 3 months ago

It happens to cimgui-go too

gucio321 commented 3 months ago

this seems to be something in Dear ImGui

        ImGui::SetNextWindowSize(ImVec2{600,600});
        ImGui::Begin("Window");
        if (ImGui::Button("Add")) {
                j++;
        }
        ImGui::PushTextWrapPos();
        ImGui::Text(std::string(j*100, 'x').c_str());
        ImGui::End();

this acts the same

let me ping @ocornut at this point. let us know if we should open an issue in imgui repo

ocornut commented 3 months ago

TextUnformatted() doesn't have a limitation, while Text() does. I don't know how Go works and why the function is called "Label" but if you can detect that there's no formatting ongoing (single param) you could call TextUnformatted() instead of Text().

gucio321 commented 3 months ago

WHat means "formatting" in Text? is it just something like Sprintf does?

gucio321 commented 3 months ago

ok I see:

// raw text without formatting. Roughly equivalent to Text("TextUnformattedV", text) but: A) doesn't require null terminated string if '
francmarx commented 3 months ago

@ocornut TextWidget.go has always used imgui.Text(), with earlier versions of imgui it was possible to use very long texts without any problems. Has anything significant changed in recent versions of imgui.Text() in imgui?

gucio321 commented 3 months ago

@francmarx it works now

francmarx commented 3 months ago

@gucio321 thanks. (but there must be a significant change in recent version of imgui, in earlier versions it worked)

gucio321 commented 3 months ago

I think that

  1. we're using docking branch
  2. previous versions of giu were on imgui-go (which was on 1.86) and now we're using cimgui-go with upstream so 1.90.4+

something could have chaged

ocornut commented 3 months ago

I don’t think it has changed, no. Tho the underlying tempbuffer system now technically allowing resizing so its possible to “fix” it with Text() function but i am not sure it is a great idea to encourage large formattiings.