2. How do I set the color of the window header?
3. When using
Code: Select all
ListIconGadget(0, 0, 0,200, 310, "Label", 100)
SetGadgetColor(0,#PB_Gadget_BackColor, RGB(0,0,0))
SetGadgetColor(0,#PB_Gadget_FrontColor, RGB(255,255,255))
Code: Select all
ListIconGadget(0, 0, 0,200, 310, "Label", 100)
SetGadgetColor(0,#PB_Gadget_BackColor, RGB(0,0,0))
SetGadgetColor(0,#PB_Gadget_FrontColor, RGB(255,255,255))
Code: Select all
EnableExplicit
#NSFullSizeContentViewWindowMask = 1 << 15
; --- Blending Modes ---
Enumeration
#NSVisualEffectBlendingModeBehindWindow
#NSVisualEffectBlendingModeWithinWindow
EndEnumeration
; --- Materials ---
Enumeration
#NSVisualEffectMaterialAppearanceBased
#NSVisualEffectMaterialLight
#NSVisualEffectMaterialDark
#NSVisualEffectMaterialTitlebar
EndEnumeration
; --- Visual Effect State ---
Enumeration
#NSVisualEffectStateFollowsWindowActiveState
#NSVisualEffectStateActive
#NSVisualEffectStateInactive
EndEnumeration
Enumeration
#NSWindowTitleVisible
#NSWindowTitleHidden
EndEnumeration
; --- PureBasic Glass Material Constants ---
#GlassWindow_Light = 1
#GlassWindow_Dark = 2
#GlassWindow_Lighter = 3
#GlassWindow_LiquidGlass = 29 ; macOS 15+ only
Global blurryView.i
; --- Helper to switch materials dynamically ---
Procedure SetGlassMaterial(materialType.i)
CocoaMessage(0, blurryView, "setMaterial:", materialType)
EndProcedure
; --- Build the demo window ---
If OpenWindow(0, 200, 200, 320, 300, "Glass UI Demo", #PB_Window_Invisible | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
Define Frame.NSRect
Frame\size\width = WindowWidth(0)
Frame\size\height = WindowHeight(0)
Define Window0_ID = WindowID(0)
Define styleMask = CocoaMessage(0, Window0_ID, "styleMask") | #NSFullSizeContentViewWindowMask
CocoaMessage(0, Window0_ID, "setStyleMask:", styleMask)
CocoaMessage(0, Window0_ID, "setTitleVisibility:", #NSWindowTitleHidden)
CocoaMessage(0, Window0_ID, "setTitlebarAppearsTransparent:", #YES)
; **Make the window background transparent**
CocoaMessage(0, Window0_ID, "setOpaque:", #NO)
CocoaMessage(0, Window0_ID, "setBackgroundColor:", CocoaMessage(0, 0, "NSColor clearColor"))
; --- Create blur view background ---
blurryView = CocoaMessage(0, CocoaMessage(0, 0, "NSVisualEffectView alloc"),
"initWithFrame:@", @Frame)
CocoaMessage(0, blurryView, "setBlendingMode:", #NSVisualEffectBlendingModeWithinWindow)
CocoaMessage(0, blurryView, "setMaterial:", #GlassWindow_Light)
CocoaMessage(0, blurryView, "setState:", #NSVisualEffectStateActive)
CocoaMessage(0, CocoaMessage(0, Window0_ID, "contentView"), "addSubview:", blurryView)
; --- Popup to select material ---
TextGadget(10, 20, 10, 120, 20, "Select Material:")
ComboBoxGadget(11, 150, 10, 150, 25)
AddGadgetItem(11, -1, "Light")
AddGadgetItem(11, -1, "Dark")
AddGadgetItem(11, -1, "Lighter")
AddGadgetItem(11, -1, "LiquidGlass (macOS 15+)")
SetGadgetState(11, 0) ; Default to Light
; --- Add sample UI gadgets to test rendering ---
TextGadget(0, 20, 50, 280, 24, "Welcome to the Glass Demo")
StringGadget(1, 20, 80, 280, 26, "")
SetGadgetText(1, "Type here...")
ButtonGadget(2, 20, 120, 120, 30, "Click Me")
CheckBoxGadget(3, 20, 160, 200, 24, "Enable Fancy Mode")
TrackBarGadget(4, 20, 200, 280, 30, 0, 100)
SetGadgetState(4, 50)
TextGadget(5, 20, 240, 280, 20, "Move the slider above!")
HideWindow(0, #False)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 2
MessageRequester("Glass Demo", "Button clicked!")
Case 3
If GetGadgetState(3)
SetGadgetText(5, "Fancy Mode Enabled!")
Else
SetGadgetText(5, "Fancy Mode Disabled!")
EndIf
Case 4
SetGadgetText(5, "Slider at " + Str(GetGadgetState(4)) + "%")
Case 11 ; Material selector
Select GetGadgetState(11)
Case 0 : SetGlassMaterial(#GlassWindow_Light)
Case 1 : SetGlassMaterial(#GlassWindow_Dark)
Case 2 : SetGlassMaterial(#GlassWindow_Lighter)
Case 3 : SetGlassMaterial(#GlassWindow_LiquidGlass)
EndSelect
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
Code: Select all
EnableExplicit
#NSFullSizeContentViewWindowMask = 1 << 15
; --- Blending Modes ---
Enumeration
#NSVisualEffectBlendingModeBehindWindow
#NSVisualEffectBlendingModeWithinWindow
EndEnumeration
; --- Materials ---
Enumeration
#NSVisualEffectMaterialAppearanceBased
#NSVisualEffectMaterialLight
#NSVisualEffectMaterialDark
#NSVisualEffectMaterialTitlebar
EndEnumeration
; --- Visual Effect State ---
Enumeration
#NSVisualEffectStateFollowsWindowActiveState
#NSVisualEffectStateActive
#NSVisualEffectStateInactive
EndEnumeration
Enumeration
#NSWindowTitleVisible
#NSWindowTitleHidden
EndEnumeration
; --- PureBasic Glass Material Constants ---
#GlassWindow_Light = 1
#GlassWindow_Dark = 2
#GlassWindow_Lighter = 3
#GlassWindow_LiquidGlass = 20 ; macOS 15+ only
Global blurryView.i
; --- Helper to switch materials dynamically ---
Procedure SetGlassMaterial(materialType.i)
CocoaMessage(0, blurryView, "setMaterial:", materialType)
EndProcedure
; --- Build the demo window ---
If OpenWindow(0, 200, 200, 520, 500, "Glass UI Demo", #PB_Window_Invisible | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
Define Frame.NSRect
Frame\size\width = WindowWidth(0)
Frame\size\height = WindowHeight(0)
Define Window0_ID = WindowID(0)
Define styleMask = CocoaMessage(0, Window0_ID, "styleMask") | #NSFullSizeContentViewWindowMask
CocoaMessage(0, Window0_ID, "setStyleMask:", styleMask)
CocoaMessage(0, Window0_ID, "setTitleVisibility:", #NSWindowTitleHidden)
CocoaMessage(0, Window0_ID, "setTitlebarAppearsTransparent:", #YES)
; **Make the window background transparent**
CocoaMessage(0, Window0_ID, "setOpaque:", #NO)
CocoaMessage(0, Window0_ID, "setBackgroundColor:", CocoaMessage(0, 0, "NSColor clearColor"))
; --- Create blur view background ---
blurryView = CocoaMessage(0, CocoaMessage(0, 0, "NSVisualEffectView alloc"),
"initWithFrame:@", @Frame)
; CocoaMessage(0, blurryView, "setBlendingMode:", #NSVisualEffectBlendingModeWithinWindow)
; CocoaMessage(0, blurryView, "setMaterial:", #GlassWindow_Light)
; CocoaMessage(0, blurryView, "setState:", #NSVisualEffectStateActive)
CocoaMessage(0, CocoaMessage(0, Window0_ID, "contentView"), "addSubview:", blurryView)
; --- Popup to select material ---
TextGadget(10, 20, 10, 120, 20, "Select Material:")
ComboBoxGadget(11, 150, 10, 150, 25)
AddGadgetItem(11, -1, "Light")
AddGadgetItem(11, -1, "Dark")
AddGadgetItem(11, -1, "Lighter")
AddGadgetItem(11, -1, "LiquidGlass (macOS 15+)")
SetGadgetState(11, 0) ; Default to Light
; --- Add sample UI gadgets to test rendering ---
TextGadget(0, 20, 50, 280, 24, "Welcome to the Glass Demo")
StringGadget(1, 20, 80, 280, 26, "")
SetGadgetText(1, "Type here...")
ButtonGadget(2, 20, 120, 120, 30, "Click Me")
CheckBoxGadget(3, 20, 160, 200, 24, "Enable Fancy Mode")
TrackBarGadget(4, 20, 200, 280, 30, 0, 100)
SetGadgetState(4, 50)
TextGadget(5, 20, 240, 280, 20, "Move the slider above!")
EditorGadget(6,300,300,160,160)
SetGadgetColor(6,#PB_Gadget_BackColor,#Black)
HideWindow(0, #False)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 2
MessageRequester("Glass Demo", "Button clicked!")
Case 3
If GetGadgetState(3)
SetGadgetText(5, "Fancy Mode Enabled!")
Else
SetGadgetText(5, "Fancy Mode Disabled!")
EndIf
Case 4
SetGadgetText(5, "Slider at " + Str(GetGadgetState(4)) + "%")
Case 11 ; Material selector
Select GetGadgetState(11)
Case 0 : SetGlassMaterial(#GlassWindow_Light)
Case 1 : SetGlassMaterial(#GlassWindow_Dark)
Case 2 : SetGlassMaterial(#GlassWindow_Lighter)
Case 3 : SetGlassMaterial(#GlassWindow_LiquidGlass)
EndSelect
EndSelect
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
Code: Select all
#NSBorderlessWindowMask = 0
#NSTitledWindowMask = 1 << 0
#NSClosableWindowMask = 1 << 1
#NSMiniaturizableWindowMask = 1 << 2
#NSResizableWindowMask = 1 << 3
#NSUtilityWindowMask = 1 << 4
#NSDocModalWindowMask = 1 << 6
#NSNonactivatingPanelMask = 1 << 7
#NSTexturedBackgroundWindowMask = 1 << 8
#NSHUDWindowMask = 1 << 14
#window=100
mask=#NSTitledWindowMask|#NSClosableWindowMask|#NSMiniaturizableWindowMask|#NSResizableWindowMask|#NSTexturedBackgroundWindowMask|#NSNonactivatingPanelMask|#NSBorderlessWindowMask
If OpenWindow(#window, 0, 0, 400, 300, "cocoa", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(#window,#Black)
EditorGadget(2,10,10,50,50)
SetGadgetColor(2,#PB_Gadget_BackColor,#Black)
win-WindowID(#window)
CocoaMessage(0,win,"styleMask:",mask)
CocoaMessage(0,win,"borderless:",#YES)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Code: Select all
mask = CocoaMessage(0, #window, "styleMask")
mask | #NSBorderlessWindowMask
CocoaMessage(0, #window,"setStyleMask:", mask)
Code: Select all
Enumeration CGWindowLevelKey
#kCGFloatingWindowLevelKey
EndEnumeration
#NSFloatingWindowLevel = #kCGFloatingWindowLevelKey
#NSBorderlessWindowMask = 0
#NSTitledWindowMask = 1 << 0
#NSClosableWindowMask = 1 << 1
#NSMiniaturizableWindowMask = 1 << 2
#NSResizableWindowMask = 1 << 3
#NSUtilityWindowMask = 1 << 4
#NSDocModalWindowMask = 1 << 6
#NSNonactivatingPanelMask = 1 << 7
#NSTexturedBackgroundWindowMask = 1 << 8
#NSHUDWindowMask = 1 <<13
ImportC ""
class_addMethod(Class.I, Selector.I, *Callback, Types.P-ASCII)
sel_registerName(MethodName.P-ASCII)
EndImport
Global NSHUDWindowMask =1
w1=OpenWindow(#PB_Any, 80, 280, 100, 300, "")
HideWindow(w1,#True)
Procedure App()
Protected app
CocoaMessage(@app,0,"NSApplication sharedApplication")
ProcedureReturn app
EndProcedure
Procedure InitRect(*rect.NSRect,x,y,width,height)
If *rect
*rect\origin\x = x
*rect\origin\y = y
*rect\size\width = width
*rect\size\height = height
EndIf
EndProcedure
Procedure Panel(x,y,width,height,title.s,mask,center=#True)
Protected size.NSSize, rect.NSRect, win, view
CocoaMessage(@win,0,"NSPanel alloc")
If win
InitRect(@rect,x,y,width,height)
CocoaMessage(0,win,"initWithContentRect:@",@rect,"styleMask:",mask,"backing:",2,"defer:",#NO)
CocoaMessage(0,Win,"makeKeyAndOrderFront:",App())
CocoaMessage(0,win,"setTitle:$",@title)
CocoaMessage(0,win,"setPreventsApplicationTerminationWhenModal:",#NO)
CocoaMessage(0,win,"setReleasedWhenClosed:",#YES)
CocoaMessage(@view,0,"NSView alloc")
If view
InitRect(@rect,0,0,width,height)
CocoaMessage(@view,view,"initWithFrame:@",@rect)
CocoaMessage(0,win,"setContentView:",view)
EndIf
If center
CocoaMessage(0,win,"center")
EndIf
CocoaMessage(0,win,"update")
CocoaMessage(0,win,"display")
EndIf
ProcedureReturn win
EndProcedure
Procedure OnBtnClick()
End
EndProcedure
ProcedureC PanelShouldCloseCallback(Object.I, Selector.I, Sender.I)
PostEvent(#PB_Event_CloseWindow)
EndProcedure
NSPanel = Panel(100,300,500,300,"HUD Window", #NSUtilityWindowMask | #NSTitledWindowMask | #NSClosableWindowMask | #NSMiniaturizableWindowMask | #NSTexturedBackgroundWindowMask | #NSNonactivatingPanelMask|#NSResizableWindowMask|#NSHUDWindowMask)
UseGadgetList( NSPanel )
ButtonGadget(0,340,5,150,25,"Exit")
EditorGadget(1,300,5,150,100)
BindGadgetEvent(0,@OnBtnClick())
class_addMethod(CocoaMessage(0, NSPanel, "class"),
sel_registerName("windowShouldClose:"), @PanelShouldCloseCallback(), "v@:@")
CocoaMessage(0, WindowID(w1), "setDelegate:", AppDelegate)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow