Added keystrokes to UiSample

Added debug function
This commit is contained in:
Kirurobo
2021-10-10 01:05:51 +09:00
parent 2b488a0384
commit 1ccb98378b
8 changed files with 91 additions and 32 deletions

View File

@@ -179,6 +179,9 @@ namespace Kirurobo
[DllImport("LibUniWinC")]
public static extern void SetKeyColor(uint colorref);
[DllImport("LibUniWinC")]
public static extern int GetDebugInfo();
}
#endregion
@@ -767,6 +770,17 @@ namespace Kirurobo
}
Debug.Log(message);
}
/// <summary>
/// Receive information for debugging
/// </summary>
/// <returns></returns>
[Obsolete]
public static int GetDebugInfo()
{
return LibUniWinC.GetDebugInfo();
}
#endregion
}

View File

@@ -921,5 +921,19 @@ namespace Kirurobo
//uniWin.SetFocus();
}
}
/// <summary>
/// デバッグ専用。その都度参考となる情報を受けるための関数
/// </summary>
/// <returns></returns>
[Obsolete]
public int GetDebugInfo()
{
if (uniWinCore != null) {
return UniWinCore.GetDebugInfo();
}
return 0;
}
}
}

View File

@@ -2050,7 +2050,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Bottommost (WIP)
m_Text: Bottommost [B]
--- !u!1 &8301087647529909540
GameObject:
m_ObjectHideFlags: 0
@@ -2432,7 +2432,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Transparent
m_Text: Transparent [T]
--- !u!1 &8301087647621619055
GameObject:
m_ObjectHideFlags: 0
@@ -5876,7 +5876,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Zoomed
m_Text: Zoomed [Z]
--- !u!1 &8301087649171761010
GameObject:
m_ObjectHideFlags: 0
@@ -6960,9 +6960,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 'Topmost
'
m_Text: Topmost [F]
--- !u!1 &8301087649501092118
GameObject:
m_ObjectHideFlags: 0

View File

@@ -108,6 +108,7 @@ namespace Kirurobo
UpdateUI();
//Debug.Log("Window state changed: " + type);
ShowEventMessage("State changed: " + type);
//ShowEventMessage("State changed: " + type + "4:isKey 2:canBecomeKey, 1:canBecomeMain : " + uniwinc.GetDebugInfo().ToString());
};
uniwinc.OnMonitorChanged += () => {
UpdateMonitorDropdown();
@@ -195,26 +196,35 @@ namespace Kirurobo
}
}
// サンプルとしての処理
// キーでも設定変更
if (uniwinc)
{
// [Space]キーを押すと強制的にクリックスルーを解除
// 操作不能となったときの対応
// ただし自動判定が有効ならすぐ変化の可能性もある
if (Input.GetKeyUp(KeyCode.Space))
{
uniwinc.isClickThrough = false;
}
}
if (Input.GetKeyUp(KeyCode.T))
{
if (uniwinc)
// Toggle transparent
if (Input.GetKeyUp(KeyCode.T))
{
uniwinc.isTransparent = !uniwinc.isTransparent;
}
// Toggle always on the front
if (Input.GetKeyUp(KeyCode.F))
{
uniwinc.isTopmost = !uniwinc.isTopmost;
}
// Toggle always on the bottom
if (Input.GetKeyUp(KeyCode.B))
{
uniwinc.isBottommost = !uniwinc.isBottommost;
}
// Toggle zoom
if (Input.GetKeyUp(KeyCode.Z))
{
uniwinc.isZoomed = !uniwinc.isZoomed;
}
}
// Test for OpenFilePanel
if (Input.GetKeyUp(KeyCode.O))
{

View File

@@ -121,7 +121,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.8.1
bundleVersion: 0.8.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0

View File

@@ -175,3 +175,8 @@ UNIWINC_EXPORT BOOL OpenSavePanel(const void* lpPanelSettings, UniChar* lpwsBuff
return [LibUniWinC openSavePanelWithLpSettings: lpPanelSettings lpBuffer: lpwsBuffer bufferSize: bufferSize];
}
// for debugging
UNIWINC_EXPORT SInt32 GetDebugInfo() {
return [LibUniWinC getDebugInfo];
}

View File

@@ -445,9 +445,11 @@ public class LibUniWinC : NSObject {
/// - isTransparent: truefalse
private static func _setWindowTransparent(window: NSWindow, isTransparent: Bool) -> Void {
if (isTransparent) {
//window.styleMask = orgWindowInfo.styleMask
//window.styleMask = []
// window.styleMask = orgWindowInfo.styleMask
// //window.styleMask = []
// if (state.isBorderless) {
// window.titlebarAppearsTransparent = true
// window.titleVisibility = .hidden
// window.styleMask.insert(.borderless)
// }
window.backgroundColor = NSColor.clear
@@ -490,10 +492,12 @@ public class LibUniWinC : NSObject {
/// - isBorderless:
private static func _setWindowBorderless(window: NSWindow, isBorderless: Bool) -> Void {
if (isBorderless) {
window.styleMask.insert(.borderless)
window.styleMask = [.borderless]
//window.styleMask.insert(.borderless)
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
} else {
window.styleMask = orgWindowInfo.styleMask
if (!orgWindowInfo.styleMask.contains(.borderless)) {
// .borderless
window.styleMask.remove(.borderless)
@@ -521,9 +525,6 @@ public class LibUniWinC : NSObject {
if let window: NSWindow = targetWindow {
_setWindowTransparent(window: window, isTransparent: isTransparent)
_setContentViewTransparent(window: window, isTransparent: isTransparent)
// Reapply borderless state
_setWindowBorderless(window: window, isBorderless: state.isBorderless)
}
if (state.isTransparent != isTransparent) {
@@ -547,6 +548,10 @@ public class LibUniWinC : NSObject {
_setWindowBorderless(window: window, isBorderless: isBorderless)
//
// window.makeMain()
// window.makeKey()
if (state.isZoomed) {
if (!window.isZoomed) {
window.zoom(nil)
@@ -558,12 +563,13 @@ public class LibUniWinC : NSObject {
window.setFrame(rect, display: true, animate: false)
}
} else {
if (!isBorderless && state.isBorderless) {
// Restore the window size when the window become bordered
if (state.normalWindowRect.width != 0 && state.normalWindowRect.height != 0) {
window.setFrame(state.normalWindowRect, display: true, animate: false)
}
}
//
// if (!isBorderless && state.isBorderless) {
// // Restore the window size when the window become bordered
// if (state.normalWindowRect.width != 0 && state.normalWindowRect.height != 0) {
// window.setFrame(state.normalWindowRect, display: true, animate: false)
// }
// }
}
}
@@ -1097,4 +1103,16 @@ public class LibUniWinC : NSObject {
}
return true
}
/// Return some information for debugging
@objc public static func getDebugInfo() -> Int32 {
var result: Int32 = 0
if (targetWindow != nil) {
if (targetWindow!.canBecomeMain) { result += 1 }
if (targetWindow!.canBecomeKey) { result += 2 }
if (targetWindow!.isKeyWindow) { result += 4 }
}
return result
}
}