1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-24 07:40:22 +01:00
This commit is contained in:
gzito 2015-10-14 23:01:52 +02:00
commit 79ca203850
23 changed files with 283 additions and 201 deletions

View File

@ -1,4 +1,7 @@
// ImGui Allegro 5 bindings
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
// by @birthggd

View File

@ -1,4 +1,7 @@
// ImGui Allegro 5 bindings
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
// by @birthggd

View File

@ -1,4 +1,7 @@
// ImGui Win32 + DirectX11 binding
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
#include <imgui.h>
@ -328,7 +331,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
// Create the input layout
D3D11_INPUT_ELEMENT_DESC localLayout[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (size_t)(&((ImDrawVert*)0)->uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (size_t)(&((ImDrawVert*)0)->col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

View File

@ -1,4 +1,7 @@
// ImGui Win32 + DirectX11 binding
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
struct ID3D11Device;

View File

@ -1,4 +1,7 @@
// ImGui Win32 + DirectX9 binding
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
#include <imgui.h>

View File

@ -1,4 +1,7 @@
// ImGui Win32 + DirectX9 binding
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
struct IDirect3DDevice9;

View File

@ -1,14 +1,14 @@
# iOS example
----
## Introduction
This example is the default XCode "OpenGL" example code, modified to support ImGui and [Synergy](http://synergy-project.org/).
It is a rather complex example because of all of the faff required to get an XCode/iOS application running. Refer to the regular OpenGL examples if you want to learn about integrating ImGui.
Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImGui without it. Synergy includes a "uSynergy" library that allows embedding a synergy client, this is what is used here. ImGui supports "TouchPadding", and this is enabled when Synergy is not active.
## How to Use
----
0. In Synergy, go to Preferences, and uncheck "Use SSL encryption"
0. Run the example app.
@ -16,7 +16,6 @@ Synergy (remote keyboard/mouse) is not required, but it's pretty hard to use ImG
0. Enter the name or the IP of your synergy host
0. If you had previously connected to a server, you may need to kill and re-start the app.
----
## Notes and TODOs
Things that would be nice but I didn't get around to doing:
@ -26,7 +25,6 @@ Things that would be nice but I didn't get around to doing:
* Graceful disconnect/reconnect from uSynergy.
* Copy/Paste not well-supported
----
## C++ on iOS
ImGui is a c++ library. If you want to include it directly, rename your Obj-C file to have the ".mm" extension.

View File

@ -20,6 +20,8 @@
MemSize=6000000
MemSizeDebug=6000000
DispFixRot=FixedLandscape
# emulate iphone 5 resolution, change these settings to emulate other display resolution
WinWidth=1136
WinHeight=640

View File

@ -17,14 +17,17 @@ static double g_Time = 0.0f;
static bool g_MousePressed[3] = { false, false, false };
static float g_MouseWheel = 0.0f;
static CIwTexture* g_FontTexture = 0;
static int g_KeyboardGetCharAvailable = 0 ;
static char* g_ClipboardText = 0 ;
static bool g_osdKeyboardEnabled = false ;
// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor
static ImVec2 g_scale = ImVec2(1.0f,1.0f) ;
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
{
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
ImGuiIO& io = ImGui::GetIO();
float fb_height = io.DisplaySize.y * io.DisplayFramebufferScale.y;
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
// Render command lists
@ -39,8 +42,9 @@ void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
CIwColour* pColStream = IW_GX_ALLOC(CIwColour,nVert) ;
for( int i=0; i < nVert; i++ ) {
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x ;
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y ;
// todo - optimize multiplication on gpu using vertex shader
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_scale.x ;
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_scale.y ;
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x ;
pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y ;
pColStream[i] = cmd_list->VtxBuffer[i].col ;
@ -83,15 +87,20 @@ void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
static const char* ImGui_Marmalade_GetClipboardText()
{
static char clipBuf[512] ;
if(s3eClipboardAvailable()) {
s3eClipboardGetText( clipBuf, 512 );
int size = s3eClipboardGetText( NULL, 0 );
if( size > 0 ) {
if(g_ClipboardText) {
delete[] g_ClipboardText ;
g_ClipboardText = 0 ;
}
g_ClipboardText = new char[size] ;
g_ClipboardText[0] = '\0' ;
s3eClipboardGetText(g_ClipboardText,size) ;
}
else {
clipBuf[0] = '\0' ;
}
return clipBuf ;
return g_ClipboardText ;
}
static void ImGui_Marmalade_SetClipboardText(const char* text)
@ -129,7 +138,7 @@ int32 ImGui_Marmalade_PointerButtonEventCallback(void* SystemData,void* pUserDat
return 0;
}
//void ImGui_Marmalade_ScrollCallback(GLFWwindow*,double /*xoffset*/,double yoffset)
//void ImGui_Marmalade_ScrollCallback(double /*xoffset*/,double yoffset)
//{
// g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
//}
@ -157,7 +166,7 @@ int32 ImGui_Marmalade_CharCallback(void* SystemData,void* userData)
ImGuiIO& io = ImGui::GetIO();
s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)SystemData ;
if( (e->m_Char > 0 && e->m_Char < 0x10000) && io.WantTextInput ) {
if( (e->m_Char > 0 && e->m_Char < 0x10000) ) {
io.AddInputCharacter((unsigned short)e->m_Char);
}
@ -177,7 +186,7 @@ bool ImGui_Marmalade_CreateDeviceObjects()
g_FontTexture = new CIwTexture() ;
g_FontTexture->SetModifiable(true) ;
CIwImage& image = g_FontTexture->GetImage() ;
image.SetFormat(CIwImage::Format::ARGB_8888) ;
image.SetFormat(CIwImage::ARGB_8888) ;
image.SetWidth(width) ;
image.SetHeight(height) ;
image.SetBuffers(); // allocates and own buffers
@ -198,6 +207,11 @@ bool ImGui_Marmalade_CreateDeviceObjects()
void ImGui_Marmalade_InvalidateDeviceObjects()
{
if(g_ClipboardText) {
delete[] g_ClipboardText ;
g_ClipboardText = 0 ;
}
if (g_FontTexture)
{
delete g_FontTexture ;
@ -239,14 +253,8 @@ bool ImGui_Marmalade_Init( bool install_callbacks)
{
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT,ImGui_Marmalade_PointerButtonEventCallback,0) ;
s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT,ImGui_Marmalade_KeyCallback,0) ;
// enable KEYBOARD_GET_CHAR
s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,1) ;
g_KeyboardGetCharAvailable = s3eKeyboardGetInt(S3E_KEYBOARD_GET_CHAR) ;
if( g_KeyboardGetCharAvailable ) {
s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT,ImGui_Marmalade_CharCallback,0) ;
}
}
return true;
}
@ -260,8 +268,9 @@ void ImGui_Marmalade_Shutdown()
void ImGui_Marmalade_NewFrame()
{
if (!g_FontTexture)
if (!g_FontTexture) {
ImGui_Marmalade_CreateDeviceObjects();
}
ImGuiIO& io = ImGui::GetIO();
@ -269,29 +278,19 @@ void ImGui_Marmalade_NewFrame()
int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight() ;
io.DisplaySize = ImVec2((float)w, (float)h);
// For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui.
io.DisplayFramebufferScale = ImVec2((float)1.0f, (float)1.0f);
io.DisplayFramebufferScale = g_scale;
// Setup time step
double current_time = s3eTimerGetUST() / 1000.0f ;
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
g_Time = current_time;
// Setup inputs
// (we already got mouse wheel, keyboard keys & characters from glfw callbacks polled in glfwPollEvents())
//if ( gui_has_focus() )
//{
double mouse_x, mouse_y;
mouse_x = s3ePointerGetX();
mouse_y = s3ePointerGetY();
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
//}
//else
//{
// io.MousePos = ImVec2(-1,-1);
//}
io.MousePos = ImVec2((float)mouse_x/g_scale.x, (float)mouse_y/g_scale.y); // Mouse position in screen coordinates (set to -1,-1 if no mouse / on another screen, etc.)
for (int i = 0; i < 3; i++)
{
for (int i = 0; i < 3; i++) {
io.MouseDown[i] = g_MousePressed[i] || s3ePointerGetState((s3ePointerButton)i) != S3E_POINTER_STATE_UP; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
g_MousePressed[i] = false;
}
@ -304,4 +303,18 @@ void ImGui_Marmalade_NewFrame()
// Start the frame
ImGui::NewFrame();
// show/hide OSD keyboard
if( io.WantTextInput ) { // some text input widget is active?
if( !g_osdKeyboardEnabled ) {
g_osdKeyboardEnabled = true ;
s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,1) ; // show OSD keyboard
}
}
else { // no text input widget is active
if(g_osdKeyboardEnabled) {
g_osdKeyboardEnabled = false ;
s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR,0) ; // hide OSD keyboard
}
}
}

View File

@ -8,10 +8,12 @@
define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS
define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS
define _snprintf=snprintf
options
{
optimise-speed=1
cxx11
}
includepaths

View File

@ -1,4 +1,7 @@
// ImGui GLFW binding with OpenGL3 + shaders
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
#include <imgui.h>

View File

@ -1,4 +1,7 @@
// ImGui GLFW binding with OpenGL3 + shaders
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
struct GLFWwindow;

View File

@ -1,4 +1,7 @@
// ImGui GLFW binding with OpenGL
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
#include <imgui.h>

View File

@ -1,4 +1,7 @@
// ImGui GLFW binding with OpenGL
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
struct GLFWwindow;

View File

@ -1,4 +1,7 @@
// ImGui SDL2 binding with OpenGL
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
#include <SDL.h>

View File

@ -1,4 +1,7 @@
// ImGui SDL2 binding with OpenGL
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui
struct SDL_Window;

View File

@ -18,21 +18,23 @@ typedef unsigned int stb_uint;
typedef unsigned char stb_uchar;
stb_uint stb_compress(stb_uchar *out,stb_uchar *in,stb_uint len);
static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding);
static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression);
int main(int argc, char** argv)
{
if (argc < 3)
{
printf("Syntax: %s [-base85] <inputfile> <symbolname>\n", argv[0]);
printf("Syntax: %s [-base85] [-nocompress] <inputfile> <symbolname>\n", argv[0]);
return 0;
}
int argn = 1;
bool use_base85_encoding = false;
bool use_compression = true;
if (argv[argn][0] == '-')
{
if (strcmp(argv[argn], "-base85") == 0) { use_base85_encoding = true; argn++; }
else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; }
else
{
printf("Unknown argument: '%s'\n", argv[argn]);
@ -40,7 +42,7 @@ int main(int argc, char** argv)
}
}
binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding);
binary_to_compressed_c(argv[argn], argv[argn+1], use_base85_encoding, use_compression);
return 1;
}
@ -50,7 +52,7 @@ char Encode85Byte(unsigned int x)
return (x>='\\') ? x+1 : x;
}
bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding)
bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression)
{
// Read file
FILE* f = fopen(filename, "rb");
@ -64,17 +66,19 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
// Compress
int maxlen = data_sz + 512 + (data_sz >> 2) + sizeof(int); // total guess
char* compressed = new char[maxlen];
int compressed_sz = stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz);
char* compressed = use_compression ? new char[maxlen] : data;
int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz;
if (use_compression)
memset(compressed + compressed_sz, 0, maxlen - compressed_sz);
// Output as Base85 encoded
FILE* out = stdout;
fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz);
fprintf(out, "// Exported using binary_to_compressed_c.cpp\n");
const char* compressed_str = use_compression ? "compressed_" : "";
if (use_base85_encoding)
{
fprintf(out, "static const char %s_compressed_data_base85[%d+1] =\n \"", symbol, (int)((compressed_sz+3)/4)*5);
fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5);
int column = 0;
for (int i = 0; i < compressed_sz; i += 4)
{
@ -87,8 +91,8 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
}
else
{
fprintf(out, "static const unsigned int %s_compressed_size = %d;\n", symbol, (int)compressed_sz);
fprintf(out, "static const unsigned int %s_compressed_data[%d/4] =\n{", symbol, (int)((compressed_sz+3)/4)*4);
fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz);
fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz+3)/4)*4);
int column = 0;
for (int i = 0; i < compressed_sz; i += 4)
{
@ -103,6 +107,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
// Cleanup
delete[] data;
if (use_compression)
delete[] compressed;
return true;
}

