Skip to content

Instantly share code, notes, and snippets.

@vurtun
vurtun / sort.c
Last active January 11, 2023 15:22
// ref: http://www.codercorner.com/RadixSortRevisited.htm
// http://stereopsis.com/radix.html
// int/float: https://github.com/lshamis/FloatRadixSort
// string: https://github.com/rantala/string-sorting/blob/master/src/msd_ce.cpp
struct str {
const char *str;
const char *end;
int len;
};
@Flix01
Flix01 / imgui_virtual_keyboard.cpp
Last active September 15, 2024 08:02
Complete keyboard prototype for Dear ImGui version 1.87.
/* This code is an extension of the 'keyboard section' present in 'imgui_demo.cpp'.
License is the same (MIT License AFAIK)
*/
#include <imgui_virtual_keyboard.h>
namespace ImGui {
// VirtualKeyboard Implementation
const char** GetKeyboardLogicalLayoutNames() {
@nem0
nem0 / imgui_treeview_clipper.cpp
Last active January 9, 2022 14:44
Simple treeview clipper for imgui
// only handles coplexity on top level, if you have a node with 1M children, you are out of luck
// changes in clipped parts are not detected, so if somebody deleted nodes in clipped, scrollbar is not updated until user actually scrolls
// scrolling and changes refresh the clipper == that part is as slow as no clipping at all
// only single list in BeginChild/EndChild is tested
struct TreeViewClipper {
// persist
float cursor_end = 0;
float cursor_visible_start = 0;
uint first_visible_index = 0;
float last_scroll = 0;
// CC0
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#define isdigit(c) (c >= '0' && c <= '9')
namespace ImGui
{
float strToFloat (const char *s) // atof from minilibc
@rokups
rokups / CMakeLists.txt
Last active September 25, 2024 12:35
Dear ImGui CMake build script.
#
# CMake build system for Dear ImGui
# =================================
#
# Build instructions:
# 1. Install latest CMake
# * Windows: https://cmake.org/download/ (Tick checkbox to place cmake in system PATH)
# * Linux: from your favorite package manager
# * MacOS: brew install cmake
# 2. Open command prompt in directory containing "imgui" and "imgui_dev" folders
#pragma once
// String tokenizing iterator
// by Nathan Reed, 2020-08-06. Licensed CC0 https://creativecommons.org/publicdomain/zero/1.0/
//
// Use it like:
//
// for (auto token : IterTokens(" Bird \t\tFish Dog Cat "))
// {
// // token is a std::string_view pointing into the original string
#include <iostream>
#include <assert.h>
#include <vector>
template<class T>
struct Func{};
// std::func replacement without dynamic memory allocation (captures are limited to 48 bytes)
// this could be extended to support captures >48 bytes... of course, with a bit more of logic
// and some state.
namespace ImGui
{
ImVec2 const AlignedCenter(0.5f, 0.5f);
ImVec2 const AlignedLeft(0.0f, 0.5f);
ImVec2 const AlignedTop(0.5f, 0.0f);
ImVec2 const AlignedRight(1.0f, 0.5f);
ImVec2 const AlignedBottom(0.5f, 1.0f);
ImVec2 const AlignedTopLeft(0.0f, 0.0f);
# The MIT License (MIT)
#
# Copyright (c) 2014-2020 Omar Cornut
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@kudaba
kudaba / iminputvalue.cpp
Last active April 9, 2020 06:40
Improved number editing control for ImGui
// WARNING: Revision 5+ Requires unreleased code from imgui, stick to 3 or 2 for now (don't look at revision 4)
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>
#include "iminputvalue.h"
namespace ImGui
{
//-------------------------------------------------------------------------------------------------