Compare commits

...

14 Commits
v1.08 ... v1.09

Author SHA1 Message Date
cd3d027df0 Delete obsolete comments in imconfig.h 2014-08-28 14:54:22 +01:00
7adad71042 Moved IMGUI_FONT_TEX_UV_FOR_WHITE define to a variable so font can be changed at runtime 2014-08-28 14:53:41 +01:00
88c33ecc29 Fixes to allow clean 1-pixel thick lines in more use cases. PixelCenterOffset not the same as previously! 2014-08-28 14:52:10 +01:00
1f63e01cc6 Minor fixes to scrollbar rendering, close button and made checkbox/radio button padding more consistent. 2014-08-27 22:16:55 +01:00
bd26de0628 Collapse triangle don't have a shadow unless borders are enabled.
Fixed cross that appears when hovering window close button to be perfectly 45 degrees.
2014-08-27 17:54:11 +01:00
5a9639b423 Fixed collapsing header border (if borders are enabled) being off the clip rectangle.
Tweak demo window.
2014-08-27 11:38:26 +01:00
b90d0c558d Minor text alignment 2014-08-26 19:22:09 +01:00
51f8e33eb4 Added FAQ entry 2014-08-26 18:29:58 +01:00
80dd1e1065 Added comments 2014-08-26 18:27:10 +01:00
5f6b261c9b Fixed uninitialised fields in ImBitmapFont (were unused when uninitialised, but still dodgy) 2014-08-26 18:14:04 +01:00
681ac5f777 Fixed size/padding of slider grab box for vertical symetry (was 1 pixel too high) 2014-08-26 16:56:20 +01:00
0d344e1f03 Merge pull request #34 from orbitcowboy/master
Do not update a variable, which is not used.
2014-08-26 14:28:40 +01:00
d2b43f31e3 Updated URL to new ProggyFonts site 2014-08-25 17:27:42 +01:00
addfa75eb0 Do not update a variable, which is not used. 2014-08-24 07:32:27 +02:00
6 changed files with 100 additions and 74 deletions

View File

