Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Nov 21, 2017 8:55 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Faking the unified window look
PostPosted: Sat May 07, 2011 10:06 am 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
OK,

I need to add the Coverflow, list and icon buttons to a toolbar, much like Apple does in Finder and iTunes. See image:

Image

Image

I am compiling to Cocoa. Yes I know it's in Beta but everything is working for me so far in this app and I'm trying not to rely on outdated Carbon declares.

I know that REALbasic Toolbar class looks like the above toolbar but you can only add predefined toolbar buttons with a custom icon. I would like to be able to draw to the toolbar (obviously not possible). I have been tinkering around and have found that if I set the Window's Frame property to 'Metal' then I can simply draw my custom buttons to the top of the window and 'fake' a toolbar. Not a big deal - it actually works really well, see below:

Image

The problem is that if I drag anywhere on the window, the entire window is dragged around the screen! I'm guessing this is the expected behaviour for a metal window but I'm wondering if:

A) There is any whay to turn off this dragging property so that the metal window behaves like a normal document window.
B) Failing the above, is there a way to draw a custom frame to mimic the Textured window look?

Sorry for the long question but this is a big deal in terms of making apps that look like Apple's native ones and that compile with Cocoa. Do any Cocoa declares exist??

MadDoc,

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Sat May 07, 2011 2:10 pm 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
Right. I've done it and I'm pretty chuffed.

I've had to resort to using the Cocoa MBS plugin (very reasonably priced) but it works great.

Here's a pic:

Image

I've written a long blog post and included an example project on how to do this on my blog.

Hope this is helpful.

MadDoc

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 10, 2011 1:46 am 
Offline

Joined: Sun Oct 22, 2006 2:08 am
Posts: 243
Didn't know it could be done that way.
I have only one question: do you know how (and if) you can set the height of the top and bottom bars as well?

_________________
Simple, useful and easy-to-use applications for Mac OS X
More information: http://www.joris-vervuurt.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 10, 2011 2:03 am 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
jorisvervuurt wrote:
I have only one question: do you know how (and if) you can set the height of the top and bottom bars as well?

Easy. If you take a look at the example project available on the blog post you'll see how.

The entire window has a textured appearance. Just move the layout of your window controls up or down to change the size of the top and bottom toolbars. There's a 1 pixel high canvas that's drawing the delineating border.

MadDoc,

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 10, 2011 3:22 am 
Offline

Joined: Sun Oct 22, 2006 2:08 am
Posts: 243
MadDoc wrote:
jorisvervuurt wrote:
I have only one question: do you know how (and if) you can set the height of the top and bottom bars as well?

Easy. If you take a look at the example project available on the blog post you'll see how.

The entire window has a textured appearance. Just move the layout of your window controls up or down to change the size of the top and bottom toolbars. There's a 1 pixel high canvas that's drawing the delineating border.

MadDoc,


Ah, but what if I don't have any controls on it and want to set the height of the top bar?
The bottom bar indeed auto-resizes, but the top bar doesn't seem to resize (the gradient stays the same, which is not what I want).

_________________
Simple, useful and easy-to-use applications for Mac OS X
More information: http://www.joris-vervuurt.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 10, 2011 3:42 am 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
jorisvervuurt wrote:
Ah, but what if I don't have any controls on it and want to set the height of the top bar?
The bottom bar indeed auto-resizes, but the top bar doesn't seem to resize (the gradient stays the same, which is not what I want).


Hmm, I don't think there's a way to change the gradient across the window content area, even with Cocoa declares...

MadDoc,

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Wed May 11, 2011 7:02 am 
Offline

Joined: Sun Oct 22, 2006 2:08 am
Posts: 243
Actually, I've been able to get it working the way I want it to! ;-)

I have written a method that is compatible with both Cocoa and Carbon, and it lets you specify the height of the top bar and the height of the bottom bar.
It also has an optional parameter that lets you set whether the window should be movable by the top bar (and the window background) or not.

Note that it also doesn't require the force redraw of the Window. ;-)

I've uploaded an example project (including the fully commented method) to my website:
http://www.joris-vervuurt.com/rs_forum_examples/UnifiedBars_Example.zip

The method can be found in Window1 of the example project.

_________________
Simple, useful and easy-to-use applications for Mac OS X
More information: http://www.joris-vervuurt.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Wed May 11, 2011 7:59 am 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
Joris that is fantastic!

I've just responded to your comment on my blog and I'm in the process of updating the post. It would seem that my method produced some issues with sheet windows not popping out from the correct part of the bottom of the toolbar. Your example fixes that.

Well done!

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Wed May 11, 2011 8:07 am 
Offline

Joined: Sun Oct 22, 2006 2:08 am
Posts: 243
Thanks!
I hope I've made a lot of people happy. ;-)

By the way, I've posted a reply on your blog again. Hehe.

_________________
Simple, useful and easy-to-use applications for Mac OS X
More information: http://www.joris-vervuurt.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Wed May 11, 2011 8:59 am 
Offline
User avatar

Joined: Wed Oct 05, 2005 1:21 pm
Posts: 515
Location: United Kingdom
Cheers mate - check the comments...

_________________
Gorgeous REALbasic controls from Figa Software | My Flickr | My Blog
11" MacBook Air 1.8Ghz i7, 4GB RAM, OSX 10.8.2, RB 2012 r1.1 Pro | iPhone 4S 32GB | Nikon D60


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Wed May 11, 2011 10:08 am 
Offline

