Strange behaviour with window padding

Hello,

I’m not sure if it’s an issue actually or I just got something wrong.
I have follwoing code from the examples and modified it to get rid of the main window padding:

ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::Begin("Main", nullptr, ImVec2(display_w, display_h), 0.0f, kMainWndFlags);
ImGui::PopStyleVar();
if (ImGui::BeginMenuBar()) {
	if (ImGui::BeginMenu("File")) {
		if (ImGui::MenuItem("Close", "Ctrl+W")) { kAppState.active = false; }
		ImGui::EndMenu();
		}
		ImGui::EndMenuBar();
            }
   }
  ImGui::End();
  ImGui::PopStyleVar(); // padding

If I run this code the main window has no padding as intended but the “file” menu item also has no top padding.
What am I doing wrong here?

See following screenshot: https://imgur.com/a/QdjCZ9v

Thx in advance. Regards.

(That code you posted has unbalanced PopStyleVar() so as-is, this should crash/assert, suggested that you aren’t actually using the code you posted.)

This works well with the current version of imgui:

image

Your version looks too old you should update.

Hello, thx . Yes indeed :wink:

I got my Version from buckaroo and later discovered there is a newer available.

Regards

1 Like