Skip to content

Commit

Permalink
New functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Aug 7, 2018
1 parent a9764b2 commit f649b77
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 2 deletions.
1 change: 1 addition & 0 deletions buildSrc/src/GenGenTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ open class GenGenTask : GenTask("JImGuiGen", "imgui") {
Fun("styleColorsDark", stylePtr("style", true)),
Fun("styleColorsClassic", stylePtr("style", true)),
Fun("styleColorsLight", stylePtr("style", true)),
Fun("styleColorsLightGreen", stylePtr("style", true)),

// Cursor / Layout
Fun("separator"),
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/GenIOTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ open class GenIOTask : GenTask("JImGuiIOGen", "imgui_io") {
BPPT("MouseReleased", isArray = true, annotation = "@MagicConstant(valuesFromClass = JImMouseIndexes.class)"),
BPPT("MouseDownOwned", isArray = true, annotation = "@MagicConstant(valuesFromClass = JImMouseIndexes.class)"),
BPPT("FontAllowUserScaling"),
BPPT("OptMacOSXBehaviors"),
BPPT("OptCursorBlink"),
BPPT("ConfigMacOSXBehaviors"),
BPPT("ConfigCursorBlink"),
BPPT("MouseDrawCursor"),
BPPT("KeyCtrl"),
BPPT("KeyShift"),
Expand Down
105 changes: 105 additions & 0 deletions core/jni/dx9_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,111 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hWnd, msg, wParam, lParam);
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeX(jlong nativeObjectPtr) -> float {
auto wc = reinterpret_cast<Ptr<WNDCLASSEX>> (object);
RECT rect{};
GetWindowRect(hwnd, &rect);
return static_cast<float>(rect.right - rect.left);
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeY(jlong nativeObjectPtr) -> float {
auto wc = reinterpret_cast<Ptr<WNDCLASSEX>> (object);
RECT rect{};
GetWindowRect(hwnd, &rect);
return static_cast<float>(rect.bottom - rect.top);
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosX(jlong nativeObjectPtr) -> float {
auto wc = reinterpret_cast<Ptr<WNDCLASSEX>> (object);
RECT rect{};
GetWindowRect(hwnd, &rect);
return static_cast<float>(rect.left);
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosY(jlong nativeObjectPtr) -> float {
auto wc = reinterpret_cast<Ptr<WNDCLASSEX>> (object);
RECT rect{};
GetWindowRect(hwnd, &rect);
return static_cast<float>(rect.top);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeX(jlong nativeObjectPtr, float newValue) {
SetWindowPos(
hwnd,
nullptr,
0,
0,
static_cast<int>(newValue),
0,
SWP_NOMOVE);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeY(jlong nativeObjectPtr, float newValue) {
SetWindowPos(
hwnd,
nullptr,
0,
0,
0,
static_cast<int>(newValue),
SWP_NOMOVE);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosX(jlong nativeObjectPtr, float newValue) {
SetWindowPos(
hwnd,
nullptr,
static_cast<int>(newValue),
0,
0,
0,
SWP_NOMOVE);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosY(jlong nativeObjectPtr, float newValue) {
SetWindowPos(
hwnd,
nullptr,
0,
static_cast<int>(newValue),
0,
0,
SWP_NOMOVE);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSize(jlong nativeObjectPtr, float newX, float newY) {
SetWindowPos(
hwnd,
nullptr,
static_cast<int>(newX),
static_cast<int>(newY),
0,
0,
SWP_NOMOVE);

}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPos(jlong nativeObjectPtr, float newX, float newY) {
SetWindowPos(
hwnd,
nullptr,
0,
0,
static_cast<int>(newX),
static_cast<int>(newY),
SWP_NOMOVE);
}

#ifndef WIN32
#pragma clang diagnostic pop
#endif
77 changes: 77 additions & 0 deletions core/jni/glfw_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,81 @@ JavaCritical_org_ice1000_jimgui_JImGui_render(jlong nativeObjectPtr, jlong color
glfwSwapBuffers(window);
}


JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeX(jlong nativeObjectPtr) -> float {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowSize(window, &w, &h);
return w;
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeY(jlong nativeObjectPtr) -> float {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowSize(window, &w, &h);
return h;
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosX(jlong nativeObjectPtr) -> float {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowPos(window, &w, &h);
return w;
}

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosY(jlong nativeObjectPtr) -> float {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowPos(window, &w, &h);
return h;
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeX(jlong nativeObjectPtr, float newValue) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowSize(window, &w, &h);
glfwSetWindowSize(window, static_cast<int>(newValue), h);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeY(jlong nativeObjectPtr, float newValue) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowSize(window, &w, &h);
glfwSetWindowSize(window, w, static_cast<int>(newValue));
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosX(jlong nativeObjectPtr, float newValue) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowPos(window, &w, &h);
glfwSetWindowPos(window, static_cast<int>(newValue), h);
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosY(jlong nativeObjectPtr, float newValue) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
int w, h;
glfwGetWindowPos(window, &w, &h);
glfwSetWindowPos(window, w, static_cast<int>(newValue));
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSize(jlong nativeObjectPtr, float newX, float newY) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
glfwSetWindowSize(window, static_cast<int>(newX), static_cast<int>(newY));
}

JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPos(jlong nativeObjectPtr, float newX, float newY) {
auto *window = PTR_J2C(GLFWwindow, nativeObjectPtr);
glfwSetWindowPos(window, static_cast<int>(newX), static_cast<int>(newY));
}

#pragma clang diagnostic pop
80 changes: 80 additions & 0 deletions core/jni/impl_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,86 @@ JavaCritical_org_ice1000_jimgui_glfw_GlfwUtil_createWindowPointer0(jint width,
Ptr<jbyte> title,
jlong anotherWindow) -> jlong;

JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeX(jlong nativeObjectPtr) -> float;
JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeY(jlong nativeObjectPtr) -> float;
JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosX(jlong nativeObjectPtr) -> float;
JNIEXPORT auto JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosY(jlong nativeObjectPtr) -> float;
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeX(jlong nativeObjectPtr, float newValue);
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeY(jlong nativeObjectPtr, float newValue);
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosX(jlong nativeObjectPtr, float newValue);
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosY(jlong nativeObjectPtr, float newValue);
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSize(jlong nativeObjectPtr, float newX, float newY);
JNIEXPORT void JNICALL
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPos(jlong nativeObjectPtr, float newX, float newY);

JNIEXPORT auto JNICALL
Java_org_ice1000_jimgui_JImGui_getPlatformWindowSizeX(JNIEnv *,
jclass,
jlong nativeObjectPtr) -> float {
return JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeX(nativeObjectPtr);
}

JNIEXPORT auto JNICALL
Java_org_ice1000_jimgui_JImGui_getPlatformWindowSizeY(JNIEnv *,
jclass,
jlong nativeObjectPtr) -> float {
return JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowSizeY(nativeObjectPtr);
}

JNIEXPORT auto JNICALL
Java_org_ice1000_jimgui_JImGui_getPlatformWindowPosX(JNIEnv *,
jclass,
jlong nativeObjectPtr) -> float {
return JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosX(nativeObjectPtr);
}

JNIEXPORT auto JNICALL
Java_org_ice1000_jimgui_JImGui_getPlatformWindowPosY(JNIEnv *,
jclass,
jlong nativeObjectPtr) -> float {
return JavaCritical_org_ice1000_jimgui_JImGui_getPlatformWindowPosY(nativeObjectPtr);
}


JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowSizeX(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newValue) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeX(nativeObjectPtr, newValue);
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowSizeY(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newValue) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSizeY(nativeObjectPtr, newValue);
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowPosX(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newValue) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosX(nativeObjectPtr, newValue);
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowPosY(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newValue) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPosY(nativeObjectPtr, newValue);
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowSize(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newX, jfloat newY) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowSize(nativeObjectPtr, newX, newY)
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_setPlatformWindowPos(JNIEnv *, jclass, jlong nativeObjectPtr, jfloat newX, jfloat newY) {
JavaCritical_org_ice1000_jimgui_JImGui_setPlatformWindowPos(nativeObjectPtr, newX, newY)
}

JNIEXPORT void JNICALL
Java_org_ice1000_jimgui_JImGui_deallocateNativeObjects(JNIEnv *, jclass, jlong nativeObjectPtr) {
JavaCritical_org_ice1000_jimgui_JImGui_deallocateNativeObjects(nativeObjectPtr);
Expand Down

0 comments on commit f649b77

Please sign in to comment.