Compare commits

..

32 Commits
v1.09 ... v1.11

Author SHA1 Message Date
24028911e3 Added version number in sources 2014-09-10 12:26:12 +01:00
3fd68c3a31 Fixed file-descriptor leak if ImBitmapFont::LoadFromFile() calls to seek/tell fails. 2014-09-10 12:21:38 +01:00
1cf4b313e2 Update README.md 2014-09-10 11:35:34 +01:00
2e85dce1ee Added #define IMGUI_INCLUDE_IMGUI_USER_CPP to optionally include imgui_user.cpp 2014-09-10 11:22:01 +01:00
62d233aaab Added extra_flags parameters to InputInt(), InputFloat(). Used in example code. Commented out broken ImGuiInputTextFlags_AlignCenter. 2014-09-08 16:50:09 +01:00
3cdb4fa456 Merge pull request #44 from xythobuz/master
Added ImGuiInputTextFlags_EnterReturnsTrue
2014-09-08 16:37:16 +01:00
7439df0ba1 Added ImGuiInputTextFlags_EnterReturnsTrue 2014-09-08 15:48:39 +02:00
ad42787543 Made radio button render ascii when logged into tty/file/clipboard 2014-09-02 14:36:03 +01:00
91059da1a5 Added more comments in the code. 2014-09-02 14:35:06 +01:00
b420a51541 Update README.md
Fixed typos, reworded sentence.
2014-09-02 10:59:14 +01:00
c07ab1b56a Minor tweaks to "Memory override" pull request 2014-08-31 12:02:22 +01:00
22a9555a99 Merge branch 'pr/40' 2014-08-31 11:54:45 +01:00
25080d53e5 Memory override #3 2014-08-31 14:58:21 +04:30
43448d9c89 Added FAQ/comments 2014-08-31 08:23:55 +01:00
e20077fbd0 Using spaces instead of tab for web readability 2014-08-30 20:06:53 +01:00
2c677c45c7 Added sample fonts data 2014-08-30 20:02:55 +01:00
3b339efeb2 Added IO.FontYOffset. Added asserts. 2014-08-30 20:02:10 +01:00
8fc50f5ed3 Remove IO.FontHeight, cached automatically. Added assertions. 2014-08-30 18:43:26 +01:00
dd5d251273 Added SetCursorPosX, SetCursorPosY shortcuts 2014-08-29 13:36:31 +01:00
2fb63b6068 Checkbox() return true when pressed 2014-08-28 17:32:03 +01:00
aa7fc37b37 removed malloc/free proxy fwd declares 2014-08-18 16:19:11 +04:30
c13c2449bb removed libimgui.pro 2014-08-18 16:09:47 +04:30
c2cb727ac9 memory override attempt #2 2014-08-18 16:08:03 +04:30
47fd8431c1 minor fixes 2014-08-18 13:19:35 +04:30
ef628a0a9d argh, removed redundent defines 2014-08-16 13:35:44 +04:30
df5a06f119 removed memory pools, they dont apply well 2014-08-16 13:34:45 +04:30
e9b697698a fixed a typo 2014-08-16 13:12:24 +04:30
5240013c90 merge with upstream 2014-08-16 13:00:39 +04:30
1956703c42 First attempt at memory management 2014-08-16 12:58:29 +04:30
6d6ee4e1f1 revert back to original 2014-08-14 19:21:01 +04:30
e9b0a61f48 :w
a
A
A
A
A
A
A
B
B
B
B
B
B
B
B
B
B
D
D
merged with upste
Merge remote-tracking branch 'upstream/master'
2014-08-14 18:59:08 +04:30
e3001fb986 project update 2014-08-11 20:43:24 +04:30
17 changed files with 369 additions and 140 deletions

View File

