forked from jvcleave/ofxImGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added RangeSlider and other widgets from here:
ocornut/imgui#76 Taken from: wasikuss/imgui@a50515a needed SliderBehaviorCalcRatioFromValue() added to imgui.cpp to compile added timeline and curveeditor widgets from imgui_user files from here: https://github.com/nem0/LumixEngine/tree/master/external/imgui
- Loading branch information
Glenn Silver
committed
Mar 5, 2017
1 parent
b0d3806
commit 98222cc
Showing
18 changed files
with
5,055 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//----------------------------------------------------------------------------- | ||
// USER IMPLEMENTATION | ||
// This file contains compile-time options for ImGui. | ||
// Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO(). | ||
//----------------------------------------------------------------------------- | ||
|
||
#pragma once | ||
|
||
//---- Define assertion handler. Defaults to calling assert(). | ||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR) | ||
|
||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows. | ||
//#define IMGUI_API __declspec( dllexport ) | ||
//#define IMGUI_API __declspec( dllimport ) | ||
|
||
//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions. | ||
#define IMGUI_INCLUDE_IMGUI_USER_INL | ||
|
||
//---- Include imgui_user.h at the end of imgui.h | ||
#define IMGUI_INCLUDE_IMGUI_USER_H | ||
|
||
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions) | ||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS | ||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS | ||
|
||
//---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty) | ||
//#define IMGUI_DISABLE_TEST_WINDOWS | ||
|
||
//---- Don't define obsolete functions names | ||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS | ||
|
||
//---- Implement STB libraries in a namespace to avoid conflicts | ||
//#define IMGUI_STB_NAMESPACE ImGuiStb | ||
|
||
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4. | ||
|
||
#include "ofVectorMath.h" | ||
#include "ofColor.h" | ||
|
||
#if OF_VERSION_MINOR >= 10 | ||
#define IM_VEC2_CLASS_EXTRA \ | ||
ImVec2(const ofVec2f& f) { x = f.x; y = f.y; } \ | ||
operator ofVec2f() const { return ofVec2f(x, y); } \ | ||
ImVec2(const glm::vec2& f) { x = f.x; y = f.y; } \ | ||
operator glm::vec2() const { return glm::vec2(x, y); } | ||
#else | ||
#define IM_VEC2_CLASS_EXTRA \ | ||
ImVec2(const ofVec2f& f) { x = f.x; y = f.y; } \ | ||
operator ofVec2f() const { return ofVec2f(x, y); } | ||
#endif | ||
|
||
#if OF_VERSION_MINOR >= 10 | ||
#define IM_VEC4_CLASS_EXTRA \ | ||
ImVec4(const ofVec4f& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ | ||
operator ofVec4f() const { return ofVec4f(x,y,z,w); } \ | ||
ImVec4(const glm::vec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ | ||
operator glm::vec4() const { return glm::vec4(x,y,z,w); } \ | ||
ImVec4(ofColor& color, float alpha) { static const float sc = 1.0f/255.0f; x = color.r*sc; y = color.g*sc; z = color.b*sc; w = alpha; } \ | ||
ImVec4(const ofColor& f) { static const float sc = 1.0f/255.0f; x = f.r*sc; y = f.g*sc; z = f.b*sc; w = f.a*sc; } \ | ||
operator ofColor() const { return ofColor((int) (x*255.0f+0.5f), (int) (y*255.0f+0.5f), (int) (z*255.0f+0.5f), (int) (w*255.0f+0.5f)); } \ | ||
ImVec4(ofFloatColor& color, float alpha) { x = color.r; y = color.g; z = color.b; w = alpha; } \ | ||
ImVec4(const ofFloatColor& f) { x = f.r; y = f.g; z = f.b; w = f.a; } \ | ||
operator ofFloatColor() const { return ofFloatColor(x, y, z, w); } | ||
#else | ||
#define IM_VEC4_CLASS_EXTRA \ | ||
ImVec4(const ofVec4f& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ | ||
operator ofVec4f() const { return ofVec4f(x,y,z,w); } \ | ||
ImVec4(ofColor& color, float alpha) { static const float sc = 1.0f/255.0f; x = color.r*sc; y = color.g*sc; z = color.b*sc; w = alpha; } \ | ||
ImVec4(const ofColor& f) { static const float sc = 1.0f/255.0f; x = f.r*sc; y = f.g*sc; z = f.b*sc; w = f.a*sc; } \ | ||
operator ofColor() const { return ofColor((int) (x*255.0f+0.5f), (int) (y*255.0f+0.5f), (int) (z*255.0f+0.5f), (int) (w*255.0f+0.5f)); } \ | ||
ImVec4(ofFloatColor& color, float alpha) { x = color.r; y = color.g; z = color.b; w = alpha; } \ | ||
ImVec4(const ofFloatColor& f) { x = f.r; y = f.g; z = f.b; w = f.a; } \ | ||
operator ofFloatColor() const { return ofFloatColor(x, y, z, w); } | ||
#endif | ||
|
||
#define ImDrawIdx ofIndexType | ||
|
||
//---- Freely implement extra functions within the ImGui:: namespace. | ||
//---- Declare helpers or widgets implemented in imgui_user.inl or elsewhere, so end-user doesn't need to include multiple files. | ||
//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers. | ||
/* | ||
namespace ImGui | ||
{ | ||
void Value(const char* prefix, const MyVec2& v, const char* float_format = NULL); | ||
void Value(const char* prefix, const MyVec4& v, const char* float_format = NULL); | ||
} | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <stdint.h> | ||
#include <inttypes.h> | ||
|
||
namespace ImGui | ||
{ | ||
struct Font | ||
{ | ||
enum Enum | ||
{ | ||
Regular, | ||
Mono, | ||
|
||
Count | ||
}; | ||
}; | ||
|
||
void PushFont(Font::Enum _font); | ||
|
||
// BK - simple string class for convenience. | ||
class ImString | ||
{ | ||
public: | ||
ImString(); | ||
ImString(const ImString& rhs); | ||
ImString(const char* rhs); | ||
~ImString(); | ||
|
||
ImString& operator=(const ImString& rhs); | ||
ImString& operator=(const char* rhs); | ||
|
||
void Clear(); | ||
bool IsEmpty() const; | ||
|
||
const char* CStr() const | ||
{ | ||
return NULL == Ptr ? "" : Ptr; | ||
} | ||
|
||
private: | ||
char* Ptr; | ||
}; | ||
|
||
} // namespace ImGui | ||
|
||
#include "widgets/color_picker.h" | ||
#include "widgets/dock.h" | ||
#include "widgets/file_list.h" | ||
#include "widgets/gizmo.h" | ||
#include "widgets/memory_editor.h" | ||
#include "widgets/range_slider.h" | ||
#include "widgets/timeline.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
namespace ImGui | ||
{ | ||
ImString::ImString() | ||
: Ptr(NULL) | ||
{ | ||
} | ||
|
||
ImString::ImString(const ImString& rhs) | ||
: Ptr(NULL) | ||
{ | ||
if (NULL != rhs.Ptr | ||
&& 0 != strcmp(rhs.Ptr, "")) | ||
{ | ||
Ptr = ImStrdup(rhs.Ptr); | ||
} | ||
} | ||
|
||
ImString::ImString(const char* rhs) | ||
: Ptr(NULL) | ||
{ | ||
if (NULL != rhs | ||
&& 0 != strcmp(rhs, "")) | ||
{ | ||
Ptr = ImStrdup(rhs); | ||
} | ||
} | ||
|
||
ImString::~ImString() | ||
{ | ||
Clear(); | ||
} | ||
|
||
ImString& ImString::operator=(const ImString& rhs) | ||
{ | ||
if (this != &rhs) | ||
{ | ||
*this = rhs.Ptr; | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
ImString& ImString::operator=(const char* rhs) | ||
{ | ||
if (Ptr != rhs) | ||
{ | ||
Clear(); | ||
|
||
if (NULL != rhs | ||
&& 0 != strcmp(rhs, "")) | ||
{ | ||
Ptr = ImStrdup(rhs); | ||
} | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
void ImString::Clear() | ||
{ | ||
if (NULL != Ptr) | ||
{ | ||
MemFree(Ptr); | ||
Ptr = NULL; | ||
} | ||
} | ||
|
||
bool ImString::IsEmpty() const | ||
{ | ||
return NULL == Ptr; | ||
} | ||
} // namespace | ||
|
||
#include "widgets/color_picker.inl" | ||
#include "widgets/dock.inl" | ||
#include "widgets/file_list.inl" | ||
#include "widgets/gizmo.inl" | ||
#include "widgets/memory_editor.inl" | ||
#include "widgets/range_slider.inl" | ||
#include "widgets/timeline.inl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace ImGui | ||
{ | ||
bool ColorPicker4(float* col, bool show_alpha); | ||
bool ColorPicker3(float col[3]); | ||
|
||
inline bool ColorEdit4(const char* label, uint32_t* _rgba, bool show_alpha = true) | ||
{ | ||
uint8_t* rgba = (uint8_t*)_rgba; | ||
float col[4] = | ||
{ | ||
rgba[0]/255.0f, | ||
rgba[1]/255.0f, | ||
rgba[2]/255.0f, | ||
rgba[3]/255.0f, | ||
}; | ||
bool result = ColorEdit4(label, col, show_alpha); | ||
rgba[0] = uint8_t(col[0]*255.0f); | ||
rgba[1] = uint8_t(col[1]*255.0f); | ||
rgba[2] = uint8_t(col[2]*255.0f); | ||
rgba[3] = uint8_t(col[3]*255.0f); | ||
return result; | ||
} | ||
|
||
} // namespace ImGui |
Oops, something went wrong.