Joined: Sun Oct 22, 2006 2:08 am
Posts: 243
MadDoc wrote:
Cheers mate - check the comments...

You've got mail! ;-)

_________________
Simple, useful and easy-to-use applications for Mac OS X
More information: http://www.joris-vervuurt.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 21, 2013 8:30 am 
Offline

Joined: Sun Jun 24, 2007 12:24 pm
Posts: 441
Location: Madrid
Hi. I was looking at a way of making custom window frames in Windows and Mac and saw MadDoc's post in both windows and macintosh sections.

Sadly, the example shared here doesn't exist any more and there's no explanation of what was done.

Do you have any pointers on what's needed to create custom window frames (which this "fake unified window view" would be, in the end)?

_________________
----
http://eduo.info/
http://gallery.eduo.info/
http://twitter.com/eduo/


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 21, 2013 8:44 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
you mean like this?

works in CARBON.. have not tested the COCOA part

SUB SetRoundWindowTopBottom(w As window, topHeight As Integer, botHeight As Integer)
#If TargetMacOS Then
#If TargetCarbon Then
If System.IsFunctionAvailable("HIWindowSetContentBorderThickness","Carbon") Then
Soft Declare Function HIWindowSetContentBorderThickness Lib "Carbon" (w As WindowPtr, inBorderThickness As Ptr) As Integer
Soft Declare Function ChangeWindowAttributes Lib "Carbon" (w As WindowPtr, setAttributes As Integer, clearAttributes As Integer) As Integer

Const kHIWindowBitRoundBottomBarCorners=13

Dim OSError As Integer
Dim BorderThickness As New MemoryBlock(16)

BorderThickness.SingleValue(0)=topHeight //Top
BorderThickness.SingleValue(4)=0 //Must Be Zero
BorderThickness.SingleValue(8)=botHeight //Bottom
BorderThickness.SingleValue(12)=0 //Must Be Zero

OSError=HIWindowSetContentBorderThickness(w,BorderThickness)
OSError=ChangeWindowAttributes(w,Bitwise.ShiftLeft(1,(kHIWindowBitRoundBottomBarCorners-1)),0)
End If
#Else
#If TargetCocoa
Const NSBackingStoreType = 2
Const NSMaxYEdge = 3
Const NSMinYEdge = 1
Const NSTexturedBackgroundWindowMask = 256
Const NSTitledWindowMask = 1
Const NSResizabkeWindowMask = 8
Const NSMiniaturizableWindowMask = 4
Const NSClosableWindowMask = 2
Const NSResizableWindowMask=8

w.Frame=9

Declare Sub setBackingType Lib "Cocoa" selector "setBackingType:" ( ObjID As Integer, bufferingType As Integer)
Declare Sub setStyleMask Lib "Cocoa" selector "setStyleMask:" (obj_id As Integer, mask As Integer)
Declare Function styleMask Lib "Cocoa.framework" selector "styleMask" (id As Integer) As Integer
Declare Sub SetAutorecalculatesContentBorder Lib "AppKit" Selector "setAutorecalculatesContentBorderThickness:forEdge:" (inWindow As WindowPtr, inRecalculates As Boolean, inEdge As UInt32)
Declare Sub SetContentBorderThickness Lib "AppKit" Selector "setContentBorderThickness:forEdge:" (inWindow As WindowPtr, inBorderThickness As Single, inEdge As UInt32)
Declare Sub ContentBorderThickness Lib "AppKit" Selector "ContentBorderThicknessForEdge:" (inWindow As WindowPtr, inBorderThickness As Single, inEdge As UInt32)

//Soft Declare Sub setMovableByWindowBackground Lib "Cocoa" selector "setMovableByWindowBackground:" (windowRef As Integer, yesNo As Boolean)
'
'
'
setBackingType w.Handle, NSBackingStoreType
//setStyleMask w.Handle, NSTexturedBackgroundWindowMask Or NSTitledWindowMask Or NSClosableWindowMask Or NSMiniaturizableWindowMask Or NSResizableWindowMask
setStyleMask w.Handle, styleMask(w.Handle) Or NSTexturedBackgroundWindowMask

SetAutorecalculatesContentBorder(w,False,NSMinYEdge)
SetAutorecalculatesContentBorder(w,False,NSMaxYEdge)

if topHeight>0 then SetContentBorderThickness(w,topHeight,NSMaxYEdge) '<----set the height top]
If botHeight>0 Then SetContentBorderThickness(w,botHeight,NSMinYEdge) '<----set the height bottom


//setMovableByWindowBackground(w.handle, False)


w.Frame=0

#EndIf
#EndIf
#EndIf
END FUNCTION

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Faking the unified window look
PostPosted: Tue May 21, 2013 11:28 am 
Offline

Joined: Sun Jun 24, 2007 12:24 pm
Posts: 441
Location: Madrid
Thanks for the code. I don't think it's doing anything in Cocoa, though.

The idea was to be able to do my own window, down to the titlebar. Like the mockup below

https://www.dropbox.com/s/v6i5wiaz88ml0 ... Window.png

Image

Same for Windows and Mac, although in Windows I'd provide Windows Widgets (I'm assuming to do this I can't just modify the window title but directly recreate it, but I don't know where to start).

_________________
----
http://eduo.info/
http://gallery.eduo.info/
http://twitter.com/eduo/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group