View File

@ -399,14 +399,19 @@
Issue numbers (#) refer to github issues.
The list below consist mostly of notes of things to do before they are requested/discussed by users (at that point it usually happens on the github)
- window: autofit feedback loop when user relies on any dynamic layout (window width multiplier, column). maybe just clearly drop manual autofit?
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list.
- window: maximum window size settings (per-axis). for large popups in particular user may not want the popup to fill all space.
- window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass.
- window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column). clarify.
- window: allow resizing of child windows (possibly given min/max for each axis?)
- window: background options for child windows, border option (disable rounding)
- window: add a way to clear an existing window instead of appending (e.g. for tooltip override using a consistent api rather than the deferred tooltip)
- window: resizing from any sides? + mouse cursor directives for app.
!- window: begin with *p_opened == false should return false.
- window: get size/pos helpers given names (see discussion in #249)
- window: a collapsed window can be stuck behind the main menu bar?
- window: detect extra End() call that pop the "Debug" window out and assert at call site instead of later.
!- scrolling: allow immediately effective change of scroll if we haven't appended items yet
- splitter: formalize the splitter idiom into an official api (we want to handle n-way split)
- widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc.
- widgets: clean up widgets internal toward exposing everything.
- widgets: add disabled and read-only modes (#211)
@ -421,6 +426,8 @@
- input number: use mouse wheel to step up/down
- input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack.
- text: proper alignment options
- image/image button: misalignment on padded/bordered button?
- image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that?
- layout: horizontal layout helper (#97)
- layout: more generic alignment state (left/right/centered) for single items?
- layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding.
@ -436,19 +443,20 @@
- listbox: user may want to initial scroll to focus on the one selected value?
- listbox: keyboard navigation.
- listbox: scrolling should track modified selection.
! menus/popups: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331)
-! menus/popups: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331)
- menus: local shortcuts, global shortcuts (#126)
- menus: icons
- menus: menubars: some sort of priority / effect of main menu-bar on desktop size?
- statusbar: add a per-window status bar helper similar to what menubar does.
- tabs
- separator: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y)
- gauge: various forms of gauge/loading bars widgets
- color: add a better color picker (perhaps a popup).
- plot: plotlines should use the polygon-stroke facilities (currently issues with averaging normals)
- color: add a better color picker
- plot: PlotLines() should use the polygon-stroke facilities (currently issues with averaging normals)
- plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots)
- plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value)
- plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID)
- file selection widget -> build the tool in our codebase to improve model-dialog idioms
- applet: file selection widget (as an example)
- slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt()
- slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar).
- slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate.
@ -459,13 +467,15 @@
- text edit: centered text for slider as input text so it matches typical positioning.
- text edit: flag to disable live update of the user buffer.
- text edit: field resize behavior - field could stretch when being edited? hover tooltip shows more text?
- tree: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
- tree node / optimization: avoid formatting when clipped.
- tree node: tree-node/header right-most side doesn't take account of horizontal scrolling.
- tree node: add treenode/treepush int variants? because (void*) cast from int warns on some platforms/settings
- textwrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (git issue #249)
- settings: write more decent code to allow saving/loading new fields
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file
- style: store rounded corners in texture to use 1 quad per corner (filled and wireframe). so rounding have minor cost.
- style: color-box not always square?
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps that other settings?
- style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc.
- text: simple markup language for color change?
- log: LogButtons() options for specifying depth and/or hiding depth slider
- log: have more control over the log scope (e.g. stop logging when leaving current tree node scope)
@ -479,11 +489,12 @@
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
- input: rework IO to be able to pass actual events to fix temporal aliasing issues.
- input: support track pad style scrolling & slider edit.
- memory: add a way to discard allocs of unused/transient windows. with the current architecture new windows (including popup, opened combos, listbox) perform at least 3 allocs.
- misc: provide a way to compile out the entire implementation while providing a dummy API (e.g. #define IMGUI_DUMMY_IMPL)
- misc: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon?
- style editor: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space?
- style editor: color child window height expressed in multiple of line height.
!- examples: directx9/directx11: resizing window duplicate the font data :(
- optimization: use another hash function than crc32, e.g. FNV1a
- optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
- optimization: turn some the various stack vectors into statically-sized arrays
- optimization: better clipping for multi-component widgets
@ -908,7 +919,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
if ((*str & 0xe0) == 0xc0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 2) return 0;
if (in_text_end && in_text_end - (const char*)str < 2) return 1;
if (*str < 0xc2) return 2;
c = (unsigned int)((*str++ & 0x1f) << 6);
if ((*str & 0xc0) != 0x80) return 2;
@ -919,7 +930,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
if ((*str & 0xf0) == 0xe0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 3) return 0;
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
c = (unsigned int)((*str++ & 0x0f) << 12);
@ -933,7 +944,7 @@ int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char*
if ((*str & 0xf8) == 0xf0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 4) return 0;
if (in_text_end && in_text_end - (const char*)str < 4) return 1;
if (*str > 0xf4) return 4;
if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
@ -1761,6 +1772,17 @@ void ImGui::MemFree(void* ptr)
return GImGui->IO.MemFreeFn(ptr);
}
const char* ImGui::GetClipboardText()
{
return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn() : "";
}
void ImGui::SetClipboardText(const char* text)
{
if (GImGui->IO.SetClipboardTextFn)
GImGui->IO.SetClipboardTextFn(text);
}
const char* ImGui::GetVersion()
{
return IMGUI_VERSION;
@ -7217,7 +7239,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
if (g.IO.InputCharacters[0])
{
// Process text input (before we check for Return because using some IME will effectively send a Return?)
if (!is_ctrl_down && is_editable)
// We ignore CTRL inputs, but need to allow CTRL+ALT as some keyboards (e.g. German) use AltGR - which is Alt+Ctrl - to input certain characters.
if (!(is_ctrl_down && !is_alt_down) && is_editable)
{
for (int n = 0; n < IM_ARRAYSIZE(g.IO.InputCharacters) && g.IO.InputCharacters[n]; n++)
if (unsigned int c = (unsigned int)g.IO.InputCharacters[n])

View File

@ -416,9 +416,11 @@ namespace ImGui
IMGUI_API void CaptureKeyboardFromApp(); // manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered.
IMGUI_API void CaptureMouseFromApp(); // manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it).
// Helpers functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO()
// Helpers functions to access functions pointers in ImGui::GetIO()
IMGUI_API void* MemAlloc(size_t sz);
IMGUI_API void MemFree(void* ptr);
IMGUI_API const char* GetClipboardText();
IMGUI_API void SetClipboardText(const char* text);
// Internal state/context access - if you want to use multiple ImGui context, or share context between modules (e.g. DLL), or allocate the memory yourself
IMGUI_API const char* GetVersion();
@ -1113,7 +1115,7 @@ struct ImDrawList
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0, const ImVec2& uv1, ImU32 col = 0xFFFFFFFF);
IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 col = 0xFFFFFFFF);
IMGUI_API void AddPolyline(const ImVec2* points, const int num_points, ImU32 col, bool closed, float thickness, bool anti_aliased);
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, const int num_points, ImU32 col, bool anti_aliased);
IMGUI_API void AddBezierCurve(const ImVec2& pos0, const ImVec2& cp0, const ImVec2& cp1, const ImVec2& pos1, ImU32 col, float thickness, int num_segments = 0);

View File

@ -14,7 +14,7 @@
#include <math.h> // sqrtf, fabsf, fmodf, powf, cosf, sinf, floorf, ceilf
#include <stdio.h> // vsnprintf, sscanf, printf
#if defined(_MSC_VER) && !defined(__S3E__)
#if defined(_MSC_VER)
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#define snprintf _snprintf
#endif

View File

@ -26,7 +26,7 @@
#endif
#endif
#if defined(_MSC_VER) && !defined(__S3E__)
#if defined(_MSC_VER)
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#define snprintf _snprintf
@ -291,6 +291,7 @@ void ImDrawList::ChannelsMerge()
void ImDrawList::ChannelsSetCurrent(int idx)
{
IM_ASSERT(idx < _ChannelsCount);
if (_ChannelsCurrent == idx) return;
memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times
memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));

View File

@ -14,7 +14,7 @@
#include <stdio.h> // FILE*
#include <math.h> // sqrtf()
#if defined(_MSC_VER) && !defined(__S3E__)
#if defined(_MSC_VER)
#pragma warning (push)
#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport)
#endif
@ -698,6 +698,6 @@ namespace ImGui
} // namespace ImGuiP
#if defined(_MSC_VER) && !defined(__S3E__)
#if defined(_MSC_VER)
#pragma warning (pop)
#endif