[Resolved] Transparent Windows on OSX?

Mac OSX specific forum
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

[Resolved] Transparent Windows on OSX?

Post by garretthylltun »

Greetings,

Is it possible to make an OSX PB made Window transparent?

Thanks,
-Garrett
Last edited by garretthylltun on Wed Jan 18, 2006 2:28 am, edited 1 time in total.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Sorry to disturb.. but here is an tip..
Use the SetWindowAlpha function in CarbonLib
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes, this should work. Just use a float as second parameter:

Code: Select all

Alpha.f = 0.5
SetWindowAlpha_(WindowID(0), Alpha)
You will have to put SetWindowAlpha in a .pbl before.
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Post by garretthylltun »

Like my previous api attempts, no errors being shown, but nothing is
going on either.

Here is the source code I'm using to test this, it's an autohide bar on the
left of the screen:

(the alpha call is in the second if statement in the main loop)

Code: Select all

;
;  /Applications/Programming/PureBasic/compilers/pbsoimporter /Applications/Programming/PureBasic/compilers/windowalpha.pbl /TO /Applications/Programming/PureBasic
;
;  Icons for OSX apps are located in the .app/resources folder.
;  Read the .app/info.plis file.  Look for the following key
;    and read it's string
;	     <key>CFBundleIconFile</key>
;	     <string>Icon</string>
;  The icon file is in .icns format.

; #PB_Window_BorderLess  #PB_Window_TitleBar

OpenWindow (0, 0, 100, 100, 600, #PB_Window_BorderLess , "ALB")
;UsePNGImageDecoder()
;LoadImage(1, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/add24.png")
;LoadImage(2, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/remove24.png")
;LoadImage(3, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/up24.png")
;LoadImage(4, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/down24.png")
;LoadImage(5, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/help24.png")
;LoadImage(6, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/close24.png")
;LoadImage(7, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/close24a.png")
CreateGadgetList(WindowID(0))
  ButtonGadget(9, 2, 100, 32, 24, "X", #PB_Button_Left)
  ;ImageGadget(1,  2, 30, 24, 24, UseImage(1), #PB_EventType_LeftClick)
  ;ImageGadget(2, 26, 30, 24, 24, UseImage(2), #PB_EventType_LeftClick)
  ;ImageGadget(3, 50, 30, 24, 24, UseImage(3), #PB_EventType_LeftClick)
  ;ImageGadget(4, 74, 30, 24, 24, UseImage(4), #PB_EventType_LeftClick)
  ;ImageGadget(6, 74,  2, 24, 24, UseImage(6), #PB_EventType_LeftClick)
  vMouseLocStatus = 1
  vInitHold = 0
  ;InitMouse()

Event_Loop:
  Delay(100)
  If vInitHold < 10
    vInitHold = vInitHold + 1
  EndIf
  If vInitHold = 9
    Alpha.f = 0.5
    SetWindowAlpha_(WindowID(0), Alpha)
    MessageRequester("Notice", "Alpha On?", #PB_MessageRequester_Ok)
  EndIf
  ; X is left to right
  ; Y is top to bottom
  If vInitHold > 8
    If vMouseX < 2 And vMouseLocStatus = 0
      Gosub RollOut
    EndIf
    If vMouseX > 100 And vMouseLocStatus = 1
      Gosub RollIn
    EndIf
  EndIf
  vMouseX = DesktopMouseX()
  vMouseY = DesktopMouseY()
  EventID = WindowEvent()
  If EventID = #PB_Event_CloseWindow
    End
  EndIf
  GadgetID = EventGadgetID()
  If GadgetID = 1
    Goto Branch_1
  ElseIf GadgetID = 6
    Goto Branch_6
    ElseIf GadgetID = 9
      Goto Branch_9
  EndIf
  Goto Event_Loop

Branch_1:
  ;Result = RunProgram("/Applications/File/Xfolders.app")
  Goto Event_Loop

Branch_6:
  ;SetGadgetState(6,UseImage(7))
  ;Repeat
  ;    vMouseClick = MouseButton(1)
  ;Until vMouseClick = 0
  ;SetGadgetState(6,UseImage(6))
  ;Delay(500)
  ;Goto Branch_9
  Goto Event_Loop

Branch_9:
  End
  
RollIn:
  vMouseLocStatus = 0
  vWide = 0
  vStep = 10
  While vWide > -98
    If vStep > 1
      vStep = vStep - 1
    EndIf
    vWide = vWide - vStep
    vMove = vWide
    MoveWindow(vMove, 100)
  Wend
  MoveWindow(-98, 100)
  Return

RollOut:
  vMouseLocStatus = 1
  vWide = 98
  vStep = 10
  While vWide > 2
    If vStep > 1
      vStep = vStep - 1
    EndIf
    vWide = vWide - vStep
    vMove = -vWide
    MoveWindow(vMove, 100)
  Wend
  MoveWindow(0,100)
  ActivateWindow()
  Return
Here is the .pbl file I used

Code: Select all

;
-framework Carbon
SetWindowAlpha 2
I'll be honest, I don't fully understand the OSX api stuff and have only
been using them with info I've been finding in this OSX forum.

Can anyone else try this, or look it over and see if I'm calling it wrong,
or if my .pbl file is incorrect?

Thanks,
-Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

SetWindowAlpha(w,alpha) is an function and return an integer
err = SetWindowAlpha(w,alpha)
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

It was a bug with float OS function parameter. I fixed it and put the new version on your private account (PureBasic 3.94c). The SetWindowAlpha_() function is now buildin in the recognized functions.
garretthylltun
Enthusiast
Enthusiast
Posts: 346
Joined: Wed Oct 26, 2005 2:46 am
Contact:

Post by garretthylltun »

Awwww Yeah! That's the stuff! :-)

Fred, if you ever need any computer related equipment, or hosting, just
visit my friend Emmanuel at http://www.netdiffusion.com/ and tell him
Garrett sent you. He should be so kind as to give you some sort of
discount if you mention my name (if he doesn't, then tell him I said to
stuff a snail up his bottom side!). He recently opened and brand new
data center in Paris, top of the line servers etc..

Thank you so very much for the fix,
-Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
· Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
· http://www.freewarehome.com/ <-- Freeware listings since 1996
Post Reply