Skip to content

Commit

Permalink
Merge pull request #373 from gucio321/cimcte-upgrade-2
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
gucio321 authored Nov 4, 2024
2 parents 5ad6857 + c1205dc commit 5e3e630
Show file tree
Hide file tree
Showing 35 changed files with 183 additions and 121 deletions.
13 changes: 2 additions & 11 deletions ImGuiColorTextEdit/cimcte_funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ImGuiColorTextEdit/cimcte_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "cimcte_wrapper.h"
#include "../cwrappers/cimCTE.h"

void wrap_TextEditor_ImGuiDebugPanel(TextEditor* self) { TextEditor_ImGuiDebugPanel(self,"Debug"); }
void wrap_TextEditor_Redo(TextEditor* self) { TextEditor_Redo(self,1); }
bool wrap_TextEditor_Render(TextEditor* self,const char* aTitle) { return TextEditor_Render(self,aTitle,false,ImVec2(),false); }
void wrap_TextEditor_SelectAllOccurrencesOf(TextEditor* self,const char* aText,int aTextSize) { TextEditor_SelectAllOccurrencesOf(self,aText,aTextSize,true); }
Expand Down
1 change: 0 additions & 1 deletion ImGuiColorTextEdit/cimcte_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
extern "C" {
#endif

extern void wrap_TextEditor_ImGuiDebugPanel(TextEditor* self);
extern void wrap_TextEditor_Redo(TextEditor* self);
extern bool wrap_TextEditor_Render(TextEditor* self,const char* aTitle);
extern void wrap_TextEditor_SelectAllOccurrencesOf(TextEditor* self,const char* aText,int aTextSize);
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ update: setup
$(call cimmarkdown)
$(call update,cimguizmo,https://github.com/cimgui/cimguizmo,ImGuizmo,master)
$(call cimguizmo)
$(call update,cimCTE,https://github.com/cimgui/cimcte,ImGuiColorTextEdit,master_santa)
$(call update,cimCTE,https://github.com/cimgui/cimcte,ImGuiColorTextEdit,master)
$(call cimcte)
$(call dummy)

Expand Down
8 changes: 3 additions & 5 deletions cmd/codegen/arguments_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ func getArgWrapper(
context *Context,
) (argDeclaration string, data ArgumentWrapperData, err error) {
argWrapperMap := map[CIdentifier]argumentWrapper{
"char": simpleW("rune", "C.char"),
"char*": constCharW,
"const char*": constCharW,
// used by code editor
"const std::string": constCharW,
"char": simpleW("rune", "C.char"),
"char*": constCharW,
"const char*": constCharW,
"const char**": charPtrPtrW,
"const char* const[]": charPtrPtrW,
"unsigned char": simpleW("uint", "C.uchar"),
Expand Down
14 changes: 13 additions & 1 deletion cmd/codegen/gencpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import (
"unicode"
)

// cppFunctionsReplace allows to force-replace function name with some other name.
// Introduced to replace TextEditor_GetText -> TextEditor_GetText_alloc
// but could be re-used to force use of another function than json tells us to use.
var cppFunctionsReplace = map[CIdentifier]CIdentifier{
"TextEditor_GetText": "TextEditor_GetText_alloc",
}

// Name of argument in cpp/go files.
// It is used by functions that has text and text_end arguments.
// In this case text_end is replaced by this argument (of type int)
Expand Down Expand Up @@ -108,7 +115,7 @@ extern "C" {
// could be generated in Go code.
// So, could be skip cimgui_wrapper.ccp/.h entirely?

cWrapperFuncName := "wrap_" + funcName
cWrapperFuncName := "wrap_" + f.FuncName

// Remove all ... arg
f.Args = strings.Replace(f.Args, ",...", "", 1)
Expand Down Expand Up @@ -389,6 +396,11 @@ extern "C" {
cppSb.WriteString(fmt.Sprintf("%s %s%s { return %s%s; }\n", f.Ret, cWrapperFuncName, f.Args, invokeFunctionName, actualCallArgsStr))
}
}

if v, ok := cppFunctionsReplace[funcName]; ok {
cWrapperFuncName = v
}

appendValidFunc()
}

Expand Down
19 changes: 8 additions & 11 deletions cmd/codegen/return_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ func getReturnWrapper(
context *Context,
) (returnWrapper, error) {
returnWrapperMap := map[CIdentifier]returnWrapper{
"bool": {"bool", "%s == C.bool(true)", "C.bool"},
"bool*": simplePtrR("bool", "C.bool"),
"const bool*": simplePtrR("bool", "c.bool"),
"char": simpleR("rune", "C.char"),
"unsigned char": simpleR("uint", "C.char"),
"unsigned char*": {"*uint", "(*uint)(unsafe.Pointer(%s))", "C.uchar"}, // NOTE: This should work but I'm not 100% sure
"char*": {"string", "C.GoString(%s)", "*C.char"},
"const char*": {"string", "C.GoString(%s)", "*C.char"},
// this is randomly used by cimCTE. It is const char* in c code but string in json for some reason
// probably should fix in cimCTE
"string": {"string", "C.GoString(%s)", "*C.char"},
"bool": {"bool", "%s == C.bool(true)", "C.bool"},
"bool*": simplePtrR("bool", "C.bool"),
"const bool*": simplePtrR("bool", "c.bool"),
"char": simpleR("rune", "C.char"),
"unsigned char": simpleR("uint", "C.char"),
"unsigned char*": {"*uint", "(*uint)(unsafe.Pointer(%s))", "C.uchar"}, // NOTE: This should work but I'm not 100% sure
"char*": {"string", "C.GoString(%s)", "*C.char"},
"const char*": {"string", "C.GoString(%s)", "*C.char"},
"const ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar*": simpleR("(*Wchar)", "*C.ImWchar"),
"ImWchar": simpleR("Wchar", "C.ImWchar"),
Expand Down
34 changes: 24 additions & 10 deletions cwrappers/ImGuizmo/ImGuizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,8 @@ namespace IMGUIZMO_NAMESPACE

struct Context
{
Context() : mbUsing(false), mbUsingViewManipulate(false), mbEnable(true), mbUsingBounds(false)
Context() : mbUsing(false), mbUsingViewManipulate(false), mbEnable(true), mIsViewManipulatorHovered(false), mbUsingBounds(false)
{
mIDStack.push_back(-1);
}

ImDrawList* mDrawList;
Expand Down Expand Up @@ -707,6 +706,7 @@ namespace IMGUIZMO_NAMESPACE
bool mbEnable;
bool mbMouseOver;
bool mReversed; // reversed projection matrix
bool mIsViewManipulatorHovered;

// translation
vec_t mTranslationPlan;
Expand Down Expand Up @@ -768,7 +768,14 @@ namespace IMGUIZMO_NAMESPACE
bool mAllowAxisFlip = true;
float mGizmoSizeClipSpace = 0.1f;

inline ImGuiID GetCurrentID() {return mIDStack.back();}
inline ImGuiID GetCurrentID()
{
if (mIDStack.empty())
{
mIDStack.push_back(-1);
}
return mIDStack.back();
}
};

static Context gContext;
Expand Down Expand Up @@ -1007,6 +1014,11 @@ namespace IMGUIZMO_NAMESPACE
return gContext.mbUsingViewManipulate;
}

bool IsViewManipulateHovered()
{
return gContext.mIsViewManipulatorHovered;
}

bool IsUsingAny()
{
return gContext.mbUsing || gContext.mbUsingBounds;
Expand Down Expand Up @@ -1094,7 +1106,6 @@ namespace IMGUIZMO_NAMESPACE
// compute scale from the size of camera right vector projected on screen at the matrix position
vec_t pointRight = viewInverse.v.right;
pointRight.TransformPoint(gContext.mViewProjection);
gContext.mScreenFactor = gContext.mGizmoSizeClipSpace / (pointRight.x / pointRight.w - gContext.mMVP.v.position.x / gContext.mMVP.v.position.w);

vec_t rightViewInverse = viewInverse.v.right;
rightViewInverse.TransformVector(gContext.mModelInverse);
Expand Down Expand Up @@ -2543,12 +2554,16 @@ namespace IMGUIZMO_NAMESPACE

void SetID(int id)
{
if (gContext.mIDStack.empty())
{
gContext.mIDStack.push_back(-1);
}
gContext.mIDStack.back() = id;
}

ImGuiID GetID(const char* str, const char* str_end)
{
ImGuiID seed = gContext.mIDStack.back();
ImGuiID seed = gContext.GetCurrentID();
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
return id;
}
Expand All @@ -2560,14 +2575,14 @@ namespace IMGUIZMO_NAMESPACE

ImGuiID GetID(const void* ptr)
{
ImGuiID seed = gContext.mIDStack.back();
ImGuiID seed = gContext.GetCurrentID();
ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
return id;
}

ImGuiID GetID(int n)
{
ImGuiID seed = gContext.mIDStack.back();
ImGuiID seed = gContext.GetCurrentID();
ImGuiID id = ImHashData(&n, sizeof(n), seed);
return id;
}
Expand Down Expand Up @@ -2907,7 +2922,6 @@ namespace IMGUIZMO_NAMESPACE
{
static bool isDraging = false;
static bool isClicking = false;
static bool isInside = false;
static vec_t interpolationUp;
static vec_t interpolationDir;
static int interpolationFrames = 0;
Expand Down Expand Up @@ -3020,7 +3034,7 @@ namespace IMGUIZMO_NAMESPACE
if (iPass)
{
ImU32 directionColor = GetColorU32(DIRECTION_X + normalIndex);
gContext.mDrawList->AddConvexPolyFilled(faceCoordsScreen, 4, (directionColor | IM_COL32(0x80, 0x80, 0x80, 0x80)) | (isInside ? IM_COL32(0x08, 0x08, 0x08, 0) : 0));
gContext.mDrawList->AddConvexPolyFilled(faceCoordsScreen, 4, (directionColor | IM_COL32(0x80, 0x80, 0x80, 0x80)) | (gContext.mIsViewManipulatorHovered ? IM_COL32(0x08, 0x08, 0x08, 0) : 0));
if (boxes[boxCoordInt])
{
gContext.mDrawList->AddConvexPolyFilled(faceCoordsScreen, 4, IM_COL32(0xF0, 0xA0, 0x60, 0x80));
Expand Down Expand Up @@ -3049,7 +3063,7 @@ namespace IMGUIZMO_NAMESPACE
vec_t newEye = camTarget + newDir * length;
LookAt(&newEye.x, &camTarget.x, &newUp.x, view);
}
isInside = gContext.mbMouseOver && ImRect(position, position + size).Contains(io.MousePos);
gContext.mIsViewManipulatorHovered = gContext.mbMouseOver && ImRect(position, position + size).Contains(io.MousePos);

if (io.MouseDown[0] && (fabsf(io.MouseDelta[0]) || fabsf(io.MouseDelta[1])) && isClicking)
{
Expand Down
10 changes: 6 additions & 4 deletions cwrappers/ImGuizmo/ImGuizmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
// - display rotation/translation/scale infos in local/world space and not only local
// - finish local/world matrix application
// - OPERATION as bitmask
//
//
// -------------------------------------------------------------------------------------------
// Example
// Example
#if 0
void EditTransform(const Camera& camera, matrix_t& matrix)
{
Expand Down Expand Up @@ -140,6 +140,8 @@ namespace IMGUIZMO_NAMESPACE

// return true if the view gizmo is in moving state
IMGUI_API bool IsUsingViewManipulate();
// only check if your mouse is over the view manipulator - no matter whether it's active or not
IMGUI_API bool IsViewManipulateHovered();

// return true if any gizmo is in moving state
IMGUI_API bool IsUsingAny();
Expand Down Expand Up @@ -172,7 +174,7 @@ namespace IMGUIZMO_NAMESPACE
IMGUI_API void DrawGrid(const float* view, const float* projection, const float* matrix, const float gridSize);

// call it when you want a gizmo
// Needs view and projection matrices.
// Needs view and projection matrices.
// matrix parameter is the source matrix (where will be gizmo be drawn) and might be transformed by the function. Return deltaMatrix is optional
// translation is applied in world space
enum OPERATION
Expand Down Expand Up @@ -222,7 +224,7 @@ namespace IMGUIZMO_NAMESPACE
IMGUI_API void ViewManipulate(float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float length, ImVec2 position, ImVec2 size, ImU32 backgroundColor);

IMGUI_API void SetAlternativeWindow(ImGuiWindow* window);

[[deprecated("Use PushID/PopID instead.")]]
IMGUI_API void SetID(int id);

Expand Down
8 changes: 4 additions & 4 deletions cwrappers/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cimgui (https://github.com/cimgui/cimgui) HEAD is on: fdd07821bbcc6583431fd42ad3ffad3a82e69501
cimgui/imgui HEAD is on: ee1deccc08c14ab1e6abcfa6aae11d915763cdb7
cimgui (https://github.com/cimgui/cimgui) HEAD is on: be19fd11eb9684462aa50ae98fa68d657daa588d
cimgui/imgui HEAD is on: a63220e3e0b28dfcd51e2e23aa79c1359fcace78
cimplot (https://github.com/cimgui/cimplot) HEAD is on: 19c90f3fb469aeba2cc66f29c29c23cf438b5dfc
cimplot/implot HEAD is on: 419a8a0f5fcb77e1e7c19ab540441686bfe21bca
cimnodes (https://github.com/cimgui/cimnodes) HEAD is on: f20c83c3cab8e99828d85c66ed3acd087f632c21
cimnodes/imnodes HEAD is on: 8563e1655bd9bb1f249e6552cc6274d506ee788b
cimmarkdown (https://github.com/gucio321/cimmarkdown) HEAD is on: 6e921ffc2b57a9969b98bf8f5aeed912bfb497f6
cimmarkdown/imgui_markdown HEAD is on: 4eb198f68090c9a1622bb9c78ee61f65b6ddc898
cimguizmo (https://github.com/cimgui/cimguizmo) HEAD is on: b360304e3e184cb4eb387429b55d7d41bbc40660
cimguizmo/ImGuizmo HEAD is on: 4298a220f113da33a73fb8357e238307c924f167
cimCTE (https://github.com/cimgui/cimcte) HEAD is on: d31240389693ade0e86273984ea8f521c679cead
cimguizmo/ImGuizmo HEAD is on: e552f632bbb17a0ebf5a91a22900f6f68bac6545
cimCTE (https://github.com/cimgui/cimcte) HEAD is on: d79dad531be6fcb76a587eefe7d0e49ef7e93bb3
cimCTE/ImGuiColorTextEdit HEAD is on: 8927d95742d4ad05540277435bab3d9ac3678bf6
19 changes: 18 additions & 1 deletion cwrappers/cimCTE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,26 @@ CIMGUI_API void TextEditor_SetText(TextEditor* self,const char* aText)
{
return self->SetText(std::string(aText));
}
CIMGUI_API char* TextEditor_GetText_alloc(TextEditor* self)
{
std::string str = self->GetText();
char* cStr = (char*)IM_ALLOC(str.size() + 1); // Allocate memory
std::strcpy(cStr, str.c_str()); // Copy string contents
return cStr; // Return new C-style string
}
CIMGUI_API void TextEditor_GetText_free(char* ptr)
{
IM_FREE(ptr); // free memory
}
CIMGUI_API const char* TextEditor_GetText_static(TextEditor* self)
{
static std::string str = self->GetText();
return str.c_str();
}
CIMGUI_API const char* TextEditor_GetText(TextEditor* self)
{
return self->GetText().c_str();
static std::string str = self->GetText();
return str.c_str();
}
CIMGUI_API void TextEditor_ImGuiDebugPanel(TextEditor* self,const char* panelName)
{
Expand Down
6 changes: 6 additions & 0 deletions cwrappers/cimCTE.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ CIMGUI_API void TextEditor_UnitTests(TextEditor* self);

///////////////manual generated
CIMGUI_API void TextEditor_SetText(TextEditor* self,const char* aText);
//allocates new memory that must be freed with TextEditor_GetText_free
CIMGUI_API char* TextEditor_GetText_alloc(TextEditor* self);
CIMGUI_API void TextEditor_GetText_free(char* ptr);
//returned value must be used to copy value before calling TextEditor_GetText_static again
CIMGUI_API const char* TextEditor_GetText_static(TextEditor* self);
//does as TextEditor_GetText_static
CIMGUI_API const char* TextEditor_GetText(TextEditor* self);
CIMGUI_API void TextEditor_ImGuiDebugPanel(TextEditor* self,const char* panelName);
#endif //CIMGUICTE_INCLUDED
Expand Down
Loading

0 comments on commit 5e3e630

Please sign in to comment.