Apply Pioneer's local patches.
parent
b5585bef4a
commit
b8c213ba40
|
@ -119,6 +119,62 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
|
|||
return false;
|
||||
}
|
||||
|
||||
// The Pioneer cursor.
|
||||
static const char mouse_cursor[] = {
|
||||
"XXXXXXXXXX "
|
||||
"X.........X "
|
||||
"X..........X "
|
||||
"X...........X "
|
||||
"X............X "
|
||||
"X.............X "
|
||||
"X..............X "
|
||||
"X...............X "
|
||||
"X................X "
|
||||
"X.................X "
|
||||
" X.................X "
|
||||
" X.......... ...X "
|
||||
" X........ ...X "
|
||||
" X...... ...X "
|
||||
" X..... ....X"
|
||||
" X.... ...X "
|
||||
" X... ..X "
|
||||
" X... ..X "
|
||||
" X... ..X "
|
||||
" X.......X "
|
||||
" X.....X "
|
||||
" X...X "
|
||||
" X.X "
|
||||
" X "
|
||||
};
|
||||
|
||||
// Shamelessly adapted from the SDL wiki, who stole it from the mailing list.
|
||||
// Create the pioneer cursor in SDL's preferred format.
|
||||
static SDL_Cursor* CreatePioneerCursor()
|
||||
{
|
||||
int i = -1;
|
||||
// Cursor data is stored as bitfields in most-significant-bit first order.
|
||||
Uint8 data[3*24];
|
||||
Uint8 mask[3*24];
|
||||
for (int row = 0; row < 24; ++row) {
|
||||
for (int col = 0; col < 24; ++col) {
|
||||
if (col % 8) {
|
||||
data[i] <<= 1;
|
||||
mask[i] <<= 1;
|
||||
} else {
|
||||
i++;
|
||||
data[i] = mask[i] = 0; // clear the next byte.
|
||||
}
|
||||
switch (mouse_cursor[row*24 + col]) {
|
||||
// Use fallthrough here because it makes sense.
|
||||
case 'X': data[i] |= 0x01;
|
||||
case '.': mask[i] |= 0x01;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SDL_CreateCursor(data, mask, 24, 24, 0, 0);
|
||||
}
|
||||
|
||||
static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
||||
{
|
||||
g_Window = window;
|
||||
|
@ -157,7 +213,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||
io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
|
||||
io.ClipboardUserData = NULL;
|
||||
|
||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
|
||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = CreatePioneerCursor();
|
||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS);
|
||||
|
@ -186,17 +242,9 @@ bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context)
|
|||
|
||||
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
|
||||
{
|
||||
#if !SDL_HAS_VULKAN
|
||||
#if !SDL_HAS_VULKAN
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window)
|
||||
{
|
||||
#if !defined(_WIN32)
|
||||
IM_ASSERT(0 && "Unsupported");
|
||||
#endif
|
||||
#endif
|
||||
return ImGui_ImplSDL2_Init(window);
|
||||
}
|
||||
|
||||
|
@ -232,7 +280,11 @@ static void ImGui_ImplSDL2_UpdateMousePosAndButtons()
|
|||
io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0;
|
||||
g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false;
|
||||
|
||||
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
||||
// Using this code-path causes several issues in Pioneer - when capturing the
|
||||
// mouse, the mouse snaps back to the center of the window, and there are some
|
||||
// issues with the WM's decoration extents being calculated into the window's
|
||||
// size on the Cinammon DE.
|
||||
#if 0 //SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)
|
||||
SDL_Window* focused_window = SDL_GetKeyboardFocus();
|
||||
if (g_Window == focused_window)
|
||||
{
|
||||
|
|
|
@ -2207,11 +2207,12 @@ struct ImFont
|
|||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||
bool DirtyLookupTables; // 1 // out //
|
||||
mutable ImVector<ImWchar> MissingGlyphs;
|
||||
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
IMGUI_API ~ImFont();
|
||||
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const;
|
||||
IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c, bool report_missing = false) const;
|
||||
IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const;
|
||||
float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; }
|
||||
bool IsLoaded() const { return ContainerAtlas != NULL; }
|
||||
|
|
|
@ -2614,13 +2614,21 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
|
|||
IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
|
||||
}
|
||||
|
||||
const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
|
||||
const ImFontGlyph* ImFont::FindGlyph(ImWchar c, bool report_missing) const
|
||||
{
|
||||
if (c >= IndexLookup.Size)
|
||||
if (c >= IndexLookup.Size) {
|
||||
if (report_missing)
|
||||
if (!MissingGlyphs.contains(c))
|
||||
MissingGlyphs.push_back(c);
|
||||
return FallbackGlyph;
|
||||
}
|
||||
const ImWchar i = IndexLookup.Data[c];
|
||||
if (i == (ImWchar)-1)
|
||||
return FallbackGlyph;
|
||||
if (i == (ImWchar)-1) {
|
||||
if (report_missing)
|
||||
if (!MissingGlyphs.contains(c))
|
||||
MissingGlyphs.push_back(c);
|
||||
return FallbackGlyph;
|
||||
}
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
|
@ -2831,7 +2839,7 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||
{
|
||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
|
||||
return;
|
||||
if (const ImFontGlyph* glyph = FindGlyph(c))
|
||||
if (const ImFontGlyph* glyph = FindGlyph(c, true))
|
||||
{
|
||||
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
|
||||
pos.x = IM_FLOOR(pos.x + DisplayOffset.x);
|
||||
|
@ -2952,7 +2960,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
|||
}
|
||||
|
||||
float char_width = 0.0f;
|
||||
if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c))
|
||||
if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c, true))
|
||||
{
|
||||
char_width = glyph->AdvanceX * scale;
|
||||
|
||||
|
|
Loading…
Reference in New Issue