Added GUI, some menus dont work yet.
Fixed uniform scaling. Removed splash screen.pull/15/head
parent
9a10d72e1f
commit
e0638c598d
|
@ -53,8 +53,6 @@ set(SOURCE_FILES
|
|||
SpaceCadetPinball/Sound.cpp
|
||||
SpaceCadetPinball/Sound.h
|
||||
SpaceCadetPinball/SpaceCadetPinball.cpp
|
||||
SpaceCadetPinball/splash.cpp
|
||||
SpaceCadetPinball/splash.h
|
||||
SpaceCadetPinball/TBall.cpp
|
||||
SpaceCadetPinball/TBall.h
|
||||
SpaceCadetPinball/TBlocker.cpp
|
||||
|
@ -138,7 +136,23 @@ set(SOURCE_FILES
|
|||
SpaceCadetPinball/winmain.cpp
|
||||
SpaceCadetPinball/winmain.h
|
||||
SpaceCadetPinball/zdrv.cpp
|
||||
SpaceCadetPinball/zdrv.h)
|
||||
SpaceCadetPinball/zdrv.h
|
||||
SpaceCadetPinball/imconfig.h
|
||||
SpaceCadetPinball/imgui_internal.h
|
||||
SpaceCadetPinball/imgui.cpp
|
||||
SpaceCadetPinball/imgui.h
|
||||
SpaceCadetPinball/imgui_sdl.cpp
|
||||
SpaceCadetPinball/imgui_sdl.h
|
||||
SpaceCadetPinball/imgui_draw.cpp
|
||||
SpaceCadetPinball/imgui_widgets.cpp
|
||||
SpaceCadetPinball/imgui_tables.cpp
|
||||
SpaceCadetPinball/imgui_demo.cpp
|
||||
SpaceCadetPinball/imgui_impl_sdl.cpp
|
||||
SpaceCadetPinball/imgui_impl_sdl.h
|
||||
SpaceCadetPinball/imstb_textedit.h
|
||||
SpaceCadetPinball/imstb_rectpack.h
|
||||
SpaceCadetPinball/imstb_truetype.h
|
||||
)
|
||||
|
||||
add_executable(SpaceCadetPinball ${SOURCE_FILES})
|
||||
|
||||
|
|
|
@ -20,8 +20,31 @@
|
|||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ]
|
||||
},
|
||||
{
|
||||
"name": "x86-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x86" ],
|
||||
"variables": []
|
||||
},
|
||||
{
|
||||
"name": "x64-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||
"variables": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -9,15 +9,8 @@
|
|||
|
||||
|
||||
int fullscrn::screen_mode;
|
||||
HWND fullscrn::hWnd;
|
||||
tagRECT fullscrn::WindowRect1, fullscrn::WindowRect2;
|
||||
rectangle_type fullscrn::WHRect;
|
||||
int fullscrn::fullscrn_flag1;
|
||||
int fullscrn::display_changed;
|
||||
int fullscrn::ChangeDisplay, fullscrn::ignoreNextDisplayChangeFg;
|
||||
int fullscrn::trick = 1;
|
||||
int fullscrn::MenuEnabled;
|
||||
HMENU fullscrn::MenuHandle;
|
||||
|
||||
int fullscrn::resolution = 0;
|
||||
int fullscrn::maxResolution = 0;
|
||||
const resolution_info fullscrn::resolution_array[3] =
|
||||
|
@ -28,45 +21,12 @@ const resolution_info fullscrn::resolution_array[3] =
|
|||
};
|
||||
float fullscrn::ScaleX = 1;
|
||||
float fullscrn::ScaleY = 1;
|
||||
float fullscrn::OffsetX = 0;
|
||||
float fullscrn::OffsetY = 0;
|
||||
int fullscrn::OffsetX = 0;
|
||||
int fullscrn::OffsetY = 0;
|
||||
|
||||
void fullscrn::init(int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay)
|
||||
void fullscrn::init()
|
||||
{
|
||||
WHRect.XPosition = 0;
|
||||
WHRect.YPosition = 0;
|
||||
ChangeDisplay = changeDisplay;
|
||||
hWnd = winHandle;
|
||||
MenuHandle = menuHandle;
|
||||
WHRect.Width = width;
|
||||
WHRect.Height = height;
|
||||
|
||||
GetWindowRect(GetDesktopWindow(), &fullscrn::WindowRect1);
|
||||
int widht2 = width + 2 * GetSystemMetrics(SM_CXBORDER);
|
||||
int height2 = height + 2 * GetSystemMetrics(SM_CYBORDER);
|
||||
int menuHeight = GetSystemMetrics(SM_CYMENU);
|
||||
int captionHeight = GetSystemMetrics(SM_CYCAPTION);
|
||||
int borderHeight = WindowRect1.bottom - WindowRect1.top - height2;
|
||||
|
||||
WindowRect2.bottom = borderHeight / 2 - 2 + height2 + 4;
|
||||
WindowRect2.right = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2 + widht2 + 4;
|
||||
WindowRect2.left = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2;
|
||||
WindowRect2.top = borderHeight / 2 - (captionHeight + menuHeight) - 2;
|
||||
|
||||
/*RECT client{0,0,width,height};
|
||||
AdjustWindowRect(&client, winmain::WndStyle, true);*/
|
||||
MoveWindow(
|
||||
hWnd,
|
||||
(WindowRect1.right - WindowRect1.left - widht2) / 2 - 2,
|
||||
WindowRect2.top,
|
||||
WindowRect2.right - WindowRect2.left + 10,
|
||||
WindowRect2.bottom - WindowRect2.top + 10,
|
||||
0);
|
||||
// Todo: WH + 10 hack: original request 640x480 window but somehow receives 650x490, even thought spyxx says it is 640x480
|
||||
fullscrn_flag1 = 0;
|
||||
|
||||
window_size_changed();
|
||||
//assertm(ScaleX == 1 && ScaleY == 1, "Wrong default client size");
|
||||
}
|
||||
|
||||
void fullscrn::shutdown()
|
||||
|
@ -83,72 +43,26 @@ int fullscrn::set_screen_mode(int isFullscreen)
|
|||
screen_mode = isFullscreen;
|
||||
if (isFullscreen)
|
||||
{
|
||||
if (IsWindowVisible(hWnd))
|
||||
GetWindowRect(hWnd, &WindowRect2);
|
||||
enableFullscreen();
|
||||
BYTE1(fullscrn_flag1) |= 0x80u;
|
||||
InvalidateRect(hWnd, nullptr, 1);
|
||||
set_menu_mode(0);
|
||||
result = disableWindowFlagsDisDlg();
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
disableFullscreen();
|
||||
BYTE1(fullscrn_flag1) |= 0x80u;
|
||||
InvalidateRect(hWnd, nullptr, 1);
|
||||
set_menu_mode(1);
|
||||
result = RedrawWindow(nullptr, nullptr, nullptr, 0x185u);
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int fullscrn::disableWindowFlagsDisDlg()
|
||||
{
|
||||
long style = GetWindowLongA(hWnd, -16);
|
||||
return SetWindowLongA(hWnd, -16, style & ~(WS_CAPTION | WS_THICKFRAME));
|
||||
}
|
||||
|
||||
int fullscrn::setWindowFlagsDisDlg()
|
||||
{
|
||||
int style = GetWindowLongA(hWnd, -16);
|
||||
return SetWindowLongA(hWnd, -16, style | WS_CAPTION | WS_THICKFRAME);
|
||||
}
|
||||
|
||||
int fullscrn::enableFullscreen()
|
||||
{
|
||||
tagRECT Rect{};
|
||||
DEVMODEA DevMode{};
|
||||
|
||||
if (ChangeDisplay && !display_changed)
|
||||
if (!display_changed)
|
||||
{
|
||||
DevMode.dmSize = sizeof DevMode;
|
||||
DevMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||
DevMode.dmPelsWidth = resolution_array[resolution].ScreenWidth;
|
||||
DevMode.dmPelsHeight = resolution_array[resolution].ScreenHeight;
|
||||
DevMode.dmBitsPerPel = 32;
|
||||
disableWindowFlagsDisDlg();
|
||||
if (trick)
|
||||
{
|
||||
GetWindowRect(GetDesktopWindow(), &Rect);
|
||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, Rect.right - Rect.left + 1,
|
||||
Rect.bottom - Rect.top + 1, SWP_NOREDRAW);
|
||||
}
|
||||
ignoreNextDisplayChangeFg = 1;
|
||||
LONG changeDispResult = ChangeDisplaySettingsA(&DevMode, CDS_FULLSCREEN);
|
||||
if (changeDispResult == DISP_CHANGE_RESTART)
|
||||
{
|
||||
DevMode.dmFields &= ~DM_BITSPERPEL;
|
||||
ignoreNextDisplayChangeFg = 1;
|
||||
changeDispResult = ChangeDisplaySettingsA(&DevMode, CDS_FULLSCREEN);
|
||||
}
|
||||
display_changed = changeDispResult == DISP_CHANGE_SUCCESSFUL;
|
||||
SDL_SetWindowFullscreen(winmain::MainWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
display_changed = 1;
|
||||
if (display_changed)
|
||||
return 1;
|
||||
}
|
||||
GetWindowRect(GetDesktopWindow(), &Rect);
|
||||
disableWindowFlagsDisDlg();
|
||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, Rect.right - Rect.left + 1, Rect.bottom - Rect.top + 1, SWP_NOREDRAW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -156,154 +70,13 @@ int fullscrn::disableFullscreen()
|
|||
{
|
||||
if (display_changed)
|
||||
{
|
||||
SDL_SetWindowFullscreen(winmain::MainWindow, 0);
|
||||
display_changed = 0;
|
||||
ignoreNextDisplayChangeFg = 1;
|
||||
ChangeDisplaySettingsA(nullptr, CDS_FULLSCREEN);
|
||||
if (trick)
|
||||
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
}
|
||||
setWindowFlagsDisDlg();
|
||||
SetWindowPos(
|
||||
hWnd,
|
||||
HWND_TOP,
|
||||
WindowRect2.left,
|
||||
WindowRect2.top,
|
||||
WindowRect2.right - WindowRect2.left,
|
||||
WindowRect2.bottom - WindowRect2.top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool fullscrn::set_menu_mode(int menuEnabled)
|
||||
{
|
||||
BOOL result;
|
||||
|
||||
MenuEnabled = menuEnabled;
|
||||
GetWindowCenter();
|
||||
if (MenuEnabled)
|
||||
{
|
||||
fullscrn_flag1 |= 2u;
|
||||
InvalidateRect(hWnd, nullptr, 1);
|
||||
result = SetMenu(hWnd, MenuHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
fullscrn_flag1 |= 1u;
|
||||
InvalidateRect(hWnd, nullptr, 1);
|
||||
result = SetMenu(hWnd, nullptr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void fullscrn::GetWindowCenter()
|
||||
{
|
||||
int yPos;
|
||||
tagRECT Rect{};
|
||||
|
||||
if (screen_mode)
|
||||
{
|
||||
GetWindowRect(GetDesktopWindow(), &Rect);
|
||||
render::vscreen.XPosition = (Rect.right - render::vscreen.Width - Rect.left) / 2;
|
||||
yPos = (Rect.bottom - render::vscreen.Height - Rect.top) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
render::vscreen.XPosition = 0;
|
||||
yPos = GetSystemMetrics(15);
|
||||
}
|
||||
render::vscreen.YPosition = yPos;
|
||||
if (MenuEnabled)
|
||||
render::vscreen.YPosition -= GetSystemMetrics(15);
|
||||
}
|
||||
|
||||
void fullscrn::force_redraw()
|
||||
{
|
||||
BYTE1(fullscrn_flag1) |= 0x80u;
|
||||
}
|
||||
|
||||
|
||||
void fullscrn::center_in(HWND parent, HWND child)
|
||||
{
|
||||
LONG right;
|
||||
tagRECT childRect{}, parentRect{}, desktopRect{};
|
||||
|
||||
GetWindowRect(parent, &parentRect);
|
||||
GetWindowRect(child, &childRect);
|
||||
GetWindowRect(GetDesktopWindow(), &desktopRect);
|
||||
if (display_changed)
|
||||
{
|
||||
desktopRect.bottom = 480;
|
||||
desktopRect.left = 0;
|
||||
desktopRect.top = 0;
|
||||
right = 640;
|
||||
desktopRect.right = 640;
|
||||
parentRect.left = 0;
|
||||
parentRect.top = 0;
|
||||
parentRect.right = 640;
|
||||
parentRect.bottom = 480;
|
||||
}
|
||||
else
|
||||
{
|
||||
right = desktopRect.right;
|
||||
}
|
||||
|
||||
int childHeight = childRect.bottom - childRect.top;
|
||||
int smthWidth = parentRect.left + (parentRect.right + childRect.left - childRect.right - parentRect.left) / 2;
|
||||
int smthHeight = parentRect.top + (parentRect.bottom + childRect.top - childRect.bottom - parentRect.top) / 2;
|
||||
if (childRect.right - childRect.left + smthWidth > right)
|
||||
smthWidth = right - (childRect.right - childRect.left);
|
||||
if (childHeight + smthHeight > desktopRect.bottom)
|
||||
smthHeight = desktopRect.bottom - childHeight;
|
||||
if (smthWidth < desktopRect.left)
|
||||
smthWidth = desktopRect.left;
|
||||
if (smthHeight < desktopRect.top)
|
||||
smthHeight = desktopRect.top;
|
||||
MoveWindow(child, smthWidth, smthHeight, childRect.right - childRect.left, childRect.bottom - childRect.top, 0);
|
||||
}
|
||||
|
||||
int fullscrn::displaychange()
|
||||
{
|
||||
int result = 0;
|
||||
if (ignoreNextDisplayChangeFg)
|
||||
{
|
||||
ignoreNextDisplayChangeFg = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (screen_mode && display_changed)
|
||||
{
|
||||
display_changed = 0;
|
||||
screen_mode = 0;
|
||||
setWindowFlagsDisDlg();
|
||||
BYTE1(fullscrn_flag1) |= 0x80u;
|
||||
InvalidateRect(hWnd, nullptr, 1);
|
||||
set_menu_mode(1);
|
||||
SetWindowPos(
|
||||
hWnd,
|
||||
HWND_TOP,
|
||||
WindowRect2.left,
|
||||
WindowRect2.top,
|
||||
WindowRect2.right - WindowRect2.left,
|
||||
WindowRect2.bottom - WindowRect2.top,
|
||||
SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE);
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowPos(
|
||||
hWnd,
|
||||
HWND_TOP,
|
||||
WindowRect2.left,
|
||||
WindowRect2.top,
|
||||
WindowRect2.right - WindowRect2.left,
|
||||
WindowRect2.bottom - WindowRect2.top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
center_in(GetDesktopWindow(), hWnd);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void fullscrn::activate(int flag)
|
||||
{
|
||||
if (screen_mode)
|
||||
|
@ -311,76 +84,10 @@ void fullscrn::activate(int flag)
|
|||
if (!flag)
|
||||
{
|
||||
set_screen_mode(0);
|
||||
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fullscrn::fillRect(int right, int bottom, int left, int top)
|
||||
{
|
||||
RECT rc;
|
||||
auto brush = CreateSolidBrush(0);
|
||||
if (brush)
|
||||
{
|
||||
auto dc = winmain::_GetDC(hWnd);
|
||||
if (dc)
|
||||
{
|
||||
auto prevBrush = SelectObject(dc, brush);
|
||||
rc.right = left + right + 1;
|
||||
rc.bottom = top + bottom + 1;
|
||||
rc.left = left;
|
||||
rc.top = top;
|
||||
FillRect(dc, &rc, brush);
|
||||
SelectObject(dc, prevBrush);
|
||||
ReleaseDC(hWnd, dc);
|
||||
}
|
||||
DeleteObject(brush);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned fullscrn::convert_mouse_pos(unsigned int mouseXY)
|
||||
{
|
||||
uint16_t x = mouseXY & 0xffFF - render::vscreen.XPosition;
|
||||
uint16_t y = (mouseXY >> 16) - render::vscreen.YPosition;
|
||||
return x | y << 16;
|
||||
}
|
||||
|
||||
void fullscrn::getminmaxinfo(MINMAXINFO* maxMin)
|
||||
{
|
||||
/*Block down-scaling lower than min resolution*/
|
||||
maxMin->ptMinTrackSize = POINT
|
||||
{
|
||||
resolution_array[0].ScreenWidth / 2,
|
||||
resolution_array[0].ScreenHeight / 2
|
||||
};
|
||||
}
|
||||
|
||||
void fullscrn::paint()
|
||||
{
|
||||
int menuHeight;
|
||||
if (screen_mode)
|
||||
{
|
||||
if ((fullscrn_flag1 & 0x8000) == 0 && fullscrn_flag1)
|
||||
{
|
||||
if (fullscrn_flag1 & 1)
|
||||
{
|
||||
menuHeight = GetSystemMetrics(SM_CYMENU);
|
||||
fillRect(WindowRect1.right - 1, menuHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MenuEnabled)
|
||||
menuHeight = GetSystemMetrics(SM_CYMENU);
|
||||
else
|
||||
menuHeight = 0;
|
||||
fillRect(WindowRect1.right, menuHeight + WindowRect1.bottom, 0, 0);
|
||||
}
|
||||
}
|
||||
render::paint();
|
||||
fullscrn_flag1 = 0;
|
||||
}
|
||||
|
||||
int fullscrn::GetResolution()
|
||||
{
|
||||
return resolution;
|
||||
|
@ -432,16 +139,8 @@ int fullscrn::get_screen_resolution()
|
|||
|
||||
void fullscrn::window_size_changed()
|
||||
{
|
||||
/*No scaling in fullscreen mode*/
|
||||
if (display_changed)
|
||||
{
|
||||
ScaleY = ScaleX = 1;
|
||||
OffsetX = OffsetY = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
SDL_GetWindowSize(winmain::MainWindow, &width, &height);
|
||||
SDL_GetRendererOutputSize(winmain::Renderer, &width, &height);
|
||||
auto res = &resolution_array[resolution];
|
||||
ScaleX = static_cast<float>(width) / res->TableWidth;
|
||||
ScaleY = static_cast<float>(height) / res->TableHeight;
|
||||
|
@ -450,13 +149,13 @@ void fullscrn::window_size_changed()
|
|||
if (options::Options.UniformScaling)
|
||||
{
|
||||
ScaleY = ScaleX = min(ScaleX, ScaleY);
|
||||
OffsetX = floor((width - res->TableWidth * ScaleX) / 2);
|
||||
OffsetY = floor((height - res->TableHeight * ScaleY) / 2);
|
||||
auto dc = GetDC(hWnd);
|
||||
if (dc)
|
||||
{
|
||||
BitBlt(dc, 0, 0, width, height, dc, 0, 0, BLACKNESS);
|
||||
ReleaseDC(hWnd, dc);
|
||||
}
|
||||
OffsetX = static_cast<int>(floor((width - res->TableWidth * ScaleX) / 2));
|
||||
OffsetY = static_cast<int>(floor((height - res->TableHeight * ScaleY) / 2));
|
||||
}
|
||||
|
||||
gdrv::DestinationRect = SDL_Rect
|
||||
{
|
||||
OffsetX, OffsetY,
|
||||
width - OffsetX * 2, height - OffsetY * 2
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
#pragma once
|
||||
#include "maths.h"
|
||||
|
||||
#define BYTEn(x, n) (*((unsigned char*)&(x)+n))
|
||||
#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0)
|
||||
#define BYTE2(x) BYTEn(x, 2)
|
||||
|
||||
|
||||
struct resolution_info
|
||||
{
|
||||
|
@ -18,32 +12,18 @@ struct resolution_info
|
|||
class fullscrn
|
||||
{
|
||||
public:
|
||||
|
||||
static int screen_mode;
|
||||
static HWND hWnd;
|
||||
static tagRECT WindowRect1, WindowRect2;
|
||||
static rectangle_type WHRect;
|
||||
static int fullscrn_flag1;
|
||||
static int display_changed;
|
||||
static int ChangeDisplay, ignoreNextDisplayChangeFg;
|
||||
static int trick;
|
||||
static const resolution_info resolution_array[3];
|
||||
static float ScaleX;
|
||||
static float ScaleY;
|
||||
static float OffsetX;
|
||||
static float OffsetY;
|
||||
static int OffsetX;
|
||||
static int OffsetY;
|
||||
|
||||
static void init(int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay);
|
||||
static void init();
|
||||
static void shutdown();
|
||||
static int set_screen_mode(int isFullscreen);
|
||||
static void force_redraw();
|
||||
static void center_in(HWND parent, HWND child);
|
||||
static int displaychange();
|
||||
static void activate(int flag);
|
||||
static unsigned convert_mouse_pos(unsigned int mouseXY);
|
||||
static void getminmaxinfo(MINMAXINFO* maxMin);
|
||||
static void paint();
|
||||
static bool set_menu_mode(int menuEnabled);
|
||||
static int GetResolution();
|
||||
static void SetResolution(int resolution);
|
||||
static int GetMaxResolution();
|
||||
|
@ -52,15 +32,9 @@ public:
|
|||
static int get_screen_resolution();
|
||||
static void window_size_changed();
|
||||
private :
|
||||
static int MenuEnabled;
|
||||
static HMENU MenuHandle;
|
||||
static int resolution;
|
||||
static int maxResolution;
|
||||
|
||||
static void GetWindowCenter();
|
||||
static int disableWindowFlagsDisDlg();
|
||||
static int setWindowFlagsDisDlg();
|
||||
static int enableFullscreen();
|
||||
static int disableFullscreen();
|
||||
static void fillRect(int right, int bottom, int left, int top);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "pch.h"
|
||||
#include "gdrv.h"
|
||||
|
||||
#include "fullscrn.h"
|
||||
#include "memory.h"
|
||||
#include "render.h"
|
||||
#include "winmain.h"
|
||||
|
@ -9,6 +10,7 @@ SDL_Texture* gdrv::vScreenTex = nullptr;
|
|||
char* gdrv::vScreenPixels = nullptr;
|
||||
int gdrv::vScreenWidth, gdrv::vScreenHeight;
|
||||
ColorRgba gdrv::current_palette[256]{};
|
||||
SDL_Rect gdrv::DestinationRect{};
|
||||
|
||||
int gdrv::init(int width, int height)
|
||||
{
|
||||
|
@ -297,6 +299,6 @@ void gdrv::BlitScreen()
|
|||
&pitch
|
||||
);
|
||||
std::memcpy(lockedPixels, vScreenPixels, vScreenWidth * vScreenHeight * 4);
|
||||
SDL_UnlockTexture(vScreenTex);
|
||||
SDL_RenderCopyEx(winmain::Renderer, vScreenTex, nullptr, nullptr, 0, nullptr, SDL_FLIP_VERTICAL);
|
||||
SDL_UnlockTexture(vScreenTex);
|
||||
SDL_RenderCopyEx(winmain::Renderer, vScreenTex, nullptr, &DestinationRect, 0, nullptr, SDL_FLIP_VERTICAL);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ struct gdrv_bitmap8
|
|||
int Height;
|
||||
int Stride;
|
||||
BitmapType BitmapType;
|
||||
int Color6;
|
||||
int XPosition;
|
||||
int YPosition;
|
||||
};
|
||||
|
@ -49,6 +48,8 @@ struct LOGPALETTEx256 : LOGPALETTE
|
|||
class gdrv
|
||||
{
|
||||
public:
|
||||
static SDL_Rect DestinationRect;
|
||||
|
||||
static int init(int width, int height);
|
||||
static int uninit();
|
||||
static void get_focus();
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
int high_score::dlg_enter_name;
|
||||
int high_score::dlg_score;
|
||||
int high_score::dlg_position;
|
||||
LPCSTR high_score::default_name;
|
||||
char high_score::default_name[32]{};
|
||||
high_score_struct* high_score::dlg_hst;
|
||||
bool high_score::ShowDialog = false;
|
||||
|
||||
winhelp_entry high_score::help[21]
|
||||
{
|
||||
|
@ -167,7 +168,7 @@ void high_score::show_high_score_dialog(high_score_struct* table)
|
|||
dlg_enter_name = 0;
|
||||
dlg_score = 0;
|
||||
dlg_hst = table;
|
||||
DialogBoxParamA(nullptr, "dlg_highscores", nullptr, HighScore, 0);
|
||||
ShowDialog = true;
|
||||
}
|
||||
|
||||
void high_score::show_and_set_high_score_dialog(high_score_struct* table, int score, int pos, LPCSTR defaultName)
|
||||
|
@ -176,126 +177,99 @@ void high_score::show_and_set_high_score_dialog(high_score_struct* table, int sc
|
|||
dlg_score = score;
|
||||
dlg_hst = table;
|
||||
dlg_enter_name = 1;
|
||||
default_name = defaultName;
|
||||
/*while (DialogBoxParamA(winmain::hinst, "dlg_highscores", winmain::hwnd_frame, HighScore, 0))
|
||||
{
|
||||
}*/
|
||||
strncpy_s(default_name, defaultName, 32);
|
||||
ShowDialog = true;
|
||||
}
|
||||
|
||||
INT_PTR high_score::HighScore(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
void high_score::RenderHighScoreDialog()
|
||||
{
|
||||
HWND parent;
|
||||
int nIDDlgItem;
|
||||
CHAR String1[256];
|
||||
CHAR name[32];
|
||||
|
||||
switch (msg)
|
||||
if (ShowDialog == true)
|
||||
{
|
||||
case WM_CLOSE:
|
||||
SendMessageA(hWnd, WM_COMMAND, WM_DESTROY, 0);
|
||||
break;
|
||||
case WM_HELP:
|
||||
WinHelpA(static_cast<HWND>(reinterpret_cast<HELPINFO*>(lParam)->hItemHandle), "pinball.hlp", HELP_WM_HELP,
|
||||
(ULONG_PTR)help);
|
||||
break;
|
||||
case WM_CONTEXTMENU:
|
||||
WinHelpA((HWND)wParam, "pinball.hlp", HELP_CONTEXTMENU, (ULONG_PTR)help);
|
||||
break;
|
||||
case WM_INITDIALOG:
|
||||
show_high_scores(hWnd, dlg_hst);
|
||||
for (nIDDlgItem = DLG_HIGHSCORES_EditName1; nIDDlgItem < 611; ++nIDDlgItem)
|
||||
ShowDialog = false;
|
||||
if (dlg_position == -1)
|
||||
{
|
||||
ShowWindow(GetDlgItem(hWnd, nIDDlgItem), 0);
|
||||
dlg_enter_name = 0;
|
||||
return;
|
||||
}
|
||||
if (dlg_enter_name == 1)
|
||||
ImGui::OpenPopup("High Scores");
|
||||
}
|
||||
|
||||
bool unused_open = true;
|
||||
if (ImGui::BeginPopupModal("High Scores", &unused_open, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
if (ImGui::BeginTable("table1", 3, 0))
|
||||
{
|
||||
if (dlg_position == -1)
|
||||
char buf[36];
|
||||
ImGui::TableSetupColumn("Rank");
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Score");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
high_score_struct* tablePtr = dlg_hst;
|
||||
for (int row = 0; row < 5; row++)
|
||||
{
|
||||
dlg_enter_name = 0;
|
||||
return 1;
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
_itoa_s(row, buf, 10);
|
||||
ImGui::TextUnformatted(buf);
|
||||
|
||||
auto score = tablePtr->Score;
|
||||
ImGui::TableNextColumn();
|
||||
if (dlg_enter_name == 1 && dlg_position == row)
|
||||
{
|
||||
score = dlg_score;
|
||||
ImGui::PushItemWidth(200);
|
||||
ImGui::InputText("", default_name, IM_ARRAYSIZE(default_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TextUnformatted(tablePtr->Name);
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
score::string_format(score, buf);
|
||||
ImGui::TextUnformatted(buf);
|
||||
|
||||
tablePtr++;
|
||||
}
|
||||
HWND nameTextBox = GetDlgItem(hWnd, dlg_position + DLG_HIGHSCORES_EditName1);
|
||||
ShowWindow(nameTextBox, 5);
|
||||
EnableWindow(nameTextBox, 1);
|
||||
SetFocus(nameTextBox);
|
||||
if (default_name)
|
||||
{
|
||||
SetWindowTextA(nameTextBox, default_name);
|
||||
SendMessageA(nameTextBox, EM_SETSEL, 0, -1);
|
||||
}
|
||||
SendMessageA(nameTextBox, EM_SETLIMITTEXT, 31u, 0);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
else
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Ok"))
|
||||
{
|
||||
SetFocus(hWnd);
|
||||
}
|
||||
parent = GetParent(hWnd);
|
||||
if (parent)
|
||||
fullscrn::center_in(parent, hWnd);
|
||||
return 0;
|
||||
case WM_COMMAND:
|
||||
switch (wParam)
|
||||
{
|
||||
case DLG_HIGHSCORES_Ok:
|
||||
if (dlg_enter_name != 1)
|
||||
{
|
||||
break;
|
||||
if (dlg_enter_name)
|
||||
{
|
||||
default_name[31] = 0;
|
||||
place_new_score_into(dlg_hst, dlg_score, default_name, dlg_position);
|
||||
}
|
||||
GetDlgItemTextA(hWnd, dlg_position + DLG_HIGHSCORES_EditName1, name, 32);
|
||||
name[31] = 0;
|
||||
place_new_score_into(dlg_hst, dlg_score, name, dlg_position);
|
||||
break;
|
||||
case DLG_HIGHSCORES_Cancel:
|
||||
break;
|
||||
case DLG_HIGHSCORES_Clear:
|
||||
lstrcpyA(String1, pinball::get_rc_string(41, 0));
|
||||
if (MessageBoxA(hWnd, pinball::get_rc_string(40, 0), String1, MB_DEFBUTTON2 | MB_OKCANCEL) == 1)
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Clear"))
|
||||
ImGui::OpenPopup("Confirm");
|
||||
if (ImGui::BeginPopupModal("Confirm", nullptr, ImGuiWindowFlags_MenuBar))
|
||||
{
|
||||
ImGui::TextUnformatted(pinball::get_rc_string(40, 0));
|
||||
if (ImGui::Button("OK", ImVec2(120, 0)))
|
||||
{
|
||||
clear_table(dlg_hst);
|
||||
if (dlg_enter_name)
|
||||
EndDialog(hWnd, 1);
|
||||
else
|
||||
EndDialog(hWnd, 0);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0)))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
dlg_enter_name = 0;
|
||||
EndDialog(hWnd, 0);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void high_score::show_high_scores(HWND hDlg, high_score_struct* table)
|
||||
{
|
||||
high_score_struct* tablePtr = table;
|
||||
int nextPosition = 0;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
if (dlg_enter_name == 1 && dlg_position == i)
|
||||
{
|
||||
hsdlg_show_score(hDlg, " ", dlg_score, i);
|
||||
nextPosition = 1;
|
||||
}
|
||||
hsdlg_show_score(hDlg, tablePtr->Name, tablePtr->Score, i + nextPosition);
|
||||
++tablePtr;
|
||||
}
|
||||
}
|
||||
|
||||
void high_score::hsdlg_show_score(HWND hDlg, LPCSTR name, int score, int position)
|
||||
{
|
||||
CHAR scoreStr[36];
|
||||
if (position < 5)
|
||||
{
|
||||
score::string_format(score, scoreStr);
|
||||
if (scoreStr[0])
|
||||
{
|
||||
SetWindowTextA(GetDlgItem(hDlg, position + DLG_HIGHSCORES_StaticName1), name);
|
||||
SetWindowTextA(GetDlgItem(hDlg, position + DLG_HIGHSCORES_Score1), scoreStr);
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,13 @@ public:
|
|||
|
||||
static void show_high_score_dialog(high_score_struct* table);
|
||||
static void show_and_set_high_score_dialog(high_score_struct* table, int score, int pos, LPCSTR defaultName);
|
||||
static INT_PTR __stdcall HighScore(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static void show_high_scores(HWND hDlg, high_score_struct* table);
|
||||
static void hsdlg_show_score(HWND hDlg, LPCSTR name, int score, int position);
|
||||
static void RenderHighScoreDialog();
|
||||
private :
|
||||
static int dlg_enter_name;
|
||||
static int dlg_score;
|
||||
static int dlg_position;
|
||||
static LPCSTR default_name;
|
||||
static char default_name[32];
|
||||
static high_score_struct* dlg_hst;
|
||||
static winhelp_entry help[21];
|
||||
static bool ShowDialog;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||
//-----------------------------------------------------------------------------
|
||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
|
||||
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger window: ShowMetricsWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
|
||||
//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
|
||||
//---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
|
||||
// Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
|
||||
// #define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
|
||||
// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
|
||||
// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
|
||||
//#define IMGUI_ENABLE_FREETYPE
|
||||
|
||||
//---- Use stb_truetype to build and rasterize the font atlas (default)
|
||||
// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
|
||||
//#define IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
|
||||
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
|
||||
// This adds a small runtime cost which is why it is not enabled by default.
|
||||
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, const MyMatrix44& v);
|
||||
}
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,2904 @@
|
|||
// dear imgui, v1.85 WIP
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
// - Read FAQ at http://dearimgui.org/faq
|
||||
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||
// Read imgui.cpp for details, links and comments.
|
||||
|
||||
// Resources:
|
||||
// - FAQ http://dearimgui.org/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/4451 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
|
||||
// Getting Started?
|
||||
// - For first-time users having issues compiling/linking/running or issues loading fonts:
|
||||
// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above.
|
||||
|
||||
/*
|
||||
|
||||
Index of this file:
|
||||
// [SECTION] Header mess
|
||||
// [SECTION] Forward declarations and basic types
|
||||
// [SECTION] Dear ImGui end-user API functions
|
||||
// [SECTION] Flags & Enumerations
|
||||
// [SECTION] Helpers: Memory allocations macros, ImVector<>
|
||||
// [SECTION] ImGuiStyle
|
||||
// [SECTION] ImGuiIO
|
||||
// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs)
|
||||
// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor)
|
||||
// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData)
|
||||
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont)
|
||||
// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport)
|
||||
// [SECTION] Obsolete functions and types
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Configuration file with compile-time options (edit imconfig.h or '#define IMGUI_USER_CONFIG "myfilename.h" from your build system')
|
||||
#ifdef IMGUI_USER_CONFIG
|
||||
#include IMGUI_USER_CONFIG
|
||||
#endif
|
||||
#if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H)
|
||||
#include "imconfig.h"
|
||||
#endif
|
||||
|
||||
#ifndef IMGUI_DISABLE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Header mess
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Includes
|
||||
#include <float.h> // FLT_MIN, FLT_MAX
|
||||
#include <stdarg.h> // va_list, va_start, va_end
|
||||
#include <stddef.h> // ptrdiff_t, NULL
|
||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||
|
||||
// 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)
|
||||
#define IMGUI_VERSION "1.85 WIP"
|
||||
#define IMGUI_VERSION_NUM 18410
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
// Define attributes of all API symbols declarations (e.g. for DLL under Windows)
|
||||
// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h)
|
||||
// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API)
|
||||
#ifndef IMGUI_API
|
||||
#define IMGUI_API
|
||||
#endif
|
||||
#ifndef IMGUI_IMPL_API
|
||||
#define IMGUI_IMPL_API IMGUI_API
|
||||
#endif
|
||||
|
||||
// Helper Macros
|
||||
#ifndef IM_ASSERT
|
||||
#include <assert.h>
|
||||
#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h
|
||||
#endif
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers!
|
||||
#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds.
|
||||
#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100)
|
||||
#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11
|
||||
#else
|
||||
#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro.
|
||||
#endif
|
||||
|
||||
// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions.
|
||||
#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__)
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0)))
|
||||
#elif !defined(IMGUI_USE_STB_SPRINTF) && (defined(__clang__) || defined(__GNUC__))
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#else
|
||||
#define IM_FMTARGS(FMT)
|
||||
#define IM_FMTLIST(FMT)
|
||||
#endif
|
||||
|
||||
// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions)
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(IMGUI_DEBUG_PARANOID)
|
||||
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
|
||||
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))
|
||||
#else
|
||||
#define IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
#define IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
#endif
|
||||
|
||||
// Warnings
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6).
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#if __has_warning("-Wzero-as-null-pointer-constant")
|
||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Forward declarations and basic types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Forward declarations
|
||||
struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit()
|
||||
struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback)
|
||||
struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix.
|
||||
struct ImDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder)
|
||||
struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself)
|
||||
struct ImDrawListSplitter; // Helper to split a draw list into different layers which can be drawn into out of order, then flattened back.
|
||||
struct ImDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT)
|
||||
struct ImFont; // Runtime data for a single font within a parent ImFontAtlas
|
||||
struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader
|
||||
struct ImFontBuilderIO; // Opaque interface to a font builder (stb_truetype or FreeType).
|
||||
struct ImFontConfig; // Configuration data when adding a font or merging fonts
|
||||
struct ImFontGlyph; // A single font glyph (code point + coordinates within in ImFontAtlas + offset)
|
||||
struct ImFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data
|
||||
struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using)
|
||||
struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h)
|
||||
struct ImGuiIO; // Main configuration and I/O between your application and ImGui
|
||||
struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use)
|
||||
struct ImGuiListClipper; // Helper to manually clip large list of items
|
||||
struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro
|
||||
struct ImGuiPayload; // User data payload for drag and drop operations
|
||||
struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use)
|
||||
struct ImGuiStorage; // Helper for key->value storage
|
||||
struct ImGuiStyle; // Runtime data for styling/colors
|
||||
struct ImGuiTableSortSpecs; // Sorting specifications for a table (often handling sort specs for a single column, occasionally more)
|
||||
struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table
|
||||
struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder)
|
||||
struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]")
|
||||
struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor
|
||||
|
||||
// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags without overhead, and to not pollute the top of this file)
|
||||
// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists!
|
||||
// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
|
||||
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
|
||||
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
|
||||
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
|
||||
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
|
||||
typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction
|
||||
typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum)
|
||||
typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation
|
||||
typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle)
|
||||
typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier
|
||||
typedef int ImGuiSortDirection; // -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending)
|
||||
typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling
|
||||
typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor()
|
||||
typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions
|
||||
typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance
|
||||
typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build
|
||||
typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags
|
||||
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for InvisibleButton()
|
||||
typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc.
|
||||
typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags
|
||||
typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo()
|
||||
typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload()
|
||||
typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused()
|
||||
typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc.
|
||||
typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline()
|
||||
typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super)
|
||||
typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen()
|
||||
typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable()
|
||||
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc.
|
||||
typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar()
|
||||
typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem()
|
||||
typedef int ImGuiTableFlags; // -> enum ImGuiTableFlags_ // Flags: For BeginTable()
|
||||
typedef int ImGuiTableColumnFlags; // -> enum ImGuiTableColumnFlags_// Flags: For TableSetupColumn()
|
||||
typedef int ImGuiTableRowFlags; // -> enum ImGuiTableRowFlags_ // Flags: For TableNextRow()
|
||||
typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader()
|
||||
typedef int ImGuiViewportFlags; // -> enum ImGuiViewportFlags_ // Flags: for ImGuiViewport
|
||||
typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild()
|
||||
|
||||
// ImTexture: user data for renderer backend to identify a texture [Compile-time configurable type]
|
||||
// - To use something else than an opaque void* pointer: override with e.g. '#define ImTextureID MyTextureType*' in your imconfig.h file.
|
||||
// - This can be whatever to you want it to be! read the FAQ about ImTextureID for details.
|
||||
#ifndef ImTextureID
|
||||
typedef void* ImTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that)
|
||||
#endif
|
||||
|
||||
// ImDrawIdx: vertex index. [Compile-time configurable type]
|
||||
// - To use 16-bit indices + allow large meshes: backend need to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset (recommended).
|
||||
// - To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in your imconfig.h file.
|
||||
#ifndef ImDrawIdx
|
||||
typedef unsigned short ImDrawIdx; // Default: 16-bit (for maximum compatibility with renderer backends)
|
||||
#endif
|
||||
|
||||
// Scalar data types
|
||||
typedef unsigned int ImGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string)
|
||||
typedef signed char ImS8; // 8-bit signed integer
|
||||
typedef unsigned char ImU8; // 8-bit unsigned integer
|
||||
typedef signed short ImS16; // 16-bit signed integer
|
||||
typedef unsigned short ImU16; // 16-bit unsigned integer
|
||||
typedef signed int ImS32; // 32-bit signed integer == int
|
||||
typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors)
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio)
|
||||
typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio)
|
||||
#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)
|
||||
#include <stdint.h>
|
||||
typedef int64_t ImS64; // 64-bit signed integer (pre C++11)
|
||||
typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11)
|
||||
#else
|
||||
typedef signed long long ImS64; // 64-bit signed integer (post C++11)
|
||||
typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11)
|
||||
#endif
|
||||
|
||||
// Character types
|
||||
// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display)
|
||||
typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
||||
typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings.
|
||||
#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16]
|
||||
typedef ImWchar32 ImWchar;
|
||||
#else
|
||||
typedef ImWchar16 ImWchar;
|
||||
#endif
|
||||
|
||||
// Callback and functions types
|
||||
typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText()
|
||||
typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints()
|
||||
typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions()
|
||||
|
||||
// ImVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type]
|
||||
// This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type.
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
struct ImVec2
|
||||
{
|
||||
float x, y;
|
||||
ImVec2() { x = y = 0.0f; }
|
||||
ImVec2(float _x, float _y) { x = _x; y = _y; }
|
||||
float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
#ifdef IM_VEC2_CLASS_EXTRA
|
||||
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
|
||||
#endif
|
||||
};
|
||||
|
||||
// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
|
||||
struct ImVec4
|
||||
{
|
||||
float x, y, z, w;
|
||||
ImVec4() { x = y = z = w = 0.0f; }
|
||||
ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
|
||||
#ifdef IM_VEC4_CLASS_EXTRA
|
||||
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
||||
#endif
|
||||
};
|
||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Dear ImGui end-user API functions
|
||||
// (Note that ImGui:: being a namespace, you can add extra ImGui:: functions in your own separate file. Please don't modify imgui source files!)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
// Context creation and access
|
||||
// - Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between contexts.
|
||||
// - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
|
||||
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for details.
|
||||
IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL);
|
||||
IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context
|
||||
IMGUI_API ImGuiContext* GetCurrentContext();
|
||||
IMGUI_API void SetCurrentContext(ImGuiContext* ctx);
|
||||
|
||||
// Main
|
||||
IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
|
||||
IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
|
||||
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
|
||||
IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
|
||||
IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData().
|
||||
IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render.
|
||||
|
||||
// Demo, Debug, Information
|
||||
IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
|
||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
|
||||
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||
IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
|
||||
IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
|
||||
IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
|
||||
IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp)
|
||||
|
||||
// Styles
|
||||
IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default)
|
||||
IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); // best used with borders and a custom, thicker font
|
||||
IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); // classic imgui style
|
||||
|
||||
// Windows
|
||||
// - Begin() = push window to the stack and start appending to it. End() = pop window from the stack.
|
||||
// - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window,
|
||||
// which clicking will set the boolean to false when clicked.
|
||||
// - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times.
|
||||
// Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin().
|
||||
// - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting
|
||||
// anything to the window. Always call a matching End() for each Begin() call, regardless of its return value!
|
||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void End();
|
||||
|
||||
// Child Windows
|
||||
// - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child.
|
||||
// - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400).
|
||||
// - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window.
|
||||
// Always call a matching EndChild() for each BeginChild() call, regardless of its return value.
|
||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void EndChild();
|
||||
|
||||
// Windows Utilities
|
||||
// - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into.
|
||||
IMGUI_API bool IsWindowAppearing();
|
||||
IMGUI_API bool IsWindowCollapsed();
|
||||
IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options.
|
||||
IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ!
|
||||
IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives
|
||||
IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
|
||||
IMGUI_API ImVec2 GetWindowSize(); // get current window size
|
||||
IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x)
|
||||
IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y)
|
||||
|
||||
// Window manipulation
|
||||
// - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin).
|
||||
IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc.
|
||||
IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin()
|
||||
IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints.
|
||||
IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin()
|
||||
IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin()
|
||||
IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin()
|
||||
IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground.
|
||||
IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects.
|
||||
IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects.
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
||||
IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
|
||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus.
|
||||
|
||||
// Content region
|
||||
// - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful.
|
||||
// - Those functions are bound to be redesigned (they are confusing, incomplete and the Min/Max return values are in local window coordinates which increases confusion)
|
||||
IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos()
|
||||
IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min for the full window (roughly (0,0)-Scroll), in window coordinates
|
||||
IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates
|
||||
|
||||
// Windows Scrolling
|
||||
IMGUI_API float GetScrollX(); // get scrolling amount [0 .. GetScrollMaxX()]
|
||||
IMGUI_API float GetScrollY(); // get scrolling amount [0 .. GetScrollMaxY()]
|
||||
IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0 .. GetScrollMaxX()]
|
||||
IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0 .. GetScrollMaxY()]
|
||||
IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.x - WindowSize.x - DecorationsSize.x
|
||||
IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.y - WindowSize.y - DecorationsSize.y
|
||||
IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
|
||||
IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead.
|
||||
IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
|
||||
IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position.
|
||||
|
||||
// Parameters stacks (shared)
|
||||
IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font
|
||||
IMGUI_API void PopFont();
|
||||
IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame().
|
||||
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
|
||||
IMGUI_API void PopStyleColor(int count = 1);
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame().
|
||||
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); // modify a style ImVec2 variable. always use this if you modify the style after NewFrame().
|
||||
IMGUI_API void PopStyleVar(int count = 1);
|
||||
IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // == tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets
|
||||
IMGUI_API void PopAllowKeyboardFocus();
|
||||
IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame.
|
||||
IMGUI_API void PopButtonRepeat();
|
||||
|
||||
// Parameters stacks (current window)
|
||||
IMGUI_API void PushItemWidth(float item_width); // push width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side).
|
||||
IMGUI_API void PopItemWidth();
|
||||
IMGUI_API void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side)
|
||||
IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions.
|
||||
IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // push word-wrapping position for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space
|
||||
IMGUI_API void PopTextWrapPos();
|
||||
|
||||
// Style read access
|
||||
// - Use the style editor (ShowStyleEditor() function) to interactively see what the colors are)
|
||||
IMGUI_API ImFont* GetFont(); // get current font
|
||||
IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied
|
||||
IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API
|
||||
IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList
|
||||
IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
||||
IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList
|
||||
IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in.
|
||||
|
||||
// Cursor / Layout
|
||||
// - By "cursor" we mean the current output position.
|
||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget.
|
||||
// - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
|
||||