mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Merge branch 'master' into docking
# Conflicts: # docs/CHANGELOG.txt # examples/example_win32_directx11/main.cpp # examples/example_win32_directx9/main.cpp # examples/imgui_impl_win32.cpp # examples/imgui_impl_win32.h # imgui.cpp
This commit is contained in:
commit
bb1e6f8af6
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@ -241,6 +241,9 @@ jobs:
|
|||||||
- name: Build example_glfw_metal
|
- name: Build example_glfw_metal
|
||||||
run: make -C examples/example_glfw_metal
|
run: make -C examples/example_glfw_metal
|
||||||
|
|
||||||
|
- name: Build example_sdl_metal
|
||||||
|
run: make -C examples/example_sdl_metal
|
||||||
|
|
||||||
- name: Build example_sdl_opengl2
|
- name: Build example_sdl_opengl2
|
||||||
run: make -C examples/example_sdl_opengl2
|
run: make -C examples/example_sdl_opengl2
|
||||||
if: github.event_name == 'schedule'
|
if: github.event_name == 'schedule'
|
||||||
|
@ -99,6 +99,29 @@ Other changes:
|
|||||||
to make the examples main.cpp easier to read.
|
to make the examples main.cpp easier to read.
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.76 WIP (In Progress)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Drag and Drop, Nav: Disabling navigation arrow keys when drag and drop is active. In the docking
|
||||||
|
branch pressing arrow keys while dragging a window from a tab could trigger an assert. (#3025)
|
||||||
|
- ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced
|
||||||
|
by default for standalone ColorButton.
|
||||||
|
- InputText: Fixed password fields displaying ASCII spaces as blanks instead of using the '*'
|
||||||
|
glyph. (#2149, #515)
|
||||||
|
- Font: Fixed non-ASCII space occasionally creating unnecessary empty polygons.
|
||||||
|
- Demo: Added a black and white gradient to Demo>Examples>Custom Rendering.
|
||||||
|
- Backends: Win32: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(),
|
||||||
|
ImGui_ImplWin32_GetDpiScaleForMonitor() helpers functions (backported from the docking branch).
|
||||||
|
Those functions makes it easier for example apps to support hi-dpi features without setting up
|
||||||
|
a manifest.
|
||||||
|
- Backends: SDL: Added ImGui_ImplSDL2_InitForMetal() for API consistency (even though the function
|
||||||
|
currently does nothing).
|
||||||
|
- Examples: Added SDL2+Metal example application. (#3017) [@coding-jackalope]
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.75 (Released 2020-02-10)
|
VERSION 1.75 (Released 2020-02-10)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
@ -7,7 +7,7 @@ dear imgui
|
|||||||
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
||||||
<br> _E-mail: contact @ dearimgui dot org_
|
<br> _E-mail: contact @ dearimgui dot org_
|
||||||
|
|
||||||
Individuals: support continued maintenance and development via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S) donations.
|
Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ You may also peak at the [Multi-Viewport](https://github.com/ocornut/imgui/issue
|
|||||||
|
|
||||||
**Who uses Dear ImGui?**
|
**Who uses Dear ImGui?**
|
||||||
|
|
||||||
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) and [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for a list of games/software which are publicly known to use dear imgui. Please add yours if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/2847)!
|
See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/2847)!
|
||||||
|
|
||||||
How to help
|
How to help
|
||||||
-----------
|
-----------
|
||||||
@ -183,31 +183,24 @@ Your contributions are keeping this project alive. The library is available unde
|
|||||||
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
Businesses: support continued development via invoiced technical support, maintenance, sponsoring contracts:
|
||||||
<br> _E-mail: contact @ dearimgui dot org_
|
<br> _E-mail: contact @ dearimgui dot org_
|
||||||
|
|
||||||
Individuals: support continued maintenance and development via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S) donations.
|
Individuals: support continued maintenance and development with [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S).
|
||||||
|
|
||||||
### Sponsors
|
Sponsors
|
||||||
|
--------
|
||||||
|
|
||||||
Ongoing Dear ImGui development is financially supported by users and private sponsors, recently:
|
Ongoing Dear ImGui development is financially supported by users and private sponsors, recently:
|
||||||
|
|
||||||
*Platinum-chocolate sponsors*
|
*Platinum-chocolate sponsors*
|
||||||
- Blizzard Entertainment
|
- [Blizzard](https://careers.blizzard.com/en-us/openings/engineering/all/all/all/1), [Google](https://github.com/google/filament), [Nvidia](https://developer.nvidia.com/nvidia-omniverse), [Ubisoft](https://montreal.ubisoft.com/en/ubisoft-sponsors-user-interface-library-for-c-dear-imgui/)
|
||||||
- Google
|
|
||||||
- Ubisoft
|
|
||||||
- Nvidia
|
|
||||||
|
|
||||||
*Double-chocolate sponsors*
|
*Double-chocolate and Salty caramel sponsors*
|
||||||
- Media Molecule, Mobigame, Aras Pranckevičius, Greggman, DotEmu, Nadeo, Supercell, Aiden Koss, Kylotonn.
|
- [DotEmu](http://www.dotemu.com), [Framefield](http://framefield.com), [Hexagon](https://hexagonxalt.com/the-technology/xalt-visualization), [Kylotonn](https://www.kylotonn.com), [Media Molecule](http://www.mediamolecule.com), [Mesh Consultants](https://www.meshconsultants.ca), [Mobigame](http://www.mobigame.net), [Nadeo](https://www.nadeo.com), [Supercell](http://www.supercell.com), [Remedy Entertainment](https://www.remedygames.com/), [Unit 2 Games](https://unit2games.com/)
|
||||||
|
|
||||||
*Salty caramel supporters*
|
From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations. Please see [detailed list of Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors).
|
||||||
- Remedy Entertainment, Next Level Games, Recognition Robotics, ikrima, Geoffrey Evans, Mercury Labs, Singularity Demo Group, Lionel Landwerlin, Ron Gilbert, Brandon Townsend, G3DVu, Cort Stratton, drudru, Harfang 3D, Jeff Roberts, Rainway inc, Ondra Voves, Mesh Consultants, Unit 2 Games, Neil Bickford, Bill Six, Graham Manders.
|
|
||||||
|
|
||||||
*Caramel supporters*
|
**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!**
|
||||||
- Jerome Lanquetot, Daniel Collin, Ctrl Alt Ninja, Neil Henning, Neil Blakey-Milner, Aleksei, NeiloGD, Eric, Game Atelier, Vincent Hamm, Morten Skaaning, Colin Riley, Sergio Gonzales, Andrew Berridge, Roy Eltham, Game Preservation Society, Josh Faust, Martin Donlon, Codecat, Doug McNabb, Emmanuel Julien, Guillaume Chereau, Jeffrey Slutter, Jeremiah Deckard, r-lyeh, Nekith, Joshua Fisher, Malte Hoffmann, Mustafa Karaalioglu, Merlyn Morgan-Graham, Per Vognsen, Fabian Giesen, Jan Staubach, Matt Hargett, John Shearer, Jesse Chounard, kingcoopa, Jonas Bernemann, Johan Andersson, Michael Labbe, Tomasz Golebiowski, Louis Schnellbach, Jimmy Andrews, Bojan Endrovski, Robin Berg Pettersen, Rachel Crawford, Andrew Johnson, Sean Hunter, Jordan Mellow, Nefarius Software Solutions, Laura Wieme, Robert Nix, Mick Honey, Steven Kah Hien Wong, Bartosz Bielecki, Oscar Penas, A M, Liam Moynihan, Artometa, Mark Lee, Dimitri Diakopoulos, Pete Goodwin, Johnathan Roatch, nyu lea, Oswald Hurlem, Semyon Smelyanskiy, Le Bach, Jeong MyeongSoo, Chris Matthews, Astrofra, Frederik De Bleser, Anticrisis, Matt Reyer.
|
|
||||||
|
|
||||||
And all other past and present supporters; THANK YOU!
|
Dear ImGui is using software and services provided free of charge for open source projects:
|
||||||
(Please contact me if you would like to be added or removed from this list)
|
|
||||||
|
|
||||||
Dear ImGui is using software and services kindly provided free of charge for open source projects:
|
|
||||||
- [PVS-Studio](https://www.viva64.com/en/b/0570/) for static analysis.
|
- [PVS-Studio](https://www.viva64.com/en/b/0570/) for static analysis.
|
||||||
- [GitHub actions](https://github.com/features/actions) for continuous integration systems.
|
- [GitHub actions](https://github.com/features/actions) for continuous integration systems.
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
dear imgui, v1.75
|
dear imgui, v1.76 WIP
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
examples/README.txt
|
examples/README.txt
|
||||||
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
||||||
@ -197,7 +197,7 @@ example_empscripten:
|
|||||||
|
|
||||||
example_glfw_metal/
|
example_glfw_metal/
|
||||||
GLFW (Mac) + Metal example.
|
GLFW (Mac) + Metal example.
|
||||||
= main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm.
|
= main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm
|
||||||
|
|
||||||
example_glfw_opengl2/
|
example_glfw_opengl2/
|
||||||
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
GLFW + OpenGL2 example (legacy, fixed pipeline).
|
||||||
@ -244,6 +244,10 @@ example_sdl_directx11/
|
|||||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
|
||||||
This to demonstrate usage of DirectX with SDL.
|
This to demonstrate usage of DirectX with SDL.
|
||||||
|
|
||||||
|
example_sdl_metal/
|
||||||
|
SDL2 (Mac) + Metal example.
|
||||||
|
= main.mm + imgui_impl_sdl.cpp + imgui_impl_metal.mm
|
||||||
|
|
||||||
example_sdl_opengl2/
|
example_sdl_opengl2/
|
||||||
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
|
||||||
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
// ImGui - standalone example application for GLFW + Metal, using programmable pipeline
|
// dear imgui: standalone example application for GLFW + Metal, using programmable pipeline
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
#include "imgui_impl_metal.h"
|
#include "imgui_impl_metal.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define GLFW_INCLUDE_NONE
|
#define GLFW_INCLUDE_NONE
|
||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
@ -13,8 +15,6 @@
|
|||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
#import <QuartzCore/QuartzCore.h>
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static void glfw_error_callback(int error, const char* description)
|
static void glfw_error_callback(int error, const char* description)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
|
// dear imgui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in the example_glfw_opengl2/ folder**
|
// **Prefer using the code in the example_glfw_opengl2/ folder**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
|
// dear imgui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_glfw.h"
|
#include "imgui_impl_glfw.h"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// dear imgui: standalone example application for SDL2 + DirectX 11
|
// dear imgui: standalone example application for SDL2 + DirectX 11
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_sdl.h"
|
#include "imgui_impl_sdl.h"
|
||||||
|
46
examples/example_sdl_metal/Makefile
Normal file
46
examples/example_sdl_metal/Makefile
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#
|
||||||
|
# You will need SDL2 (http://www.libsdl.org):
|
||||||
|
# brew install sdl2
|
||||||
|
#
|
||||||
|
|
||||||
|
#CXX = g++
|
||||||
|
#CXX = clang++
|
||||||
|
|
||||||
|
EXE = example_sdl_metal
|
||||||
|
SOURCES = main.mm
|
||||||
|
SOURCES += ../imgui_impl_sdl.cpp ../imgui_impl_metal.mm
|
||||||
|
SOURCES += ../../imgui.cpp ../../imgui_widgets.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp
|
||||||
|
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
|
||||||
|
|
||||||
|
LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore
|
||||||
|
LIBS += `sdl2-config --libs`
|
||||||
|
LIBS += -L/usr/local/lib
|
||||||
|
|
||||||
|
CXXFLAGS = -I../ -I../../ -I/usr/local/include
|
||||||
|
CXXFLAGS += `sdl2-config --cflags`
|
||||||
|
CXXFLAGS += -Wall -Wformat
|
||||||
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
|
||||||
|
%.o:%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../../%.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:../%.mm
|
||||||
|
$(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
|
||||||
|
|
||||||
|
%.o:%.mm
|
||||||
|
$(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $<
|
||||||
|
|
||||||
|
all: $(EXE)
|
||||||
|
@echo Build complete
|
||||||
|
|
||||||
|
$(EXE): $(OBJS)
|
||||||
|
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(EXE) $(OBJS)
|
179
examples/example_sdl_metal/main.mm
Normal file
179
examples/example_sdl_metal/main.mm
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
// Dear ImGui: standalone example application for SDL2 + Metal
|
||||||
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui_impl_sdl.h"
|
||||||
|
#include "imgui_impl_metal.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#import <Metal/Metal.h>
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
// Setup Dear ImGui binding
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
|
// Setup style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
//ImGui::StyleColorsClassic();
|
||||||
|
|
||||||
|
// Load Fonts
|
||||||
|
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
|
||||||
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
|
||||||
|
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
|
||||||
|
// - Read 'docs/FONTS.txt' for more instructions and details.
|
||||||
|
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
|
||||||
|
//io.Fonts->AddFontDefault();
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
|
||||||
|
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
|
||||||
|
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
//IM_ASSERT(font != NULL);
|
||||||
|
|
||||||
|
// Setup SDL
|
||||||
|
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
|
||||||
|
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0)
|
||||||
|
{
|
||||||
|
printf("Error: %s\n", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inform SDL that we will be using metal for rendering. Without this hint initialization of metal renderer may fail.
|
||||||
|
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
|
||||||
|
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL+Metal example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
|
if (window == NULL)
|
||||||
|
{
|
||||||
|
printf("Error creating window: %s\n", SDL_GetError());
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
if (renderer == NULL)
|
||||||
|
{
|
||||||
|
printf("Error creating renderer: %s\n", SDL_GetError());
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAMetalLayer* layer = (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderer);
|
||||||
|
layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||||
|
ImGui_ImplMetal_Init(layer.device);
|
||||||
|
ImGui_ImplSDL2_InitForMetal(window);
|
||||||
|
|
||||||
|
id<MTLCommandQueue> commandQueue = [layer.device newCommandQueue];
|
||||||
|
MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor new];
|
||||||
|
|
||||||
|
// Our state
|
||||||
|
bool show_demo_window = true;
|
||||||
|
bool show_another_window = false;
|
||||||
|
float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f};
|
||||||
|
|
||||||
|
// Main loop
|
||||||
|
bool done = false;
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
@autoreleasepool
|
||||||
|
{
|
||||||
|
// Poll and handle events (inputs, window resize, etc.)
|
||||||
|
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||||
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
|
// - 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.
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||||
|
if (event.type == SDL_QUIT)
|
||||||
|
done = true;
|
||||||
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||||
|
layer.drawableSize = CGSizeMake(width, height);
|
||||||
|
id<CAMetalDrawable> drawable = [layer nextDrawable];
|
||||||
|
|
||||||
|
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
|
||||||
|
renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
|
||||||
|
renderPassDescriptor.colorAttachments[0].texture = drawable.texture;
|
||||||
|
renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
|
||||||
|
renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||||
|
id <MTLRenderCommandEncoder> renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor];
|
||||||
|
[renderEncoder pushDebugGroup:@"ImGui demo"];
|
||||||
|
|
||||||
|
// Start the Dear ImGui frame
|
||||||
|
ImGui_ImplMetal_NewFrame(renderPassDescriptor);
|
||||||
|
ImGui_ImplSDL2_NewFrame(window);
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
|
||||||
|
if (show_demo_window)
|
||||||
|
ImGui::ShowDemoWindow(&show_demo_window);
|
||||||
|
|
||||||
|
// 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window.
|
||||||
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||||
|
|
||||||
|
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||||
|
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||||
|
ImGui::Checkbox("Another Window", &show_another_window);
|
||||||
|
|
||||||
|
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||||
|
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||||
|
|
||||||
|
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||||
|
counter++;
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("counter = %d", counter);
|
||||||
|
|
||||||
|
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Show another simple window.
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||||
|
ImGui::Text("Hello from another window!");
|
||||||
|
if (ImGui::Button("Close Me"))
|
||||||
|
show_another_window = false;
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
ImGui::Render();
|
||||||
|
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder);
|
||||||
|
|
||||||
|
[renderEncoder popDebugGroup];
|
||||||
|
[renderEncoder endEncoding];
|
||||||
|
|
||||||
|
[commandBuffer presentDrawable:drawable];
|
||||||
|
[commandBuffer commit];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
ImGui_ImplMetal_Shutdown();
|
||||||
|
ImGui_ImplSDL2_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
// dear imgui: standalone example application for SDL2 + OpenGL
|
// dear imgui: standalone example application for SDL2 + OpenGL
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
|
|
||||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||||
// **Prefer using the code in the example_sdl_opengl3/ folder**
|
// **Prefer using the code in the example_sdl_opengl3/ folder**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// dear imgui: standalone example application for SDL2 + OpenGL
|
// dear imgui: standalone example application for SDL2 + OpenGL
|
||||||
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
|
||||||
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
// (GL3W is a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc.)
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
@ -228,8 +228,10 @@ void CleanupRenderTarget()
|
|||||||
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
|
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Win32 message handler
|
// Win32 message handler
|
||||||
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
@ -243,8 +243,10 @@ void CleanupRenderTarget()
|
|||||||
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Win32 message handler
|
// Win32 message handler
|
||||||
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
@ -446,8 +446,10 @@ void ResizeSwapChain(HWND hWnd, int width, int height)
|
|||||||
assert(g_hSwapChainWaitableObject != NULL);
|
assert(g_hSwapChainWaitableObject != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Win32 message handler
|
// Win32 message handler
|
||||||
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
@ -150,9 +150,9 @@ int main(int, char**)
|
|||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::EndFrame();
|
ImGui::EndFrame();
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||||
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
|
D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f));
|
||||||
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
|
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
|
||||||
if (g_pd3dDevice->BeginScene() >= 0)
|
if (g_pd3dDevice->BeginScene() >= 0)
|
||||||
@ -228,8 +228,10 @@ void ResetDevice()
|
|||||||
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
#define WM_DPICHANGED 0x02E0 // From Windows SDK 8.1+ headers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Forward declare message handler from imgui_impl_win32.cpp
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
// Win32 message handler
|
// Win32 message handler
|
||||||
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
@ -68,16 +68,16 @@ static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
|||||||
g_pd3dDevice->SetPixelShader(NULL);
|
g_pd3dDevice->SetPixelShader(NULL);
|
||||||
g_pd3dDevice->SetVertexShader(NULL);
|
g_pd3dDevice->SetVertexShader(NULL);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, false);
|
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
|
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, true);
|
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||||
g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, false);
|
g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||||
|
@ -257,6 +257,11 @@ bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
|||||||
return ImGui_ImplSDL2_Init(window, NULL);
|
return ImGui_ImplSDL2_Init(window, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window)
|
||||||
|
{
|
||||||
|
return ImGui_ImplSDL2_Init(window);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui_ImplSDL2_Shutdown()
|
void ImGui_ImplSDL2_Shutdown()
|
||||||
{
|
{
|
||||||
ImGui_ImplSDL2_ShutdownPlatformInterface();
|
ImGui_ImplSDL2_ShutdownPlatformInterface();
|
||||||
|
@ -24,6 +24,7 @@ typedef union SDL_Event SDL_Event;
|
|||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window);
|
||||||
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
|
||||||
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(SDL_Window* window);
|
||||||
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core imgui)
|
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
@ -30,6 +30,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions.
|
||||||
// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.
|
// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.
|
||||||
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||||
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
||||||
@ -338,13 +339,18 @@ void ImGui_ImplWin32_NewFrame()
|
|||||||
#define DBT_DEVNODES_CHANGED 0x0007
|
#define DBT_DEVNODES_CHANGED 0x0007
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Process Win32 mouse/keyboard inputs.
|
// Win32 message handler (process Win32 mouse/keyboard inputs, etc.)
|
||||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
// Call from your application's message handler.
|
||||||
|
// When implementing your own back-end, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs.
|
||||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
// - 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.
|
// Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags.
|
||||||
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
|
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
|
||||||
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
|
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
|
||||||
|
#if 0
|
||||||
|
// Copy this line into your .cpp file to forward declare the function.
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
#endif
|
||||||
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (ImGui::GetCurrentContext() == NULL)
|
if (ImGui::GetCurrentContext() == NULL)
|
||||||
@ -418,27 +424,34 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
// DPI handling
|
// DPI-related helpers (optional)
|
||||||
// Those in theory should be simple calls but Windows has multiple ways to handle DPI, and most of them
|
//--------------------------------------------------------------------------------------------------------
|
||||||
// require recent Windows versions at runtime or recent Windows SDK at compile-time. Neither we want to depend on.
|
// - Use to enable DPI awareness without having to create an application manifest.
|
||||||
// So we dynamically select and load those functions to avoid dependencies. This is the scheme successfully
|
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||||
// used by GLFW (from which we borrowed some of the code here) and other applications aiming to be portable.
|
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||||
|
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||||
|
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
// At this point ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically.
|
// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable.
|
||||||
|
// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically.
|
||||||
|
// If you are trying to implement your own back-end for your own engine, you may ignore that noise.
|
||||||
//---------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Implement some of the functions and types normally declared in recent Windows SDK.
|
||||||
|
#if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS)
|
||||||
static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp)
|
static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp };
|
OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp };
|
||||||
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
|
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
|
||||||
ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||||
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||||
cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||||
return VerifyVersionInfoW(&osvi, mask, cond);
|
return ::VerifyVersionInfoW(&osvi, mask, cond);
|
||||||
}
|
}
|
||||||
#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WINBLUE
|
#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WINBLUE
|
||||||
#define IsWindows10OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0A00), LOBYTE(0x0A00), 0) // _WIN32_WINNT_WIN10
|
#endif
|
||||||
|
|
||||||
#ifndef DPI_ENUMS_DECLARED
|
#ifndef DPI_ENUMS_DECLARED
|
||||||
typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
|
typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
|
||||||
@ -451,13 +464,14 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
|
|||||||
#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
|
#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
|
||||||
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4
|
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4
|
||||||
#endif
|
#endif
|
||||||
typedef HRESULT(WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib+dll, Windows 8.1
|
typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+
|
||||||
typedef HRESULT(WINAPI * PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib+dll, Windows 8.1
|
typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+
|
||||||
typedef DPI_AWARENESS_CONTEXT(WINAPI * PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib+dll, Windows 10 v1607 (Creators Update)
|
typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update)
|
||||||
|
|
||||||
|
// Helper function to enable DPI awareness without setting up a manifest
|
||||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||||
{
|
{
|
||||||
// if (IsWindows10OrGreater()) // FIXME-DPI: This needs a manifest to succeed. Instead we try to grab the function pointer.
|
// if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer!
|
||||||
{
|
{
|
||||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||||
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
||||||
@ -470,22 +484,22 @@ void ImGui_ImplWin32_EnableDpiAwareness()
|
|||||||
{
|
{
|
||||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||||
if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
|
if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
|
||||||
SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SetProcessDPIAware();
|
SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SetProcessDPIAware();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma comment(lib, "gdi32") // GetDeviceCaps()
|
#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
||||||
{
|
{
|
||||||
UINT xdpi = 96, ydpi = 96;
|
UINT xdpi = 96, ydpi = 96;
|
||||||
if (::IsWindows8Point1OrGreater())
|
if (IsWindows8Point1OrGreater())
|
||||||
{
|
{
|
||||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||||
if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
|
if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
|
||||||
@ -508,6 +522,7 @@ float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
|||||||
return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
// IME (Input Method Editor) basic support for e.g. Asian language users
|
// IME (Input Method Editor) basic support for e.g. Asian language users
|
||||||
//--------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------
|
||||||
@ -845,3 +860,5 @@ static void ImGui_ImplWin32_ShutdownPlatformInterface()
|
|||||||
{
|
{
|
||||||
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(NULL));
|
::UnregisterClass(_T("ImGui Platform"), ::GetModuleHandle(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core imgui)
|
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||||
@ -18,14 +18,19 @@ IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
|||||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||||
//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
||||||
|
|
||||||
// DPI-related helpers (which run and compile without requiring 8.1 or 10, neither Windows version, neither associated SDK)
|
// Win32 message handler
|
||||||
|
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h>
|
||||||
|
// - You can COPY this line into your .cpp code to forward declare the function.
|
||||||
|
#if 0
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// DPI-related helpers (optional)
|
||||||
|
// - Use to enable DPI awareness without having to create an application manifest.
|
||||||
|
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||||
|
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||||
|
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||||
|
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
|
IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
|
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
|
||||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
|
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
|
||||||
|
|
||||||
// Handler for Win32 messages, update mouse/keyboard data.
|
|
||||||
// You may or not need this for your implementation, but it can serve as reference for handling inputs.
|
|
||||||
// Intentionally commented out to avoid dragging dependencies on <windows.h> types. You can COPY this line into your .cpp code instead.
|
|
||||||
#if 0
|
|
||||||
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
|
||||||
#endif
|
|
||||||
|
10
imgui.cpp
10
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -3387,6 +3387,9 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod
|
|||||||
|
|
||||||
// Handle mouse moving window
|
// Handle mouse moving window
|
||||||
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
|
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
|
||||||
|
// FIXME: We don't have strong guarantee that g.MovingWindow stay synched with g.ActiveId == g.MovingWindow->MoveId.
|
||||||
|
// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs,
|
||||||
|
// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other.
|
||||||
void ImGui::UpdateMouseMovingWindowNewFrame()
|
void ImGui::UpdateMouseMovingWindowNewFrame()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -9772,6 +9775,11 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
return false;
|
return false;
|
||||||
source_parent_id = window->IDStack.back();
|
source_parent_id = window->IDStack.back();
|
||||||
source_drag_active = IsMouseDragging(mouse_button);
|
source_drag_active = IsMouseDragging(mouse_button);
|
||||||
|
|
||||||
|
// Disable navigation and key inputs while dragging
|
||||||
|
g.ActiveIdUsingNavDirMask = ~(ImU32)0;
|
||||||
|
g.ActiveIdUsingNavInputMask = ~(ImU32)0;
|
||||||
|
g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
13
imgui.h
13
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -60,8 +60,8 @@ Index of this file:
|
|||||||
|
|
||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.75"
|
#define IMGUI_VERSION "1.76 WIP"
|
||||||
#define IMGUI_VERSION_NUM 17500
|
#define IMGUI_VERSION_NUM 17502
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
||||||
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
||||||
@ -1232,6 +1232,7 @@ enum ImGuiColorEditFlags_
|
|||||||
ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
|
ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker).
|
||||||
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
|
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
|
||||||
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
|
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
|
||||||
|
ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default)
|
||||||
|
|
||||||
// User Options (right-click on widget to change some of them).
|
// User Options (right-click on widget to change some of them).
|
||||||
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
|
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
|
||||||
@ -2171,9 +2172,12 @@ struct ImFontConfig
|
|||||||
IMGUI_API ImFontConfig();
|
IMGUI_API ImFontConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Hold rendering data for one glyph.
|
||||||
|
// (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this)
|
||||||
struct ImFontGlyph
|
struct ImFontGlyph
|
||||||
{
|
{
|
||||||
ImWchar Codepoint; // 0x0000..0xFFFF
|
unsigned int Codepoint : 31; // 0x0000..0xFFFF
|
||||||
|
unsigned int Visible : 1; // Flag to allow early out when rendering
|
||||||
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
|
float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in)
|
||||||
float X0, Y0, X1, Y1; // Glyph corners
|
float X0, Y0, X1, Y1; // Glyph corners
|
||||||
float U0, V0, U1, V1; // Texture coordinates
|
float U0, V0, U1, V1; // Texture coordinates
|
||||||
@ -2368,6 +2372,7 @@ struct ImFont
|
|||||||
IMGUI_API void GrowIndex(int new_size);
|
IMGUI_API void GrowIndex(int new_size);
|
||||||
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
IMGUI_API void AddGlyph(ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
|
||||||
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
|
||||||
|
IMGUI_API void SetGlyphVisible(ImWchar c, bool visible);
|
||||||
IMGUI_API void SetFallbackChar(ImWchar c);
|
IMGUI_API void SetFallbackChar(ImWchar c);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Help:
|
// Help:
|
||||||
@ -684,7 +684,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
{
|
{
|
||||||
ImGui::Text("blah blah");
|
ImGui::Text("blah blah");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("button")) {};
|
if (ImGui::SmallButton("button")) {}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1095,11 +1095,11 @@ static void ShowDemoWindowWidgets()
|
|||||||
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters);
|
||||||
|
|
||||||
ImGui::Text("Password input");
|
ImGui::Text("Password input");
|
||||||
static char bufpass[64] = "password123";
|
static char password[64] = "password123";
|
||||||
ImGui::InputText("password", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::InputText("password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
|
||||||
ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n");
|
||||||
ImGui::InputTextWithHint("password (w/ hint)", "<password>", bufpass, 64, ImGuiInputTextFlags_Password | ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::InputTextWithHint("password (w/ hint)", "<password>", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password);
|
||||||
ImGui::InputText("password (clear)", bufpass, 64, ImGuiInputTextFlags_CharsNoBlank);
|
ImGui::InputText("password (clear)", password, IM_ARRAYSIZE(password));
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1319,7 +1319,9 @@ static void ShowDemoWindowWidgets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Color button only:");
|
ImGui::Text("Color button only:");
|
||||||
ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
|
static bool no_border = false;
|
||||||
|
ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border);
|
||||||
|
ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80,80));
|
||||||
|
|
||||||
ImGui::Text("Color picker:");
|
ImGui::Text("Color picker:");
|
||||||
static bool alpha = true;
|
static bool alpha = true;
|
||||||
@ -3542,6 +3544,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
ImGui::Text("Codepoint: U+%04X", base + n);
|
ImGui::Text("Codepoint: U+%04X", base + n);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
ImGui::Text("Visible: %d", glyph->Visible);
|
||||||
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
|
ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX);
|
||||||
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
|
ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1);
|
||||||
ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
|
ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1);
|
||||||
@ -4553,7 +4556,6 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
if (ImGui::SliderInt("Circle segments", &circle_segments_override_v, 3, 40))
|
if (ImGui::SliderInt("Circle segments", &circle_segments_override_v, 3, 40))
|
||||||
circle_segments_override = true;
|
circle_segments_override = true;
|
||||||
ImGui::ColorEdit4("Color", &colf.x);
|
ImGui::ColorEdit4("Color", &colf.x);
|
||||||
ImGui::PopItemWidth();
|
|
||||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||||
const ImU32 col = ImColor(colf);
|
const ImU32 col = ImColor(colf);
|
||||||
const float spacing = 10.0f;
|
const float spacing = 10.0f;
|
||||||
@ -4592,6 +4594,28 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
|||||||
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
|
draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine)
|
||||||
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
|
draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255));
|
||||||
ImGui::Dummy(ImVec2((sz + spacing) * 9.8f, (sz + spacing) * 3));
|
ImGui::Dummy(ImVec2((sz + spacing) * 9.8f, (sz + spacing) * 3));
|
||||||
|
|
||||||
|
// Draw black and white gradients
|
||||||
|
static int gradient_steps = 16;
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::AlignTextToFramePadding();
|
||||||
|
ImGui::Text("Gradient steps");
|
||||||
|
ImGui::SameLine(); if (ImGui::RadioButton("16", gradient_steps == 16)) { gradient_steps = 16; }
|
||||||
|
ImGui::SameLine(); if (ImGui::RadioButton("32", gradient_steps == 32)) { gradient_steps = 32; }
|
||||||
|
ImGui::SameLine(); if (ImGui::RadioButton("256", gradient_steps == 256)) { gradient_steps = 256; }
|
||||||
|
ImVec2 gradient_size = ImVec2(ImGui::CalcItemWidth(), 64.0f);
|
||||||
|
x = ImGui::GetCursorScreenPos().x;
|
||||||
|
y = ImGui::GetCursorScreenPos().y;
|
||||||
|
for (int n = 0; n < gradient_steps; n++)
|
||||||
|
{
|
||||||
|
float f0 = n / (float)gradient_steps;
|
||||||
|
float f1 = (n + 1) / (float)gradient_steps;
|
||||||
|
ImU32 col32 = ImGui::GetColorU32(ImVec4(f0, f0, f0, 1.0f));
|
||||||
|
draw_list->AddRectFilled(ImVec2(x + gradient_size.x * f0, y), ImVec2(x + gradient_size.x * f1, y + gradient_size.y), col32);
|
||||||
|
}
|
||||||
|
ImGui::InvisibleButton("##gradient", gradient_size);
|
||||||
|
|
||||||
|
ImGui::PopItemWidth();
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -623,8 +623,8 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
|
|||||||
|
|
||||||
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
|
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
|
||||||
// Those macros expects l-values.
|
// Those macros expects l-values.
|
||||||
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } }
|
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
||||||
#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; }
|
#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0)
|
||||||
|
|
||||||
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
|
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
|
||||||
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
|
||||||
@ -686,7 +686,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
|||||||
// Average normals
|
// Average normals
|
||||||
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
|
||||||
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
|
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
|
||||||
IM_FIXNORMAL2F(dm_x, dm_y)
|
IM_FIXNORMAL2F(dm_x, dm_y);
|
||||||
dm_x *= AA_SIZE;
|
dm_x *= AA_SIZE;
|
||||||
dm_y *= AA_SIZE;
|
dm_y *= AA_SIZE;
|
||||||
|
|
||||||
@ -1948,7 +1948,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
{
|
{
|
||||||
IM_ASSERT(atlas->ConfigData.Size > 0);
|
IM_ASSERT(atlas->ConfigData.Size > 0);
|
||||||
|
|
||||||
ImFontAtlasBuildRegisterDefaultCustomRects(atlas);
|
ImFontAtlasBuildInit(atlas);
|
||||||
|
|
||||||
// Clear atlas
|
// Clear atlas
|
||||||
atlas->TexID = (ImTextureID)NULL;
|
atlas->TexID = (ImTextureID)NULL;
|
||||||
@ -2200,7 +2200,8 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
|
// Register default custom rectangles (this is called/shared by both the stb_truetype and the FreeType builder)
|
||||||
|
void ImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
if (atlas->CustomRectIds[0] >= 0)
|
if (atlas->CustomRectIds[0] >= 0)
|
||||||
return;
|
return;
|
||||||
@ -2627,6 +2628,7 @@ void ImFont::BuildLookupTable()
|
|||||||
for (int i = 0; i != Glyphs.Size; i++)
|
for (int i = 0; i != Glyphs.Size; i++)
|
||||||
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
|
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
|
||||||
|
|
||||||
|
// Build lookup table
|
||||||
IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
|
IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
|
||||||
IndexAdvanceX.clear();
|
IndexAdvanceX.clear();
|
||||||
IndexLookup.clear();
|
IndexLookup.clear();
|
||||||
@ -2643,7 +2645,7 @@ void ImFont::BuildLookupTable()
|
|||||||
// FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
|
// FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
|
||||||
if (FindGlyph((ImWchar)' '))
|
if (FindGlyph((ImWchar)' '))
|
||||||
{
|
{
|
||||||
if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times
|
if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times (FIXME: Flaky)
|
||||||
Glyphs.resize(Glyphs.Size + 1);
|
Glyphs.resize(Glyphs.Size + 1);
|
||||||
ImFontGlyph& tab_glyph = Glyphs.back();
|
ImFontGlyph& tab_glyph = Glyphs.back();
|
||||||
tab_glyph = *FindGlyph((ImWchar)' ');
|
tab_glyph = *FindGlyph((ImWchar)' ');
|
||||||
@ -2653,6 +2655,11 @@ void ImFont::BuildLookupTable()
|
|||||||
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
|
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
|
||||||
|
SetGlyphVisible((ImWchar)' ', false);
|
||||||
|
SetGlyphVisible((ImWchar)'\t', false);
|
||||||
|
|
||||||
|
// Setup fall-backs
|
||||||
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
|
||||||
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
|
||||||
for (int i = 0; i < max_codepoint + 1; i++)
|
for (int i = 0; i < max_codepoint + 1; i++)
|
||||||
@ -2660,6 +2667,12 @@ void ImFont::BuildLookupTable()
|
|||||||
IndexAdvanceX[i] = FallbackAdvanceX;
|
IndexAdvanceX[i] = FallbackAdvanceX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImFont::SetGlyphVisible(ImWchar c, bool visible)
|
||||||
|
{
|
||||||
|
if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)c))
|
||||||
|
glyph->Visible = visible ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ImFont::SetFallbackChar(ImWchar c)
|
void ImFont::SetFallbackChar(ImWchar c)
|
||||||
{
|
{
|
||||||
FallbackChar = c;
|
FallbackChar = c;
|
||||||
@ -2681,7 +2694,8 @@ void ImFont::AddGlyph(ImWchar codepoint, float x0, float y0, float x1, float y1,
|
|||||||
{
|
{
|
||||||
Glyphs.resize(Glyphs.Size + 1);
|
Glyphs.resize(Glyphs.Size + 1);
|
||||||
ImFontGlyph& glyph = Glyphs.back();
|
ImFontGlyph& glyph = Glyphs.back();
|
||||||
glyph.Codepoint = (ImWchar)codepoint;
|
glyph.Codepoint = (unsigned int)codepoint;
|
||||||
|
glyph.Visible = (x0 != x1) && (y0 != y1);
|
||||||
glyph.X0 = x0;
|
glyph.X0 = x0;
|
||||||
glyph.Y0 = y0;
|
glyph.Y0 = y0;
|
||||||
glyph.X1 = x1;
|
glyph.X1 = x1;
|
||||||
@ -2930,17 +2944,15 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
|||||||
|
|
||||||
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
|
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
|
||||||
{
|
{
|
||||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
|
const ImFontGlyph* glyph = FindGlyph(c);
|
||||||
|
if (!glyph || !glyph->Visible)
|
||||||
return;
|
return;
|
||||||
if (const ImFontGlyph* glyph = FindGlyph(c))
|
|
||||||
{
|
|
||||||
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
||||||
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
||||||
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
pos.y = IM_FLOOR(pos.y + DisplayOffset.y);
|
||||||
draw_list->PrimReserve(6, 4);
|
draw_list->PrimReserve(6, 4);
|
||||||
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
|
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
|
||||||
{
|
{
|
||||||
@ -3052,13 +3064,12 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float char_width = 0.0f;
|
const ImFontGlyph* glyph = FindGlyph((ImWchar)c);
|
||||||
if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c))
|
if (glyph == NULL)
|
||||||
{
|
continue;
|
||||||
char_width = glyph->AdvanceX * scale;
|
|
||||||
|
|
||||||
// Arbitrarily assume that both space and tabs are empty glyphs as an optimization
|
float char_width = glyph->AdvanceX * scale;
|
||||||
if (c != ' ' && c != '\t')
|
if (glyph->Visible)
|
||||||
{
|
{
|
||||||
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
|
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
|
||||||
float x1 = x + glyph->X0 * scale;
|
float x1 = x + glyph->X0 * scale;
|
||||||
@ -3117,8 +3128,6 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
x += char_width;
|
x += char_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
@ -882,7 +882,7 @@ struct ImGuiColumns
|
|||||||
// Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
|
// Helper function to calculate a circle's segment count given its radius and a "maximum error" value.
|
||||||
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 12
|
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 12
|
||||||
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
|
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512
|
||||||
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp((int)((IM_PI * 2.0f) / ImAcos((_RAD - _MAXERROR) / _RAD)), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
|
#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp((int)((IM_PI * 2.0f) / ImAcos(((_RAD) - (_MAXERROR)) / (_RAD))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX)
|
||||||
|
|
||||||
// Data shared between all ImDrawList instances
|
// Data shared between all ImDrawList instances
|
||||||
// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
|
// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure.
|
||||||
@ -2122,7 +2122,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// ImFontAtlas internals
|
// ImFontAtlas internals
|
||||||
IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque);
|
||||||
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.75
|
// dear imgui, v1.76 WIP
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4966,8 +4966,12 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|||||||
float grid_step = ImMin(size.x, size.y) / 2.99f;
|
float grid_step = ImMin(size.x, size.y) / 2.99f;
|
||||||
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
|
float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f);
|
||||||
ImRect bb_inner = bb;
|
ImRect bb_inner = bb;
|
||||||
float off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
|
float off = 0.0f;
|
||||||
|
if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
|
||||||
|
{
|
||||||
|
off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts.
|
||||||
bb_inner.Expand(off);
|
bb_inner.Expand(off);
|
||||||
|
}
|
||||||
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
|
if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f)
|
||||||
{
|
{
|
||||||
float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f);
|
float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f);
|
||||||
@ -4984,10 +4988,13 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|||||||
window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
|
window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding, ImDrawCornerFlags_All);
|
||||||
}
|
}
|
||||||
RenderNavHighlight(bb, id);
|
RenderNavHighlight(bb, id);
|
||||||
|
if ((flags & ImGuiColorEditFlags_NoBorder) == 0)
|
||||||
|
{
|
||||||
if (g.Style.FrameBorderSize > 0.0f)
|
if (g.Style.FrameBorderSize > 0.0f)
|
||||||
RenderFrameBorder(bb.Min, bb.Max, rounding);
|
RenderFrameBorder(bb.Min, bb.Max, rounding);
|
||||||
else
|
else
|
||||||
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
|
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border
|
||||||
|
}
|
||||||
|
|
||||||
// Drag and Drop Source
|
// Drag and Drop Source
|
||||||
// NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.
|
// NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test.
|
||||||
|
@ -2538,11 +2538,11 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, i
|
|||||||
// There are no other cases.
|
// There are no other cases.
|
||||||
STBTT_assert(0);
|
STBTT_assert(0);
|
||||||
break;
|
break;
|
||||||
};
|
} // [DEAR IMGUI] removed ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
};
|
} // [DEAR IMGUI] removed ;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO: Implement other stuff.
|
// TODO: Implement other stuff.
|
||||||
@ -4132,7 +4132,7 @@ STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect
|
|||||||
STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
|
STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
|
||||||
{
|
{
|
||||||
stbtt_fontinfo info;
|
stbtt_fontinfo info;
|
||||||
int i,j,n, return_value = 1;
|
int i,j,n, return_value; // [DEAR IMGUI] removed = 1
|
||||||
//stbrp_context *context = (stbrp_context *) spc->pack_info;
|
//stbrp_context *context = (stbrp_context *) spc->pack_info;
|
||||||
stbrp_rect *rects;
|
stbrp_rect *rects;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ bool ImFontAtlasBuildWithFreeType(FT_Library ft_library, ImFontAtlas* atlas, uns
|
|||||||
{
|
{
|
||||||
IM_ASSERT(atlas->ConfigData.Size > 0);
|
IM_ASSERT(atlas->ConfigData.Size > 0);
|
||||||
|
|
||||||
ImFontAtlasBuildRegisterDefaultCustomRects(atlas);
|
ImFontAtlasBuildInit(atlas);
|
||||||
|
|
||||||
// Clear atlas
|
// Clear atlas
|
||||||
atlas->TexID = (ImTextureID)NULL;
|
atlas->TexID = (ImTextureID)NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user