@ -34,7 +34,7 @@ Frequently Asked Question
-------------------------
<b>How do you use ImGui on a platform that may not have a mouse and keyboard?</b>
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.
I recommend using [Synergy](http://synergy-project.org). With the uSynergy.c micro client running you can seamlessly use your PC input devices from 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>
@ -51,6 +51,10 @@ Yes, you can alter the look of the interface to some degree: changing colors, si
![skinning screenshot 1](/web/skinning_sample_01.png?raw=true)
<b>Can you develop features xxxx for ImGui?</b>
Please use GitHub 'Issues' facilities to suggest and discuss improvements. If you are company and would like specific non-trivial features to be implemented, I am available for hire to work on or with ImGui. Donations are also welcome to support further work on the library.
Credits
-------

BIN
extra_fonts/ProggyClean.zip Normal file

Binary file not shown.

BIN
extra_fonts/ProggySmall.zip Normal file

Binary file not shown.

71
extra_fonts/README.txt Normal file
View File

@ -0,0 +1,71 @@
Extra fonts for ImGui.
THOSE FONTS ARE OPTIONAL.
ImGui embeds a copy of 'proggy_clean' that you can use without any external files.
Export your own font with bmfont (www.angelcode.com/products/bmfont).
bmfont reads fonts (.ttf, .fon, etc.) and output a .fnt file and a texture file, e.g:
proggy_clean.fon --> [bmfont] ---> proggy_clean_13.fnt
proggy_clean_13.png
Configure bmfont:
- Export .fnt as Binary
- Tip: uncheck "Render from TrueType outline" and "Font Smoothing" for best result with non-anti-aliased type fonts.
But you can experiment with other settings if you want anti-aliased fonts.
(A) Use font data embedded in ImGui
// Access embedded font data
const void* fnt_data; // pointer to FNT data
unsigned fnt_size; // size of FNT data
const void* png_data; // pointer to PNG data
unsigned int png_size; // size of PNG data
ImGui::GetDefaultFontData(&fnt_data, &fnt_size, &png_data, &png_size);
1. Load the .FNT data from 'fnt_data' (NB: this is done for you by default if you don't do anything)
ImGuiIO& io = ImGui::GetIO();
io.Font = new ImBitmapFont();
io.Font->LoadFromMemory(fnt_data, fnt_size);
2. Load the .PNG data from 'png_data' into a texture
(B) Use fonts from external files
ImGuiIO& io = ImGui::GetIO();
1. Load the .FNT data, e.g.
// proggy_clean_13 [default]
io.Font->LoadFromFile("proggy_clean_13.fnt");
io.FontTexUvForWhite = ImVec2(0.0f/256.0f,0.0f/128);
io.FontYOffset = +1;
// proggy_small_12
io.Font = new ImBitmapFont();
io.Font->LoadFromFile("proggy_small_12.fnt");
io.FontTexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64);
io.FontYOffset = +2;
// proggy_small_14
io.Font = new ImBitmapFont();
io.Font->LoadFromFile("proggy_small_14.fnt");
io.FontTexUvForWhite = ImVec2(84.0f/256.0f,20.0f/64);
io.FontYOffset = +3;
// courier_new_16
io.Font->LoadFromFile("courier_new_16.fnt");
io.FontTexUvForWhite = ImVec2(1.0f/256.0f,4.0f/128);
// courier_new_18
io.Font->LoadFromFile("courier_new_18.fnt");
io.FontTexUvForWhite = ImVec2(4.0f/256.0f,5.0f/256);
2. Load the matching .PNG data into a texture

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

View File

@ -4,6 +4,11 @@
#pragma once
//---- Define your own malloc/free/realloc functions if you want to override internal memory allocations for ImGui
//#define IM_MALLOC(_SIZE) MyMalloc(_SIZE) // void* MyMalloc(size_t size);
//#define IM_FREE(_PTR) MyFree(_PTR) // void MyFree(void *ptr);
//#define IM_REALLOC(_PTR, _SIZE) MyRealloc(_PTR, _SIZE) // void* MyRealloc(void *ptr, size_t size);
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
//#include <vector>
//#define ImVector std::vector
@ -15,6 +20,9 @@
//---- Don't implement default clipboard handlers for Windows (so as not to link with OpenClipboard(), etc.)
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
//---- Include imgui_user.cpp at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
//#define IMGUI_INCLUDE_IMGUI_USER_CPP
//---- Define implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
/*
#define IM_VEC2_CLASS_EXTRA \
@ -35,3 +43,4 @@ namespace ImGui
void Value(const char* prefix, const MyVec4& v, const char* float_format = NULL);
};
*/

355
imgui.cpp

File diff suppressed because it is too large Load Diff

68
imgui.h
View File

@ -1,4 +1,4 @@
// ImGui library
// ImGui library v1.11
// See .cpp file for commentary.
// See ImGui::ShowTestWindow() for sample code.
// Read 'Programmer guide' in .cpp for notes on how to setup ImGui in your codebase.
@ -17,7 +17,19 @@ struct ImGuiWindow;
#include "imconfig.h"
#include <float.h> // FLT_MAX
#include <stdarg.h> // va_list
#include <stdlib.h> // NULL
#include <stdlib.h> // NULL, malloc
#ifndef IM_MALLOC
#define IM_MALLOC(_SIZE) malloc((_SIZE))
#endif
#ifndef IM_FREE
#define IM_FREE(_PTR) free((_PTR))
#endif
#ifndef IM_REALLOC
#define IM_REALLOC(_PTR, _SIZE) realloc((_PTR), (_SIZE))
#endif
#ifndef IM_ASSERT
#include <assert.h>
@ -72,7 +84,7 @@ public:
typedef const value_type* const_iterator;
ImVector() { Size = Capacity = 0; Data = NULL; }
~ImVector() { if (Data) free(Data); }
~ImVector() { if (Data) IM_FREE(Data); }
inline bool empty() const { return Size == 0; }
inline size_t size() const { return Size; }
@ -83,7 +95,7 @@ public:
inline value_type& operator[](size_t i) { IM_ASSERT(i < Size); return Data[i]; }
inline const value_type& operator[](size_t i) const { IM_ASSERT(i < Size); return Data[i]; }
inline void clear() { if (Data) { Size = Capacity = 0; free(Data); Data = NULL; } }
inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } }
inline iterator begin() { return Data; }
inline const_iterator begin() const { return Data; }
inline iterator end() { return Data + Size; }
@ -94,7 +106,7 @@ public:
inline const value_type& back() const { IM_ASSERT(Size > 0); return at(Size-1); }
inline void swap(ImVector<T>& rhs) { const size_t rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; const size_t rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; value_type* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; }
inline void reserve(size_t new_capacity) { Data = (value_type*)realloc(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
inline void reserve(size_t new_capacity) { Data = (value_type*)IM_REALLOC(Data, new_capacity * sizeof(value_type)); Capacity = new_capacity; }
inline void resize(size_t new_size) { if (new_size > Capacity) reserve(new_size); Size = new_size; }
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(Capacity ? Capacity * 2 : 4); Data[Size++] = v; }
@ -133,16 +145,16 @@ namespace ImGui
void BeginChild(const char* str_id, ImVec2 size = ImVec2(0,0), bool border = false, ImGuiWindowFlags extra_flags = 0);
void EndChild();
bool GetWindowIsFocused();
float GetWindowWidth();
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
void SetWindowPos(const ImVec2& pos); // set current window pos
ImVec2 GetWindowSize();
float GetWindowWidth();
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing.
void SetWindowPos(const ImVec2& pos); // set current window pos.
ImVec2 GetWindowContentRegionMin();
ImVec2 GetWindowContentRegionMax();
ImDrawList* GetWindowDrawList();
ImDrawList* GetWindowDrawList(); // get rendering command-list if you want to append your own draw primitives.
void SetFontScale(float scale);
void SetScrollPosHere();
void SetTreeStateStorage(ImGuiStorage* tree);
void SetScrollPosHere(); // adjust scrolling position to center into the current cursor position.
void SetTreeStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it).
ImGuiStorage* GetTreeStateStorage();
void PushItemWidth(float item_width);
void PopItemWidth();
@ -154,7 +166,7 @@ namespace ImGui
// Tooltip
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
void EndTooltip();
// Layout
@ -168,8 +180,10 @@ namespace ImGui
float GetColumnWidth(int column_index = -1);
ImVec2 GetCursorPos(); // cursor position relative to window position
void SetCursorPos(const ImVec2& pos); // "
void SetCursorPosX(float x); // "
void SetCursorPosY(float y); // "
ImVec2 GetCursorScreenPos(); // cursor position in screen space
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match subsequent (bigger) widgets.
float GetTextLineSpacing();
float GetTextLineHeight();
@ -189,7 +203,7 @@ namespace ImGui
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
bool SmallButton(const char* label);
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.
bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
bool SliderFloat4(const char* label, float v[3], float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f);
@ -197,16 +211,16 @@ namespace ImGui
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
void Checkbox(const char* label, bool* v);
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
bool Checkbox(const char* label, bool* v);
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
bool RadioButton(const char* label, bool active);
bool RadioButton(const char* label, int* v, int v_button);
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1, ImGuiInputTextFlags extra_flags = 0);
bool InputFloat2(const char* label, float v[2], int decimal_precision = -1);
bool InputFloat3(const char* label, float v[3], int decimal_precision = -1);
bool InputFloat4(const char* label, float v[4], int decimal_precision = -1);
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100);
bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0);
bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags extra_flags = 0);
bool Combo(const char* label, int* current_item, const char** items, int items_count, int popup_height_items = 7);
bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_height_items = 7); // Separate items with \0, end item-list with \0\0
bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_height_items = 7);
@ -214,10 +228,10 @@ namespace ImGui
bool ColorEdit3(const char* label, float col[3]);
bool ColorEdit4(const char* label, float col[4], bool show_alpha = true);
void ColorEditMode(ImGuiColorEditMode mode);
bool TreeNode(const char* str_label_id); // if returning 'true' the user is responsible for calling TreePop
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
bool TreeNode(const char* str_id, const char* fmt, ...); // "
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layout purpose
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
void TreePush(const void* ptr_id = NULL); // "
void TreePop();
void OpenNextNode(bool open); // force open/close the next TreeNode or CollapsingHeader
@ -276,10 +290,11 @@ enum ImGuiWindowFlags_
enum ImGuiInputTextFlags_
{
// Default: 0
ImGuiInputTextFlags_CharsDecimal = 1 << 0,
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1,
ImGuiInputTextFlags_AutoSelectAll = 1 << 2,
ImGuiInputTextFlags_AlignCenter = 1 << 3,
ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
ImGuiInputTextFlags_AutoSelectAll = 1 << 2, // Select entire text when first taking focus
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 3, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
//ImGuiInputTextFlags_AlignCenter = 1 << 3,
};
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
@ -389,7 +404,7 @@ struct ImGuiIO
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
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
float FontYOffset; // = 0.0f // Offset font rendering by xx pixels in Y axis.
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.0f // Try to set to 0.5f or 0.375f if rendering is blurry
@ -640,6 +655,7 @@ struct ImBitmapFont
void BuildLookupTable();
const FntGlyph * FindGlyph(unsigned short c) const;
float GetFontSize() const { return (float)Info->FontSize; }
bool IsLoaded() const { return Info != NULL && Common != NULL && Glyphs != NULL; }
ImVec2 CalcTextSize(float size, float max_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const;
void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawVert*& out_vertices) const;