@ -36,9 +36,14 @@ Frequently Asked Question
I recommend using [Synergy](http://synergy-project.org) and the uSynergy.c micro client to share your mouse and keyboard. This way you can seemingly use your PC input devices on a video game console or a tablet. ImGui was also designed to function with touch inputs if you increase the padding of widgets to compensate for the lack of precision of touch devices, but it is recommended you use a mouse to allow optimising for screen real-estate.
<b>I integrated ImGui in my engine and the text or lines are blurry..</b>
- Try adjusting ImGui::GetIO().PixelCenterOffset to 0.0f or 0.5f.
- In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
<b>Can you create elaborate/serious tools with ImGui?</b>
Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. There's no reason you cannot, and in my experience the simplicity of the API is very empowering. However note that ImGui is very programmer centric and the immediate-mode GUI paradigm might requires a bit of adaptation before you can realize its full potential.
Yes. I have written data browsers, debuggers, profilers and all sort of non-trivial tools with the library. There's no reason you cannot, and in my experience the simplicity of the API is very empowering. However note that ImGui is programmer centric and the immediate-mode GUI paradigm might requires a bit of adaptation before you can realize its full potential.
<b>Can you reskin the look of ImGui?</b>
@ -52,7 +57,7 @@ Credits
Developed by [Omar Cornut](http://www.miracleworld.net). The library was developed with the support of [Media Molecule](http://www.mediamolecule.com) and first used internally on the game [Tearaway](http://tearaway.mediamolecule.com).
Embeds [proggy_clean](http://www.proggyfonts.net/) font by Tristan Grimmer (also MIT license).
Embeds [proggy_clean](http://upperbounds.net) font by Tristan Grimmer (also MIT license).
Inspiration, feedback, and testing: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Thanks!

View File

@ -20,7 +20,10 @@ struct CUSTOMVERTEX
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer)
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
// If text or lines are blurry when integrating ImGui in your engine:
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
// - try adjusting ImGui::GetIO().PixelCenterOffset to 0.5f or 0.375f
static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
{
size_t total_vtx_count = 0;
@ -79,7 +82,7 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
D3DXMatrixIdentity(&mat);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat);
D3DXMatrixOrthoOffCenterLH(&mat, 0.0f, ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y, 0.0f, -1.0f, +1.0f);
D3DXMatrixOrthoOffCenterLH(&mat, 0.5f, ImGui::GetIO().DisplaySize.x+0.5f, ImGui::GetIO().DisplaySize.y+0.5f, 0.5f, -1.0f, +1.0f);
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat);
// Render command lists

View File

@ -11,14 +11,17 @@
static GLFWwindow* window;
static GLuint fontTex;
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structuer)
// We are using the fixed pipeline.
// A faster way would be to collate all vertices from all cmd_lists into a single vertex buffer
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
// If text or lines are blurry when integrating ImGui in your engine:
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
// - try adjusting ImGui::GetIO().PixelCenterOffset to 0.5f or 0.375f
static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
{
if (cmd_lists_count == 0)
return;
// We are using the OpenGL fixed pipeline to make the example code simpler to read!
// A probable faster way to render would be to collate all vertices from all cmd_lists into a single vertex buffer.
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -146,10 +149,10 @@ void InitImGui()
glfwGetWindowSize(window, &w, &h);
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2((float)w, (float)h); // Display size, in pixels. For clamping windows positions.
io.DeltaTime = 1.0f/60.0f; // Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset = 0.5f; // Align OpenGL texels
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
io.DisplaySize = ImVec2((float)w, (float)h); // Display size, in pixels. For clamping windows positions.
io.DeltaTime = 1.0f/60.0f; // Time elapsed since last frame, in seconds (in this sample app we'll override this every frame because our timestep is variable)
io.PixelCenterOffset = 0.0f; // Align OpenGL texels
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;

View File

@ -15,10 +15,6 @@
//---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard(), etc.)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
//---- If you are loading a custom font, ImGui expect to find a pure white pixel at (0,0)
// Change it's UV coordinate here if you can't have a white pixel at (0,0)
//#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f/256.f,0.f/256.f)
//---- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
/*
#define IM_VEC2_CLASS_EXTRA \

130
imgui.cpp
View File

@ -53,7 +53,7 @@
- every frame:
1/ in your mainloop or right after you got your keyboard/mouse info, call ImGui::GetIO() and fill the 'Input' data, then call ImGui::NewFrame().
2/ use any ImGui function you want between NewFrame() and Render()
3/ ImGui::Render() to render all the accumulated command-lists. it will cack your RenderDrawListFn handler set in the IO structure.
3/ ImGui::Render() to render all the accumulated command-lists. it will call your RenderDrawListFn handler that you set in the IO structure.
- all rendering information are stored into command-lists until ImGui::Render() is called.
- effectively it means you can create widgets at any time in your code, regardless of "update" vs "render" considerations.
- a typical application skeleton may be:
@ -87,6 +87,10 @@
// swap video buffer, etc.
}
- if text or lines are blurry when integrating ImGui in your engine:
- in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
- try adjusting ImGui::GetIO().PixelCenterOffset to 0.5f or 0.375f
- some widgets carry state and requires an unique ID to do so.
- unique ID are typically derived from a string label, an indice or a pointer.
- use PushID/PopID to easily create scopes and avoid ID conflicts. A Window is also an implicit scope.
@ -101,7 +105,7 @@
- if you want to use a different font than the default
- create bitmap font data using BMFont. allocate ImGui::GetIO().Font and use ->LoadFromFile()/LoadFromMemory(), set ImGui::GetIO().FontHeight
- load your texture yourself. texture *MUST* have white pixel at UV coordinate 'IMGUI_FONT_TEX_UV_FOR_WHITE' (you can #define it in imconfig.h), this is used by solid objects.
- load your texture yourself. texture *MUST* have white pixel at UV coordinate Imgui::GetIO().FontTexUvForWhite. This is used to draw all solid shapes.
- tip: the construct 'if (IMGUI_ONCE_UPON_A_FRAME)' will evaluate to true only once a frame, you can use it to add custom UI in the middle of a deep nested inner loop in your code.
- tip: you can call Render() multiple times (e.g for VR renders), up to you to communicate the extra state to your RenderDrawListFn function.
@ -150,6 +154,7 @@
- input: support trackpad style scrolling & slider edit.
- misc: not thread-safe
- misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
- style editor: add a button to print C code.
- optimisation/render: use indexed rendering
- optimisation/render: move clip-rect to vertex data? would allow merging all commands
- optimisation/render: merge command-list of all windows into one command-list?
@ -178,10 +183,12 @@ namespace ImGui
{
static bool ButtonBehaviour(const ImGuiAabb& bb, const ImGuiID& id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, bool repeat = false);
static void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
static void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, const bool hide_text_after_hash = true);
static void LogText(const ImVec2& ref_pos, const char* text, const char* text_end = NULL);
static void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, const bool hide_text_after_hash = true);
static void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
static void RenderCollapseTriangle(ImVec2 p_min, bool open, float scale = 1.0f, bool shadow = false);
static void ItemSize(ImVec2 size, ImVec2* adjust_start_offset = NULL);
static void ItemSize(const ImGuiAabb& aabb, ImVec2* adjust_start_offset = NULL);
static void PushColumnClipRect(int column_index = -1);
@ -272,8 +279,9 @@ ImGuiIO::ImGuiIO()
IniFilename = "imgui.ini";
LogFilename = "imgui_log.txt";
Font = NULL;
FontTexUvForWhite = ImVec2(0.0f,0.0f);
FontAllowScaling = false;
PixelCenterOffset = 0.5f;
PixelCenterOffset = 0.0f;
MousePos = ImVec2(-1,-1);
MousePosPrev = ImVec2(-1,-1);
MouseDoubleClickTime = 0.30f;
@ -1553,12 +1561,14 @@ static void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border,
window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
if (border && (window->Flags & ImGuiWindowFlags_ShowBorders))
{
window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), window->Color(ImGuiCol_BorderShadow), rounding);
window->DrawList->AddRect(p_min, p_max, window->Color(ImGuiCol_Border), rounding);
// FIXME: I have no idea how this is working correctly but it is the best I've found that works on multiple rendering
const float offset = GImGui.IO.PixelCenterOffset;
window->DrawList->AddRect(p_min+ImVec2(1.5f-offset,1.5f-offset), p_max+ImVec2(1.0f-offset*2,1.0f-offset*2), window->Color(ImGuiCol_BorderShadow), rounding);
window->DrawList->AddRect(p_min+ImVec2(0.5f-offset,0.5f-offset), p_max+ImVec2(0.0f-offset*2,0.0f-offset*2), window->Color(ImGuiCol_Border), rounding);
}
}
static void RenderCollapseTriangle(ImVec2 p_min, bool open, float scale = 1.0f, bool shadow = false)
static void RenderCollapseTriangle(ImVec2 p_min, bool open, float scale, bool shadow)
{
ImGuiWindow* window = GetCurrentWindow();
@ -1581,7 +1591,7 @@ static void RenderCollapseTriangle(ImVec2 p_min, bool open, float scale = 1.0f,
c = center + ImVec2(-0.500f,-0.866f)*r;
}
if (shadow)
if (shadow && (window->Flags & ImGuiWindowFlags_ShowBorders) != 0)
window->DrawList->AddTriangleFilled(a+ImVec2(2,2), b+ImVec2(2,2), c+ImVec2(2,2), window->Color(ImGuiCol_BorderShadow));
window->DrawList->AddTriangleFilled(a, b, c, window->Color(ImGuiCol_Border));
}
@ -2066,8 +2076,7 @@ bool Begin(const char* name, bool* open, ImVec2 size, float fill_alpha, ImGuiWin
ImGuiAabb scrollbar_bb(window->Aabb().Max.x - style.ScrollBarWidth, title_bar_aabb.Max.y+1, window->Aabb().Max.x, window->Aabb().Max.y-1);
//window->DrawList->AddLine(scrollbar_bb.GetTL(), scrollbar_bb.GetBL(), g.Colors[ImGuiCol_Border]);
window->DrawList->AddRectFilled(scrollbar_bb.Min, scrollbar_bb.Max, window->Color(ImGuiCol_ScrollbarBg));
scrollbar_bb.Max.x -= 3;
scrollbar_bb.Expand(ImVec2(0,-3));
scrollbar_bb.Expand(ImVec2(-3,-3));
const float grab_size_y_norm = ImSaturate(window->Size.y / ImMax(window->SizeContentsFit.y, window->Size.y));
const float grab_size_y = scrollbar_bb.GetHeight() * grab_size_y_norm;
@ -2761,21 +2770,22 @@ static bool CloseWindowButton(bool* open)
ImGuiWindow* window = GetCurrentWindow();
const ImGuiID id = window->GetID("##CLOSE");
const float title_bar_height = window->TitleBarHeight();
const ImGuiAabb bb(window->Aabb().GetTR() + ImVec2(-title_bar_height+3.0f,2.0f), window->Aabb().GetTR() + ImVec2(-2.0f,+title_bar_height-2.0f));
const float size = window->TitleBarHeight() - 4.0f;
const ImGuiAabb bb(window->Aabb().GetTR() + ImVec2(-3.0f-size,2.0f), window->Aabb().GetTR() + ImVec2(-3.0f,2.0f+size));
bool hovered, held;
bool pressed = ButtonBehaviour(bb, id, &hovered, &held, true);
// Render
const ImU32 col = window->Color((held && hovered) ? ImGuiCol_CloseButtonActive : hovered ? ImGuiCol_CloseButtonHovered : ImGuiCol_CloseButton);
window->DrawList->AddCircleFilled(bb.GetCenter(), ImMax(2.0f,title_bar_height*0.5f-4), col, 16);
const ImVec2 center = bb.GetCenter();
window->DrawList->AddCircleFilled(center, ImMax(2.0f,size*0.5f), col, 16);
const float cross_padding = 4;
if (hovered && bb.GetWidth() >= (cross_padding+1)*2 && bb.GetHeight() >= (cross_padding+1)*2)
const float cross_extent = (size * 0.5f * 0.7071f) - 1.0f;
if (hovered)
{
window->DrawList->AddLine(bb.GetTL()+ImVec2(+cross_padding,+cross_padding), bb.GetBR()+ImVec2(-cross_padding,-cross_padding), window->Color(ImGuiCol_Text));
window->DrawList->AddLine(bb.GetBL()+ImVec2(+cross_padding,-cross_padding), bb.GetTR()+ImVec2(-cross_padding,+cross_padding), window->Color(ImGuiCol_Text));
window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), window->Color(ImGuiCol_Text));
window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), window->Color(ImGuiCol_Text));
}
if (open != NULL && pressed)
@ -2883,8 +2893,8 @@ bool CollapsingHeader(const char* label, const char* str_id, const bool display_
ImGuiAabb bb = ImGuiAabb(pos_min, ImVec2(pos_max.x, pos_min.y + text_size.y));
if (display_frame)
{
bb.Min.x -= window_padding.x*0.5f;
bb.Max.x += window_padding.x*0.5f;
bb.Min.x -= window_padding.x*0.5f - 1;
bb.Max.x += window_padding.x*0.5f - 1;
bb.Max.y += style.FramePadding.y * 2;
}
@ -2920,7 +2930,7 @@ bool CollapsingHeader(const char* label, const char* str_id, const bool display_
{
if ((held && hovered) || hovered)
RenderFrame(bb.Min, bb.Max, col, false);
RenderCollapseTriangle(bb.Min + ImVec2(style.FramePadding.x, window->FontSize()*0.15f), opened, 0.70f);
RenderCollapseTriangle(bb.Min + ImVec2(style.FramePadding.x, window->FontSize()*0.15f), opened, 0.70f, false);
RenderText(bb.Min + ImVec2(window->FontSize() + style.FramePadding.x*2,0), label);
}
@ -3284,7 +3294,7 @@ bool SliderFloat(const char* label, float* v, float v_min, float v_max, const ch
// Draw
const float grab_x = ImLerp(slider_effective_x1, slider_effective_x2, grab_t);
const ImGuiAabb grab_bb(ImVec2(grab_x-grab_size_in_pixels*0.5f,frame_bb.Min.y+2.0f), ImVec2(grab_x+grab_size_in_pixels*0.5f,frame_bb.Max.y-1.0f));
const ImGuiAabb grab_bb(ImVec2(grab_x-grab_size_in_pixels*0.5f,frame_bb.Min.y+2.0f), ImVec2(grab_x+grab_size_in_pixels*0.5f,frame_bb.Max.y-2.0f));
window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, window->Color(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab));
}
@ -3464,7 +3474,6 @@ static void Plot(ImGuiPlotType plot_type, const char* label, const float* values
else if (plot_type == ImGuiPlotType_Histogram)
window->DrawList->AddRectFilled(ImLerp(graph_bb.Min, graph_bb.Max, p0), ImLerp(graph_bb.Min, graph_bb.Max, ImVec2(p1.x, 1.0f))+ImVec2(-1,0), v_hovered == v_idx ? col_hovered : col_base);
v0 = v1;
t0 = t1;
p0 = p1;
}
@ -3522,7 +3531,7 @@ void Checkbox(const char* label, bool* v)
RenderFrame(check_bb.Min, check_bb.Max, window->Color(hovered ? ImGuiCol_CheckHovered : ImGuiCol_FrameBg));
if (*v)
{
window->DrawList->AddRectFilled(check_bb.Min+ImVec2(4,4), check_bb.Max-ImVec2(4,4), window->Color(ImGuiCol_CheckActive));
window->DrawList->AddRectFilled(check_bb.Min+ImVec2(3,3), check_bb.Max-ImVec2(3,3), window->Color(ImGuiCol_CheckActive));
}
if (g.LogEnabled)
@ -3575,7 +3584,7 @@ bool RadioButton(const char* label, bool active)
window->DrawList->AddCircleFilled(center, radius, window->Color(hovered ? ImGuiCol_CheckHovered : ImGuiCol_FrameBg), 16);
if (active)
window->DrawList->AddCircleFilled(center, radius-2, window->Color(ImGuiCol_CheckActive), 16);
window->DrawList->AddCircleFilled(center, radius-3.0f, window->Color(ImGuiCol_CheckActive), 16);
if (window->Flags & ImGuiWindowFlags_ShowBorders)
{
@ -4804,22 +4813,24 @@ void ImDrawList::AddVtx(const ImVec2& pos, ImU32 col)
{
vtx_write->pos = pos;
vtx_write->col = col;
vtx_write->uv = IMGUI_FONT_TEX_UV_FOR_WHITE;
vtx_write->uv = GImGui.IO.FontTexUvForWhite;
vtx_write++;
}
void ImDrawList::AddVtxLine(const ImVec2& a, const ImVec2& b, ImU32 col)
{
const ImVec2 n = (b - a) / ImLength(b - a);
const ImVec2 hn = ImVec2(n.y, -n.x) * 0.5f;
const float offset = GImGui.IO.PixelCenterOffset;
const ImVec2 hn = (b - a) * (0.50f / ImLength(b - a)); // half normal
const ImVec2 hp0 = ImVec2(offset - hn.y, offset + hn.x); // half perpendiculars + user offset
const ImVec2 hp1 = ImVec2(offset + hn.y, offset - hn.x);
AddVtx(a - hn, col);
AddVtx(b - hn, col);
AddVtx(a + hn, col);
AddVtx(b - hn, col);
AddVtx(b + hn, col);
AddVtx(a + hn, col);
// Two triangles makes up one line. Using triangles allows us to make draw calls.
AddVtx(a + hp0, col);
AddVtx(b + hp0, col);
AddVtx(a + hp1, col);
AddVtx(b + hp0, col);
AddVtx(b + hp1, col);
AddVtx(a + hp1, col);
}
void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col)
@ -4961,10 +4972,12 @@ void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec
if ((col >> 24) == 0)
return;
const ImVec2 offset(GImGui.IO.PixelCenterOffset,GImGui.IO.PixelCenterOffset);
ReserveVertices(3);
AddVtx(a, col);
AddVtx(b, col);
AddVtx(c, col);
AddVtx(a + offset, col);
AddVtx(b + offset, col);
AddVtx(c + offset, col);
}
void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments)
@ -4972,13 +4985,15 @@ void ImDrawList::AddCircle(const ImVec2& centre, float radius, ImU32 col, int nu
if ((col >> 24) == 0)
return;
const ImVec2 offset(GImGui.IO.PixelCenterOffset,GImGui.IO.PixelCenterOffset);
ReserveVertices((unsigned int)num_segments*6);
const float a_step = 2*PI/(float)num_segments;
float a0 = 0.0f;
for (int i = 0; i < num_segments; i++)
{
const float a1 = (i + 1) == num_segments ? 0.0f : a0 + a_step;
AddVtxLine(centre + ImVec2(cos(a0),sin(a0))*radius, centre + ImVec2(cos(a1),sin(a1))*radius, col);
AddVtxLine(centre + offset + ImVec2(cos(a0),sin(a0))*radius, centre + ImVec2(cos(a1),sin(a1))*radius, col);
a0 = a1;
}
}
@ -4988,15 +5003,17 @@ void ImDrawList::AddCircleFilled(const ImVec2& centre, float radius, ImU32 col,
if ((col >> 24) == 0)
return;
const ImVec2 offset(GImGui.IO.PixelCenterOffset,GImGui.IO.PixelCenterOffset);
ReserveVertices((unsigned int)num_segments*3);
const float a_step = 2*PI/(float)num_segments;
float a0 = 0.0f;
for (int i = 0; i < num_segments; i++)
{
const float a1 = (i + 1) == num_segments ? 0.0f : a0 + a_step;
AddVtx(centre + ImVec2(cos(a0),sin(a0))*radius, col);
AddVtx(centre + ImVec2(cos(a1),sin(a1))*radius, col);
AddVtx(centre, col);
AddVtx(centre + offset + ImVec2(cos(a0),sin(a0))*radius, col);
AddVtx(centre + offset + ImVec2(cos(a1),sin(a1))*radius, col);
AddVtx(centre + offset, col);
a0 = a1;
}
}
@ -5031,11 +5048,14 @@ void ImDrawList::AddText(ImFont font, float font_size, const ImVec2& pos, ImU32
ImBitmapFont::ImBitmapFont()
{
Data = NULL;
DataSize = 0;
DataOwned = false;
Info = NULL;
Common = NULL;
Glyphs = NULL;
GlyphsCount = 0;
Kerning = NULL;
KerningCount = 0;
TabCount = 4;
}
@ -5223,13 +5243,11 @@ void ImBitmapFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& c
const float outline = (float)Info->Outline;
// Align to be pixel perfect
pos.x = (float)(int)pos.x + 0.5f;
pos.y = (float)(int)pos.y + 0.5f;
pos.x = (float)(int)pos.x;
pos.y = (float)(int)pos.y;
const ImVec4 clip_rect = clip_rect_ref;
const float uv_offset = GImGui.IO.PixelCenterOffset;
float x = pos.x;
float y = pos.y;
for (const char* s = text_begin; s < text_end; s++)
@ -5266,10 +5284,10 @@ void ImBitmapFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& c
continue;
}
const float s1 = (uv_offset + glyph->X) * tex_scale_x;
const float t1 = (uv_offset + glyph->Y) * tex_scale_y;
const float s2 = (uv_offset + glyph->X + glyph->Width) * tex_scale_x;
const float t2 = (uv_offset + glyph->Y + glyph->Height) * tex_scale_y;
const float s1 = (glyph->X) * tex_scale_x;
const float t1 = (glyph->Y) * tex_scale_y;
const float s2 = (glyph->X + glyph->Width) * tex_scale_x;
const float t2 = (glyph->Y + glyph->Height) * tex_scale_y;
out_vertices[0].pos = ImVec2(x1, y1);
out_vertices[0].uv = ImVec2(s1, t1);
@ -5504,10 +5522,10 @@ void ShowTestWindow(bool* open)
if (ImGui::CollapsingHeader("Window options"))
{
ImGui::Checkbox("no titlebar", &no_titlebar); ImGui::SameLine(200);
ImGui::Checkbox("no border", &no_border); ImGui::SameLine(400);
ImGui::Checkbox("no titlebar", &no_titlebar); ImGui::SameLine(150);
ImGui::Checkbox("no border", &no_border); ImGui::SameLine(300);
ImGui::Checkbox("no resize", &no_resize);
ImGui::Checkbox("no move", &no_move); ImGui::SameLine(200);
ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150);
ImGui::Checkbox("no scrollbar", &no_scrollbar);
ImGui::SliderFloat("fill alpha", &fill_alpha, 0.0f, 1.0f);
if (ImGui::TreeNode("Style Editor"))
@ -5590,6 +5608,9 @@ void ShowTestWindow(bool* open)
ImGui::EndTooltip();
}
ImGui::Separator();
ImGui::Text("^ Horizontal separator");
static int item = 1;
ImGui::Combo("combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0");
@ -5896,7 +5917,8 @@ void ShowTestWindow(bool* open)
//-----------------------------------------------------------------------------
// Font data
// Bitmap exported from proggy_clean.fon (c) by Tristan Grimmer http://www.proggyfonts.net
// Bitmap exported from proggy_clean.fon (c) by Tristan Grimmer http://upperbounds.net/
// Also available on unofficial ProggyFonts mirror http://www.proggyfonts.net
//-----------------------------------------------------------------------------
/*
// Copyright (c) 2004, 2005 Tristan Grimmer

View File

@ -390,8 +390,9 @@ struct ImGuiIO
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
float FontHeight; // <auto> // Default font height, must be the vertical distance between two lines of text, aka == CalcTextSize(" ").y
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
float PixelCenterOffset; // = 0.5f // Set to 0.0f for DirectX <= 9, 0.5f for Direct3D >= 10 and OpenGL.
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
// Settings - Rendering function (REQUIRED)
// See example code if you are unsure of how to implement this.
@ -524,10 +525,6 @@ struct ImDrawCmd
ImVec4 clip_rect;
};
#ifndef IMGUI_FONT_TEX_UV_FOR_WHITE
#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f,0.f)
#endif
// sizeof() == 20
struct ImDrawVert
{