Skip to content

Commit e9cfd62

Browse files
committed
[WIP] Viewports backend, 2
1 parent c1632cf commit e9cfd62

File tree

13 files changed

+126
-12
lines changed

13 files changed

+126
-12
lines changed

bin/imgui-java.dll

1.5 KB
Binary file not shown.

bin/imgui-java64.dll

512 Bytes
Binary file not shown.

bin/libimgui-java.so

4 KB
Binary file not shown.

bin/libimgui-java64.so

0 Bytes
Binary file not shown.

imgui-binding/src/main/java/imgui/ImGuiIO.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,75 @@ void setClipboardTextStub(void* userData, const char* text) {
590590
ImGui::GetIO().ConfigDockingTransparentPayload = value;
591591
*/
592592

593+
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
594+
595+
/**
596+
* Set to make all floating imgui windows always create their own viewport.
597+
* Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
598+
*/
599+
public native boolean getConfigViewportsNoAutoMerge(); /*
600+
return ImGui::GetIO().ConfigViewportsNoAutoMerge;
601+
*/
602+
603+
/**
604+
* Set to make all floating imgui windows always create their own viewport.
605+
* Otherwise, they are merged into the main host viewports when overlapping it. May also set ImGuiViewportFlags_NoAutoMerge on individual viewport.
606+
*/
607+
public native void setConfigViewportsNoAutoMerge(boolean value); /*
608+
ImGui::GetIO().ConfigViewportsNoAutoMerge = value;
609+
*/
610+
611+
/**
612+
* Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
613+
*/
614+
public native boolean getConfigViewportsNoTaskBarIcon(); /*
615+
return ImGui::GetIO().ConfigViewportsNoTaskBarIcon;
616+
*/
617+
618+
/**
619+
* Disable default OS task bar icon flag for secondary viewports. When a viewport doesn't want a task bar icon, ImGuiViewportFlags_NoTaskBarIcon will be set on it.
620+
*/
621+
public native void setConfigViewportsNoTaskBarIcon(boolean value); /*
622+
ImGui::GetIO().ConfigViewportsNoTaskBarIcon = value;
623+
*/
624+
625+
/**
626+
* [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations,
627+
* ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
628+
*/
629+
public native boolean getConfigViewportsNoDecoration(); /*
630+
return ImGui::GetIO().ConfigViewportsNoDecoration;
631+
*/
632+
633+
/**
634+
* [BETA] Disable default OS window decoration flag for secondary viewports. When a viewport doesn't want window decorations,
635+
* ImGuiViewportFlags_NoDecoration will be set on it. Enabling decoration can create subsequent issues at OS levels (e.g. minimum window size).
636+
*/
637+
public native void setConfigViewportsNoDecoration(boolean value); /*
638+
ImGui::GetIO().ConfigViewportsNoDecoration = value;
639+
*/
640+
641+
/**
642+
* Disable default OS parenting to main viewport for secondary viewports.
643+
* By default, viewports are marked with ParentViewportId = <main_viewport>,
644+
* expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this).
645+
* Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
646+
*/
647+
public native boolean getConfigViewportsNoDefaultParent(); /*
648+
return ImGui::GetIO().ConfigViewportsNoDefaultParent;
649+
*/
650+
651+
/**
652+
* Disable default OS parenting to main viewport for secondary viewports.
653+
* By default, viewports are marked with ParentViewportId = <main_viewport>,
654+
* expecting the platform back-end to setup a parent/child relationship between the OS windows (some back-end may ignore this).
655+
* Set to true if you want the default to be 0, then all viewports will be top-level OS windows.
656+
*/
657+
public native void setConfigViewportsNoDefaultParent(boolean value); /*
658+
ImGui::GetIO().ConfigViewportsNoDefaultParent = value;
659+
*/
660+
661+
593662
/**
594663
* Time elapsed since last frame, in seconds.
595664
* <p>

imgui-binding/src/main/java/imgui/ImGuiPlatformIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void init() {
191191
JNIEnv* env = Jni::GetEnv();\
192192
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
193193
Jni::CallImPlatformFuncViewportSuppImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\
194-
Jni::ImVec2Cpy(env, jTmpImVec2, dst);\
194+
Jni::ImVec2Cpy(env, jTmpImVec2, &dst);\
195195
}\
196196
return dst;\
197197
}

imgui-binding/src/main/java/imgui/ImGuiViewport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public ImGuiViewport(final long ptr) {
3838
*/
3939

4040
/**
41-
* See ImGuiViewportFlags_.
41+
* See {@link imgui.flag.ImGuiViewportFlags}.
4242
*/
4343
public native int getFlags(); /*
4444
return IMGUI_VIEWPORT->Flags;
4545
*/
4646

4747
/**
48-
* See ImGuiViewportFlags_.
48+
* See {@link imgui.flag.ImGuiViewportFlags}.
4949
*/
5050
public native void setFlags(int flags); /*
5151
IMGUI_VIEWPORT->Flags = flags;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package imgui.glfw;
2+
3+
final class ImGuiImplGlfwNative {
4+
private ImGuiImplGlfwNative() {
5+
}
6+
7+
/*JNI
8+
#if defined(_WIN32)
9+
#include <windows.h>
10+
#endif
11+
*/
12+
13+
// GLFW hack: Hide icon from task bar
14+
// Applied only for windows
15+
static native void win32hideFromTaskBar(long hwndPtr); /*
16+
#if defined(_WIN32)
17+
HWND hwnd = (HWND)hwndPtr;
18+
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
19+
ex_style &= ~WS_EX_APPWINDOW;
20+
ex_style |= WS_EX_TOOLWINDOW;
21+
::SetWindowLong(hwnd, GWL_EXSTYLE, ex_style);
22+
#endif
23+
*/
24+
}

imgui-binding/src/main/native/jni_common.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ namespace Jni
4848
dst->y = env->GetFloatField(src, imVec2YID);
4949
}
5050

51-
void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst) {
52-
dst.x = env->GetFloatField(src, imVec2XID);
53-
dst.y = env->GetFloatField(src, imVec2YID);
54-
}
55-
5651
void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst) {
5752
env->SetFloatField(dst, imVec4XID, src->x);
5853
env->SetFloatField(dst, imVec4YID, src->y);

imgui-binding/src/main/native/jni_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace Jni
1414
void ImVec2Cpy(JNIEnv* env, ImVec2 src, jobject dst);
1515

1616
void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2* dst);
17-
void ImVec2Cpy(JNIEnv* env, jobject src, ImVec2 dst);
1817

1918
void ImVec4Cpy(JNIEnv* env, ImVec4* src, jobject dst);
2019
void ImVec4Cpy(JNIEnv* env, ImVec4 src, jobject dst);

0 commit comments

Comments
 (0)