mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-03 21:59:15 +08:00
Demo tweaks + general removal of the word dummy were possible with no issues (kept the API call).
This commit is contained in:
parent
55041ac3be
commit
963839373c
@ -573,7 +573,7 @@ Other Changes:
|
||||
because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly
|
||||
enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added
|
||||
equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental back-end. (#2546)
|
||||
- Backends: SDL2: Added dummy ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
|
||||
- Backends: SDL2: Added ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible.
|
||||
(#2482, #2632) [@josiahmanson]
|
||||
- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm]
|
||||
|
||||
@ -733,7 +733,7 @@ Other Changes:
|
||||
- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx.
|
||||
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
|
||||
- Demo: Improved trees in columns demo.
|
||||
- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
||||
- Examples: OpenGL: Added a test GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
|
||||
GL function loaders early, and help users understand what they are missing. (#2421)
|
||||
- Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink]
|
||||
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames]
|
||||
@ -841,7 +841,7 @@ Breaking Changes:
|
||||
|
||||
- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||
- Made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame).
|
||||
If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
||||
If for some reason your time step calculation gives you a zero value, replace it with a arbitrary small value!
|
||||
|
||||
Other Changes:
|
||||
|
||||
@ -1332,7 +1332,7 @@ Other Changes:
|
||||
- ColorEdit: Fixed not being able to pass the ImGuiColorEditFlags_NoAlpha or ImGuiColorEditFlags_HDR flags to SetColorEditOptions().
|
||||
- Nav: Fixed hovering a Selectable() with the mouse so that it update the navigation cursor (as it happened in the pre-1.60 navigation branch). (#787)
|
||||
- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439)
|
||||
- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render a dummy/default glyph. Saves space and allow merging fonts with
|
||||
- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render the default glyph. Saves space and allow merging fonts with
|
||||
overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671)
|
||||
- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769)
|
||||
- Misc: Added IMGUI_DISABLE_MATH_FUNCTIONS in imconfig.h to make it easier to redefine wrappers for std/crt math functions.
|
||||
|
@ -453,7 +453,7 @@ ImGui::End();
|
||||
- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`.
|
||||
- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`.
|
||||
- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window.
|
||||
- You can also create your own dummy window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
- You can also create your own empty window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
|
||||
- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData, and then call your renderer function with your own ImDrawList or ImDrawData data.
|
||||
|
||||
##### [Return to Index](#index)
|
||||
|
@ -365,7 +365,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost.
|
||||
- misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960)
|
||||
- misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?)
|
||||
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
|
||||
- misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682)
|
||||
- misc: use more size_t in public api?
|
||||
- misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui: null/dummy example application
|
||||
// dear imgui: "null" example application
|
||||
// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT)
|
||||
// This is useful to test building, but you cannot interact with anything here!
|
||||
#include "imgui.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||
// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||
@ -179,7 +179,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
strcpy(g_GlslVersionString, glsl_version);
|
||||
strcat(g_GlslVersionString, "\n");
|
||||
|
||||
// Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||
// Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash below.
|
||||
@ -204,7 +204,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
gl_loader = "none";
|
||||
#endif
|
||||
|
||||
// Make a dummy GL call (we don't actually need the result)
|
||||
// Make an arbitrary GL call (we don't actually need the result)
|
||||
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
||||
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||
GLint current_texture;
|
||||
|
20
imgui.cpp
20
imgui.cpp
@ -417,7 +417,7 @@ CODE
|
||||
- 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete).
|
||||
- 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete).
|
||||
- 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
|
||||
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
||||
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with an arbitrary small value!
|
||||
- 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||
- 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
|
||||
- 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
|
||||
@ -1663,8 +1663,8 @@ static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
|
||||
// Not optimal but we very rarely use this function.
|
||||
int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end)
|
||||
{
|
||||
unsigned int dummy = 0;
|
||||
return ImTextCharFromUtf8(&dummy, in_text, in_text_end);
|
||||
unsigned int unused = 0;
|
||||
return ImTextCharFromUtf8(&unused, in_text, in_text_end);
|
||||
}
|
||||
|
||||
static inline int ImTextCountUtf8BytesFromChar(unsigned int c)
|
||||
@ -2160,7 +2160,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
||||
*out_items_display_end = end;
|
||||
}
|
||||
|
||||
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
||||
static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height)
|
||||
{
|
||||
// Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor.
|
||||
// FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue.
|
||||
@ -2192,7 +2192,7 @@ void ImGuiListClipper::Begin(int count, float items_height)
|
||||
{
|
||||
ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display
|
||||
if (DisplayStart > 0)
|
||||
SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor
|
||||
StepNo = 2;
|
||||
}
|
||||
}
|
||||
@ -2203,7 +2203,7 @@ void ImGuiListClipper::End()
|
||||
return;
|
||||
// In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
|
||||
if (ItemsCount < INT_MAX)
|
||||
SetCursorPosYAndSetupDummyPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor
|
||||
SetCursorPosYAndSetupForPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor
|
||||
ItemsCount = -1;
|
||||
StepNo = 3;
|
||||
}
|
||||
@ -2237,7 +2237,7 @@ bool ImGuiListClipper::Step()
|
||||
StepNo = 3;
|
||||
return true;
|
||||
}
|
||||
if (StepNo == 2) // Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3.
|
||||
if (StepNo == 2) // Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3.
|
||||
{
|
||||
IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0);
|
||||
StepNo = 3;
|
||||
@ -3040,7 +3040,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
||||
if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
return false;
|
||||
|
||||
// Special handling for the dummy item after Begin() which represent the title bar or tab.
|
||||
// Special handling for calling after Begin() which represent the title bar or tab.
|
||||
// When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
|
||||
if (window->DC.LastItemId == window->MoveId && window->WriteAccessed)
|
||||
return false;
|
||||
@ -4728,7 +4728,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
||||
{
|
||||
FocusWindow(child_window);
|
||||
NavInitWindow(child_window, false);
|
||||
SetActiveID(id + 1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item
|
||||
SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item
|
||||
g.ActiveIdSource = ImGuiInputSource_Nav;
|
||||
}
|
||||
return ret;
|
||||
@ -7849,7 +7849,7 @@ void ImGui::EndPopup()
|
||||
g.WithinEndChild = false;
|
||||
}
|
||||
|
||||
// Open a popup if mouse is released over the item
|
||||
// Open a popup if mouse button is released over the item
|
||||
bool ImGui::OpenPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
|
14
imgui.h
14
imgui.h
@ -1330,16 +1330,16 @@ enum ImGuiCond_
|
||||
// Helpers: Memory allocations macros
|
||||
// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE()
|
||||
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
|
||||
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||
// Defining a custom placement new() with a custom parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct ImNewDummy {};
|
||||
inline void* operator new(size_t, ImNewDummy, void* ptr) { return ptr; }
|
||||
inline void operator delete(void*, ImNewDummy, void*) {} // This is only required so we can use the symmetrical new()
|
||||
struct ImNewWrapper {};
|
||||
inline void* operator new(size_t, ImNewWrapper, void* ptr) { return ptr; }
|
||||
inline void operator delete(void*, ImNewWrapper, void*) {} // This is only required so we can use the symmetrical new()
|
||||
#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE)
|
||||
#define IM_FREE(_PTR) ImGui::MemFree(_PTR)
|
||||
#define IM_PLACEMENT_NEW(_PTR) new(ImNewDummy(), _PTR)
|
||||
#define IM_NEW(_TYPE) new(ImNewDummy(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
||||
#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper(), _PTR)
|
||||
#define IM_NEW(_TYPE) new(ImNewWrapper(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
|
||||
template<typename T> void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1843,7 +1843,7 @@ struct ImGuiStorage
|
||||
// ImGui::Text("line number %d", i);
|
||||
// - Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
|
||||
// - Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
|
||||
// - (Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
|
||||
// - (Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
|
||||
// - Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
|
||||
struct ImGuiListClipper
|
||||
{
|
||||
|
@ -1243,7 +1243,7 @@ static void ShowDemoWindowWidgets()
|
||||
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
|
||||
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
|
||||
|
||||
// Create a dummy array of contiguous float values to plot
|
||||
// Fill an array of contiguous float values to plot
|
||||
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float
|
||||
// and the sizeof() of your structure in the "stride" parameter.
|
||||
static float values[90] = {};
|
||||
@ -1251,7 +1251,7 @@ static void ShowDemoWindowWidgets()
|
||||
static double refresh_time = 0.0;
|
||||
if (!animate || refresh_time == 0.0)
|
||||
refresh_time = ImGui::GetTime();
|
||||
while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 Hz rate for the demo
|
||||
while (refresh_time < ImGui::GetTime()) // Create data at fixed 60 Hz rate for the demo
|
||||
{
|
||||
static float phase = 0.0f;
|
||||
values[values_offset] = cosf(phase);
|
||||
@ -1351,7 +1351,7 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
ImGui::Text("Color button with Custom Picker Popup:");
|
||||
|
||||
// Generate a dummy default palette. The palette will persist and can be edited.
|
||||
// Generate a default palette. The palette will persist and can be edited.
|
||||
static bool saved_palette_init = true;
|
||||
static ImVec4 saved_palette[32] = {};
|
||||
if (saved_palette_init)
|
||||
@ -1932,8 +1932,8 @@ static void ShowDemoWindowWidgets()
|
||||
if (embed_all_inside_a_child_window)
|
||||
ImGui::EndChild();
|
||||
|
||||
static char dummy_str[] = "This is a dummy field to be able to tab-out of the widgets above.";
|
||||
ImGui::InputText("dummy", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly);
|
||||
static char unused_str[] = "This widget is only here to be able to tab-out of the widgets above.";
|
||||
ImGui::InputText("unused", unused_str, IM_ARRAYSIZE(unused_str), ImGuiInputTextFlags_ReadOnly);
|
||||
|
||||
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
|
||||
// This is useful in particular if you want to create a context menu associated to the title bar of a window.
|
||||
@ -2376,7 +2376,7 @@ static void ShowDemoWindowLayout()
|
||||
ImGui::SameLine(0.0f, spacing);
|
||||
if (ImGui::TreeNode("Node##1"))
|
||||
{
|
||||
// Dummy tree data
|
||||
// Placeholder tree data
|
||||
for (int i = 0; i < 6; i++)
|
||||
ImGui::BulletText("Item %d..", i);
|
||||
ImGui::TreePop();
|
||||
@ -2392,7 +2392,7 @@ static void ShowDemoWindowLayout()
|
||||
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
|
||||
if (node_open)
|
||||
{
|
||||
// Dummy tree data
|
||||
// Placeholder tree data
|
||||
for (int i = 0; i < 6; i++)
|
||||
ImGui::BulletText("Item %d..", i);
|
||||
ImGui::TreePop();
|
||||
@ -2693,7 +2693,7 @@ static void ShowDemoWindowLayout()
|
||||
ImGui::TextWrapped("(Click and drag)");
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
ImVec4 clip_rect(pos.x, pos.y, pos.x + size.x, pos.y + size.y);
|
||||
ImGui::InvisibleButton("##dummy", size);
|
||||
ImGui::InvisibleButton("##empty", size);
|
||||
if (ImGui::IsItemActive() && ImGui::IsMouseDragging(0))
|
||||
{
|
||||
offset.x += ImGui::GetIO().MouseDelta.x;
|
||||
@ -2869,8 +2869,8 @@ static void ShowDemoWindowPopups()
|
||||
ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n");
|
||||
ImGui::Separator();
|
||||
|
||||
//static int dummy_i = 0;
|
||||
//ImGui::Combo("Combo", &dummy_i, "Delete\0Delete harder\0");
|
||||
//static int unused_i = 0;
|
||||
//ImGui::Combo("Combo", &unused_i, "Delete\0Delete harder\0");
|
||||
|
||||
static bool dont_ask_me_next_time = false;
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
@ -2892,7 +2892,7 @@ static void ShowDemoWindowPopups()
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
if (ImGui::MenuItem("Dummy menu item")) {}
|
||||
if (ImGui::MenuItem("Some menu item")) {}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::EndMenuBar();
|
||||
@ -2911,8 +2911,8 @@ static void ShowDemoWindowPopups()
|
||||
// Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which
|
||||
// will close the popup. Note that the visibility state of popups is owned by imgui, so the input value
|
||||
// of the bool actually doesn't matter here.
|
||||
bool dummy_open = true;
|
||||
if (ImGui::BeginPopupModal("Stacked 2", &dummy_open))
|
||||
bool unused_open = true;
|
||||
if (ImGui::BeginPopupModal("Stacked 2", &unused_open))
|
||||
{
|
||||
ImGui::Text("Hello from Stacked The Second!");
|
||||
if (ImGui::Button("Close"))
|
||||
@ -3247,7 +3247,7 @@ static void ShowDemoWindowMisc()
|
||||
if (ImGui::TreeNode("Tabbing"))
|
||||
{
|
||||
ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields.");
|
||||
static char buf[32] = "dummy";
|
||||
static char buf[32] = "hello";
|
||||
ImGui::InputText("1", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::InputText("2", buf, IM_ARRAYSIZE(buf));
|
||||
ImGui::InputText("3", buf, IM_ARRAYSIZE(buf));
|
||||
@ -3903,7 +3903,7 @@ static void ShowExampleAppMainMenuBar()
|
||||
// (future version will add explicit flags to BeginMenu() to request processing shortcuts)
|
||||
static void ShowExampleMenuFile()
|
||||
{
|
||||
ImGui::MenuItem("(dummy menu)", NULL, false, false);
|
||||
ImGui::MenuItem("(demo menu)", NULL, false, false);
|
||||
if (ImGui::MenuItem("New")) {}
|
||||
if (ImGui::MenuItem("Open", "Ctrl+O")) {}
|
||||
if (ImGui::BeginMenu("Open Recent"))
|
||||
@ -4067,8 +4067,8 @@ struct ExampleAppConsole
|
||||
|
||||
// TODO: display items starting from the bottom
|
||||
|
||||
if (ImGui::SmallButton("Add Dummy Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Dummy Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Debug Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Add Debug Error")) { AddLog("[error] something went wrong"); } ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Clear")) { ClearLog(); } ImGui::SameLine();
|
||||
bool copy_to_clipboard = ImGui::SmallButton("Copy");
|
||||
//static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); }
|
||||
@ -4558,7 +4558,7 @@ static void ShowExampleAppLayout(bool* p_open)
|
||||
// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void ShowDummyObject(const char* prefix, int uid)
|
||||
static void ShowPlaceholderObject(const char* prefix, int uid)
|
||||
{
|
||||
// Use object uid as identifier. Most commonly you could also use the object pointer as a base ID.
|
||||
ImGui::PushID(uid);
|
||||
@ -4570,13 +4570,13 @@ static void ShowDummyObject(const char* prefix, int uid)
|
||||
ImGui::NextColumn();
|
||||
if (node_open)
|
||||
{
|
||||
static float dummy_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f };
|
||||
static float placeholder_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f };
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
ImGui::PushID(i); // Use field index as identifier.
|
||||
if (i < 2)
|
||||
{
|
||||
ShowDummyObject("Child", 424242);
|
||||
ShowPlaceholderObject("Child", 424242);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4587,9 +4587,9 @@ static void ShowDummyObject(const char* prefix, int uid)
|
||||
ImGui::NextColumn();
|
||||
ImGui::SetNextItemWidth(-1);
|
||||
if (i >= 5)
|
||||
ImGui::InputFloat("##value", &dummy_members[i], 1.0f);
|
||||
ImGui::InputFloat("##value", &placeholder_members[i], 1.0f);
|
||||
else
|
||||
ImGui::DragFloat("##value", &dummy_members[i], 0.01f);
|
||||
ImGui::DragFloat("##value", &placeholder_members[i], 0.01f);
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
ImGui::PopID();
|
||||
@ -4619,9 +4619,9 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
|
||||
ImGui::Columns(2);
|
||||
ImGui::Separator();
|
||||
|
||||
// Iterate dummy objects with dummy members (all the same data)
|
||||
// Iterate placeholder objects (all the same data)
|
||||
for (int obj_i = 0; obj_i < 3; obj_i++)
|
||||
ShowDummyObject("Object", obj_i);
|
||||
ShowPlaceholderObject("Object", obj_i);
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
@ -4955,10 +4955,12 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
struct ItemLine { ImVec2 p0, p1; ItemLine(const ImVec2& _p0, const ImVec2& _p1) { p0 = _p0; p1 = _p1; } };
|
||||
static ImVector<ItemLine> lines;
|
||||
static ImVec2 scrolling(0.0f, 0.0f);
|
||||
static bool show_grid = true;
|
||||
static bool opt_enable_grid = true;
|
||||
static bool opt_enable_context_menu = true;
|
||||
static bool adding_line = false;
|
||||
|
||||
ImGui::Checkbox("Show grid", &show_grid);
|
||||
ImGui::Checkbox("Enable grid", &opt_enable_grid);
|
||||
ImGui::Checkbox("Enable context menu", &opt_enable_context_menu);
|
||||
ImGui::Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu.");
|
||||
|
||||
// Typically you would use a BeginChild()/EndChild() pair to benefit from a clipping region + own scrolling.
|
||||
@ -5005,17 +5007,18 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
adding_line = false;
|
||||
}
|
||||
|
||||
// Pan (using zero mouse threshold)
|
||||
if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, 0.0f))
|
||||
// Pan (we use a zero mouse threshold when there's no context menu)
|
||||
// You may decide to make that threshold dynamic based on whether the mouse is hovering something etc.
|
||||
const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0f : 0.0f;
|
||||
if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mouse_threshold_for_pan))
|
||||
{
|
||||
scrolling.x += io.MouseDelta.x;
|
||||
scrolling.y += io.MouseDelta.y;
|
||||
}
|
||||
|
||||
// Context menu (under default mouse threshold)
|
||||
// We intentionally use the same button to demonstrate using mouse drag threshold. Some may feel panning should rely on same threshold.
|
||||
ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right);
|
||||
if (drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
||||
if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f)
|
||||
ImGui::OpenPopupContextItem("context");
|
||||
if (ImGui::BeginPopup("context"))
|
||||
{
|
||||
@ -5029,7 +5032,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
|
||||
// Draw grid + all lines in the canvas
|
||||
draw_list->PushClipRect(canvas_p0, canvas_p1, true);
|
||||
if (show_grid)
|
||||
if (opt_enable_grid)
|
||||
{
|
||||
const float GRID_STEP = 64.0f;
|
||||
for (float x = fmodf(scrolling.x, GRID_STEP); x < canvas_sz.x; x += GRID_STEP)
|
||||
@ -5095,7 +5098,7 @@ struct MyDocument
|
||||
void DoForceClose() { Open = false; Dirty = false; }
|
||||
void DoSave() { Dirty = false; }
|
||||
|
||||
// Display dummy contents for the Document
|
||||
// Display placeholder contents for the Document
|
||||
static void DisplayContents(MyDocument* doc)
|
||||
{
|
||||
ImGui::PushID(doc);
|
||||
|
@ -2307,8 +2307,8 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
const int codepoint = src_tmp.GlyphsList[glyph_i];
|
||||
const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i];
|
||||
stbtt_aligned_quad q;
|
||||
float dummy_x = 0.0f, dummy_y = 0.0f;
|
||||
stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &dummy_x, &dummy_y, &q, 0);
|
||||
float unused_x = 0.0f, unused_y = 0.0f;
|
||||
stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &unused_x, &unused_y, &q, 0);
|
||||
dst_font->AddGlyph(&cfg, (ImWchar)codepoint, q.x0 + font_off_x, q.y0 + font_off_y, q.x1 + font_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
|
||||
}
|
||||
}
|
||||
|
@ -5205,9 +5205,9 @@ void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags fl
|
||||
if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup
|
||||
g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask);
|
||||
SetCursorScreenPos(backup_pos);
|
||||
ImVec4 dummy_ref_col;
|
||||
memcpy(&dummy_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4));
|
||||
ColorPicker4("##dummypicker", &dummy_ref_col.x, picker_flags);
|
||||
ImVec4 previewing_ref_col;
|
||||
memcpy(&previewing_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4));
|
||||
ColorPicker4("##previewing_picker", &previewing_ref_col.x, picker_flags);
|
||||
PopID();
|
||||
}
|
||||
PopItemWidth();
|
||||
@ -5679,7 +5679,7 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags
|
||||
// - Selectable()
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Tip: pass a non-visible label (e.g. "##dummy") then you can use the space to draw other text or image.
|
||||
// Tip: pass a non-visible label (e.g. "##hello") then you can use the space to draw other text or image.
|
||||
// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id.
|
||||
// With this scheme, ImGuiSelectableFlags_SpanAllColumns and ImGuiSelectableFlags_AllowItemOverlap are also frequently used flags.
|
||||
// FIXME: Selectable() with (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported.
|
||||
@ -7121,7 +7121,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
const ImGuiStyle& style = g.Style;
|
||||
const ImGuiID id = TabBarCalcTabID(tab_bar, label);
|
||||
|
||||
// If the user called us with *p_open == false, we early out and don't render. We make a dummy call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID.
|
||||
// If the user called us with *p_open == false, we early out and don't render.
|
||||
// We make a call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID.
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags);
|
||||
if (p_open && !*p_open)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user