mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Merge branch 'master' into viewport (inc Vulkan resize fix merge #1042)
This commit is contained in:
commit
f6fc28dfd2
4
.github/CONTRIBUTING.md
vendored
4
.github/CONTRIBUTING.md
vendored
@ -22,3 +22,7 @@ You may use the Issue tracker to submit bug reports, feature requests or suggest
|
||||
|
||||
If you have been using dear imgui for a while and/or have been using C/C++ for several years and/or have demonstrated good behavior here, it is ok to not fullfill every item to the letter. Those are guidelines and experienced users of dear imgui will know what information are useful in a given context.
|
||||
|
||||
## How to create an Pull Request
|
||||
|
||||
- If you are adding a feature, please explain the context of the change: what do you need the feature for?
|
||||
- Make sure you create a branch for the pull request. In Git, 1 PR is associated to 1 branch. If you keep pushing to the same branch after you submitted the PR, your new commits will appear in the PR.
|
||||
|
9
.github/issue_template.md
vendored
9
.github/issue_template.md
vendored
@ -1,7 +1,12 @@
|
||||
(Please carefully read guidelines in [CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md) then delete this line)
|
||||
You may use the Issue tracker to ask for help, submit bug reports, feature requests or suggestions.
|
||||
Please carefully read this document before doing so:
|
||||
[CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md).
|
||||
|
||||
You can include code this way:
|
||||
You can include code snippets using `Begin()` for short in-line snippets, or:
|
||||
```cpp
|
||||
ImGui::Begin("Hello");
|
||||
ImGui::ThisIsMoreCode();
|
||||
```
|
||||
For multiline snippets.
|
||||
|
||||
(Clear this form before submitting your issue)
|
||||
|
5
.github/pull_request_template.md
vendored
Normal file
5
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
- If you are adding a feature, please explain the context of the change: what do you need the feature for?
|
||||
- Make sure you create a branch for the pull request. In Git, 1 PR is associated to 1 branch. If you keep pushing to the same branch after you submitted the PR, your new commits will appear in the PR.
|
||||
- You can read [CONTRIBUTING.md](https://github.com/ocornut/imgui/blob/master/.github/CONTRIBUTING.md) for more details.
|
||||
|
||||
(Clear this form before submitting your PR)
|
@ -60,6 +60,7 @@ Breaking Changes:
|
||||
- Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
||||
- Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- Obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered style colors as the closing cross uses regular button colors now.
|
||||
- Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
|
||||
- Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side.
|
||||
|
||||
@ -101,6 +102,7 @@ Other Changes:
|
||||
- Style: Enable window border by default. (#707)
|
||||
- Style: Exposed ImGuiStyleVar_WindowTitleAlign, ImGuiStyleVar_ScrollbarSize, ImGuiStyleVar_ScrollbarRounding, ImGuiStyleVar_GrabRounding + added an assert to reduce accidental breakage. (#1181)
|
||||
- Style: Added style.MouseCursorScale help when using the software mouse cursor facility. (#939).
|
||||
- Style: Close button nows display a cross before hovering. Uses button colors for highlight when hovering. (#707)
|
||||
- Popup: OpenPopup() Always reopen existing popup. (Removed imgui_internal.h's OpenPopupEx() which was used for this.) (#1497, #1533).
|
||||
- Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse press. (~#439)
|
||||
- Popup: Better handling of user mistakenly calling OpenPopup() every frame (with reopen_existing option). The error will now be more visible and easier to understand. (#1497)
|
||||
|
1
TODO.txt
1
TODO.txt
@ -30,6 +30,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
!- scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet.
|
||||
- scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro)
|
||||
|
||||
- drawdata: make it easy to clone (or swap?) a ImDrawData so user can easily save that data if they use threaded renderering.
|
||||
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
|
||||
- drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command).
|
||||
- drawlist: primtiives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
// FIXME-VULKAN: Resizing with IMGUI_UNLIMITED_FRAME_RATE triggers errors from the validation layer.
|
||||
#define IMGUI_UNLIMITED_FRAME_RATE
|
||||
#ifdef _DEBUG
|
||||
#define IMGUI_VULKAN_DEBUG_REPORT
|
||||
@ -29,6 +28,8 @@ static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE;
|
||||
static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE;
|
||||
|
||||
static ImGui_ImplVulkan_WindowData g_WindowData;
|
||||
static bool g_ResizeWanted = false;
|
||||
static int g_ResizeWidth = 0, g_ResizeHeight = 0;
|
||||
|
||||
static void check_vk_result(VkResult err)
|
||||
{
|
||||
@ -289,14 +290,8 @@ static void FrameEnd(ImGui_ImplVulkan_WindowData* wd)
|
||||
static void FramePresent(ImGui_ImplVulkan_WindowData* wd)
|
||||
{
|
||||
VkResult err;
|
||||
// If IMGUI_UNLIMITED_FRAME_RATE is defined we present the latest but one frame. Otherwise we present the latest rendered frame
|
||||
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
||||
uint32_t PresentIndex = (wd->FrameIndex + IMGUI_VK_QUEUED_FRAMES - 1) % IMGUI_VK_QUEUED_FRAMES;
|
||||
#else
|
||||
uint32_t PresentIndex = wd->FrameIndex;
|
||||
#endif // IMGUI_UNLIMITED_FRAME_RATE
|
||||
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[PresentIndex];
|
||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||
VkPresentInfoKHR info = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||
info.waitSemaphoreCount = 1;
|
||||
@ -315,7 +310,9 @@ static void glfw_error_callback(int error, const char* description)
|
||||
|
||||
static void glfw_resize_callback(GLFWwindow*, int w, int h)
|
||||
{
|
||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, w, h);
|
||||
g_ResizeWanted = true;
|
||||
g_ResizeWidth = w;
|
||||
g_ResizeHeight = h;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
@ -424,8 +421,6 @@ int main(int, char**)
|
||||
bool show_another_window = false;
|
||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
|
||||
bool swap_chain_has_at_least_one_image = false;
|
||||
|
||||
// Main loop
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
@ -434,6 +429,10 @@ int main(int, char**)
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
glfwPollEvents();
|
||||
|
||||
if (g_ResizeWanted)
|
||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &g_WindowData, g_Allocator, g_ResizeWidth, g_ResizeHeight);
|
||||
g_ResizeWanted = false;
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
@ -480,18 +479,9 @@ int main(int, char**)
|
||||
FrameBegin(wd);
|
||||
ImGui_ImplVulkan_Render(wd->Frames[wd->FrameIndex].CommandBuffer);
|
||||
FrameEnd(wd);
|
||||
|
||||
ImGui::RenderAdditionalViewports();
|
||||
|
||||
#ifdef IMGUI_UNLIMITED_FRAME_RATE
|
||||
// When IMGUI_UNLIMITED_FRAME_RATE is defined we render into latest image acquired from the swapchain but we display the image which was rendered before.
|
||||
// Hence we must render once and increase the FrameIndex without presenting.
|
||||
if (swap_chain_has_at_least_one_image)
|
||||
FramePresent(wd);
|
||||
#else
|
||||
FramePresent(wd);
|
||||
#endif
|
||||
swap_chain_has_at_least_one_image = true;
|
||||
|
||||
wd->FrameIndex = (wd->FrameIndex + 1) % IMGUI_VK_QUEUED_FRAMES;
|
||||
}
|
||||
|
||||
|
46
imgui.cpp
46
imgui.cpp
@ -251,6 +251,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2018/03/12 (1.60) - Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
|
||||
- 2018/03/08 (1.60) - Changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
|
||||
- 2018/03/03 (1.60) - Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
|
||||
- 2018/02/27 (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayPos..DisplayPos+Size range, I don't know of anyone using it)
|
||||
@ -1821,13 +1822,14 @@ float ImGuiMenuColumns::CalcExtraSpace(float avail_w)
|
||||
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
||||
{
|
||||
// Set cursor position and a few other things so that SetScrollHere() 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. Consider moving within SetCursorXXX functions?
|
||||
// FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue.
|
||||
// The clipper should probably have a 4th step to display the last item in a regular manner.
|
||||
ImGui::SetCursorPosY(pos_y);
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
|
||||
window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
|
||||
if (window->DC.ColumnsSet)
|
||||
window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
||||
window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
|
||||
}
|
||||
|
||||
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
|
||||
@ -6741,9 +6743,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Close button
|
||||
if (p_open != NULL)
|
||||
{
|
||||
const float PAD = 2.0f;
|
||||
const float rad = (window->TitleBarHeight() - PAD*2.0f) * 0.5f;
|
||||
if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-PAD - rad, PAD + rad), rad))
|
||||
const float pad = style.FramePadding.y;
|
||||
const float rad = g.FontSize * 0.5f;
|
||||
if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-pad - rad, pad + rad), rad + 1))
|
||||
*p_open = false;
|
||||
}
|
||||
|
||||
@ -7343,9 +7345,6 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
||||
case ImGuiCol_ResizeGrip: return "ResizeGrip";
|
||||
case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered";
|
||||
case ImGuiCol_ResizeGripActive: return "ResizeGripActive";
|
||||
case ImGuiCol_CloseButton: return "CloseButton";
|
||||
case ImGuiCol_CloseButtonHovered: return "CloseButtonHovered";
|
||||
case ImGuiCol_CloseButtonActive: return "CloseButtonActive";
|
||||
case ImGuiCol_PlotLines: return "PlotLines";
|
||||
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
|
||||
case ImGuiCol_PlotHistogram: return "PlotHistogram";
|
||||
@ -8394,17 +8393,16 @@ bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos, float radius)
|
||||
return pressed;
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_CloseButtonActive : hovered ? ImGuiCol_CloseButtonHovered : ImGuiCol_CloseButton);
|
||||
ImVec2 center = bb.GetCenter();
|
||||
window->DrawList->AddCircleFilled(center, ImMax(2.0f, radius), col, 12);
|
||||
|
||||
const float cross_extent = (radius * 0.7071f) - 1.0f;
|
||||
if (hovered)
|
||||
{
|
||||
center -= ImVec2(0.5f, 0.5f);
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), GetColorU32(ImGuiCol_Text));
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), GetColorU32(ImGuiCol_Text));
|
||||
}
|
||||
window->DrawList->AddCircleFilled(center, ImMax(2.0f, radius), GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered), 9);
|
||||
|
||||
float cross_extent = (radius * 0.7071f) - 1.0f;
|
||||
ImU32 cross_col = GetColorU32(ImGuiCol_Text);
|
||||
center -= ImVec2(0.5f, 0.5f);
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), cross_col, 1.0f);
|
||||
window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), cross_col, 1.0f);
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@ -12778,7 +12776,7 @@ void ImGui::Separator()
|
||||
if (window->DC.ColumnsSet)
|
||||
{
|
||||
PushColumnClipRect();
|
||||
window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y;
|
||||
window->DC.ColumnsSet->LineMinY = window->DC.CursorPos.y;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12997,7 +12995,7 @@ void ImGui::NextColumn()
|
||||
PopClipRect();
|
||||
|
||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||
if (++columns->Current < columns->Count)
|
||||
{
|
||||
// Columns 1+ cancel out IndentX
|
||||
@ -13009,10 +13007,10 @@ void ImGui::NextColumn()
|
||||
window->DC.ColumnsOffsetX = 0.0f;
|
||||
window->DrawList->ChannelsSetCurrent(0);
|
||||
columns->Current = 0;
|
||||
columns->CellMinY = columns->CellMaxY;
|
||||
columns->LineMinY = columns->LineMaxY;
|
||||
}
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||
window->DC.CursorPos.y = columns->CellMinY;
|
||||
window->DC.CursorPos.y = columns->LineMinY;
|
||||
window->DC.CurrentLineHeight = 0.0f;
|
||||
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
||||
|
||||
@ -13183,7 +13181,7 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
||||
columns->MaxX = ImMax(content_region_width - window->Scroll.x, columns->MinX + 1.0f);
|
||||
columns->StartPosY = window->DC.CursorPos.y;
|
||||
columns->StartMaxPosX = window->DC.CursorMaxPos.x;
|
||||
columns->CellMinY = columns->CellMaxY = window->DC.CursorPos.y;
|
||||
columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
|
||||
window->DC.ColumnsOffsetX = 0.0f;
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||
|
||||
@ -13230,8 +13228,8 @@ void ImGui::EndColumns()
|
||||
PopClipRect();
|
||||
window->DrawList->ChannelsMerge();
|
||||
|
||||
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
||||
window->DC.CursorPos.y = columns->CellMaxY;
|
||||
columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y);
|
||||
window->DC.CursorPos.y = columns->LineMaxY;
|
||||
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
||||
window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent
|
||||
|
||||
|
13
imgui.h
13
imgui.h
@ -831,9 +831,6 @@ enum ImGuiCol_
|
||||
ImGuiCol_ResizeGrip,
|
||||
ImGuiCol_ResizeGripHovered,
|
||||
ImGuiCol_ResizeGripActive,
|
||||
ImGuiCol_CloseButton,
|
||||
ImGuiCol_CloseButtonHovered,
|
||||
ImGuiCol_CloseButtonActive,
|
||||
ImGuiCol_PlotLines,
|
||||
ImGuiCol_PlotLinesHovered,
|
||||
ImGuiCol_PlotHistogram,
|
||||
@ -843,12 +840,15 @@ enum ImGuiCol_
|
||||
ImGuiCol_DragDropTarget,
|
||||
ImGuiCol_NavHighlight, // gamepad/keyboard: current highlighted item
|
||||
ImGuiCol_NavWindowingHighlight, // gamepad/keyboard: when holding NavMenu to focus/move/resize windows
|
||||
ImGuiCol_COUNT
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
//, ImGuiCol_ComboBg = ImGuiCol_PopupBg // ComboBg has been merged with PopupBg, so a redirect isn't accurate.
|
||||
, ImGuiCol_ChildWindowBg = ImGuiCol_ChildBg, ImGuiCol_Column = ImGuiCol_Separator, ImGuiCol_ColumnHovered = ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive = ImGuiCol_SeparatorActive
|
||||
ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered, // [unused since 1.60+] the close button now uses regular button colors.
|
||||
ImGuiCol_ComboBg, // [unused since 1.53+] ComboBg has been merged with PopupBg, so a redirect isn't accurate.
|
||||
ImGuiCol_COUNT,
|
||||
ImGuiCol_ChildWindowBg = ImGuiCol_ChildBg, ImGuiCol_Column = ImGuiCol_Separator, ImGuiCol_ColumnHovered = ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive = ImGuiCol_SeparatorActive
|
||||
#else
|
||||
ImGuiCol_COUNT
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -1839,6 +1839,7 @@ struct ImFont
|
||||
IMGUI_API void ClearOutputData();
|
||||
IMGUI_API void BuildLookupTable();
|
||||
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
|
||||
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
|
||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
|
||||
bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
|
@ -2223,26 +2223,24 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
||||
{
|
||||
// Display all glyphs of the fonts in separate pages of 256 characters
|
||||
const ImFontGlyph* glyph_fallback = font->FallbackGlyph; // Forcefully/dodgily make FindGlyph() return NULL on fallback, which isn't the default behavior.
|
||||
font->FallbackGlyph = NULL;
|
||||
for (int base = 0; base < 0x10000; base += 256)
|
||||
{
|
||||
int count = 0;
|
||||
for (int n = 0; n < 256; n++)
|
||||
count += font->FindGlyph((ImWchar)(base + n)) ? 1 : 0;
|
||||
count += font->FindGlyphNoFallback((ImWchar)(base + n)) ? 1 : 0;
|
||||
if (count > 0 && ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base+255, count, count > 1 ? "glyphs" : "glyph"))
|
||||
{
|
||||
float cell_size = font->FontSize * 1;
|
||||
float cell_spacing = style.ItemSpacing.y;
|
||||
ImVec2 cell_size(font->FontSize * 1, font->FontSize * 1);
|
||||
ImVec2 base_pos = ImGui::GetCursorScreenPos();
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
for (int n = 0; n < 256; n++)
|
||||
{
|
||||
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size.x + cell_spacing), base_pos.y + (n / 16) * (cell_size.y + cell_spacing));
|
||||
ImVec2 cell_p2(cell_p1.x + cell_size.x, cell_p1.y + cell_size.y);
|
||||
const ImFontGlyph* glyph = font->FindGlyph((ImWchar)(base+n));
|
||||
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
|
||||
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
|
||||
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base+n));
|
||||
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255,255,255,100) : IM_COL32(255,255,255,50));
|
||||
font->RenderChar(draw_list, cell_size.x, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
|
||||
font->RenderChar(draw_list, cell_size, cell_p1, ImGui::GetColorU32(ImGuiCol_Text), (ImWchar)(base+n)); // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions available to generate a string.
|
||||
if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2))
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
@ -2254,11 +2252,10 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
ImGui::Dummy(ImVec2((cell_size.x + cell_spacing) * 16, (cell_size.y + cell_spacing) * 16));
|
||||
ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
font->FallbackGlyph = glyph_fallback;
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
|
@ -165,9 +165,6 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_CloseButton] = ImVec4(0.41f, 0.41f, 0.41f, 0.50f);
|
||||
colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
|
||||
colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -217,9 +214,6 @@ void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.16f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
|
||||
colors[ImGuiCol_CloseButton] = ImVec4(0.50f, 0.50f, 0.90f, 0.50f);
|
||||
colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.70f, 0.70f, 0.90f, 0.60f);
|
||||
colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -272,9 +266,6 @@ void ImGui::StyleColorsLight(ImGuiStyle* dst)
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.80f, 0.80f, 0.80f, 0.56f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 0.50f);
|
||||
colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
|
||||
colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
@ -1841,7 +1832,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
continue;
|
||||
|
||||
const int codepoint = range.first_unicode_codepoint_in_range + char_idx;
|
||||
if (cfg.MergeMode && dst_font->FindGlyph((unsigned short)codepoint))
|
||||
if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint))
|
||||
continue;
|
||||
|
||||
stbtt_aligned_quad q;
|
||||
@ -2205,8 +2196,7 @@ void ImFont::BuildLookupTable()
|
||||
IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1);
|
||||
}
|
||||
|
||||
FallbackGlyph = NULL;
|
||||
FallbackGlyph = FindGlyph(FallbackChar);
|
||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
||||
for (int i = 0; i < max_codepoint + 1; i++)
|
||||
if (IndexAdvanceX[i] < 0.0f)
|
||||
@ -2268,13 +2258,22 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
|
||||
{
|
||||
if (c < IndexLookup.Size)
|
||||
{
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i != (unsigned short)-1)
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
return FallbackGlyph;
|
||||
if (c >= IndexLookup.Size)
|
||||
return FallbackGlyph;
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i == (unsigned short)-1)
|
||||
return FallbackGlyph;
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
|
||||
{
|
||||
if (c >= IndexLookup.Size)
|
||||
return NULL;
|
||||
const unsigned short i = IndexLookup[c];
|
||||
if (i == (unsigned short)-1)
|
||||
return NULL;
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const
|
||||
|
@ -468,9 +468,9 @@ struct ImGuiColumnsSet
|
||||
int Current;
|
||||
int Count;
|
||||
float MinX, MaxX;
|
||||
float StartPosY;
|
||||
float StartMaxPosX; // Backup of CursorMaxPos
|
||||
float CellMinY, CellMaxY;
|
||||
float LineMinY, LineMaxY;
|
||||
float StartPosY; // Copy of CursorPos
|
||||
float StartMaxPosX; // Copy of CursorMaxPos
|
||||
ImVector<ImGuiColumnData> Columns;
|
||||
|
||||
ImGuiColumnsSet() { Clear(); }
|
||||
@ -483,9 +483,9 @@ struct ImGuiColumnsSet
|
||||
Current = 0;
|
||||
Count = 1;
|
||||
MinX = MaxX = 0.0f;
|
||||
LineMinY = LineMaxY = 0.0f;
|
||||
StartPosY = 0.0f;
|
||||
StartMaxPosX = 0.0f;
|
||||
CellMinY = CellMaxY = 0.0f;
|
||||
Columns.clear();
|
||||
}
|
||||
};
|
||||
|
@ -121,8 +121,9 @@ struct FreeTypeTest
|
||||
```
|
||||
|
||||
**Known issues**
|
||||
- Output texture has excessive resolution (lots of vertical waste)
|
||||
- Output texture has excessive resolution (lots of vertical waste).
|
||||
- FreeType's memory allocator is not overridden.
|
||||
- `cfg.OversampleH`, `OversampleV` are ignored (but perhaps not so necessary with this rasterizer).
|
||||
|
||||
**Obligatory comparison screenshots**
|
||||
|
||||
|
@ -17,8 +17,9 @@
|
||||
// The default imgui styles will be impacted by this change (alpha values will need tweaking).
|
||||
|
||||
// TODO:
|
||||
// - Output texture has excessive resolution (lots of vertical waste)
|
||||
// - Output texture has excessive resolution (lots of vertical waste).
|
||||
// - FreeType's memory allocator is not overridden.
|
||||
// - cfg.OversampleH, OversampleV are ignored (but perhaps not so necessary with this rasterizer).
|
||||
|
||||
#include "imgui_freetype.h"
|
||||
#include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*,
|
||||
@ -333,7 +334,7 @@ bool ImGuiFreeType::BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags)
|
||||
{
|
||||
for (uint32_t codepoint = in_range[0]; codepoint <= in_range[1]; ++codepoint)
|
||||
{
|
||||
if (cfg.MergeMode && dst_font->FindGlyph((unsigned short)codepoint))
|
||||
if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint))
|
||||
continue;
|
||||
|
||||
FT_Glyph ft_glyph = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user