developing multiple panels in a single view - cocoa

I'm new to cocoa development, and been trying to look for something similar in the attached image.
Basically an app with multiple views or sections or panels, where I'd link separate classes to each of them instead of one Delegate class doing everything.
I'm also confused between the old xib and the new storyboard style and wondering how can I accomplish the same, like what kind of visual objects to use. attached images explains where I'm trying to get at.

In Mac OS Cocoa it's common to just uses plain NSView objects to hierarchically subdivide complex views.
If you also want visual dividers there's NSBox. For resizable parts use NSSplitView.
Regarding the controller tier it's also pretty common to set up individual controller objects for separated panes (subviews) in a window.

You are talking about one single view. So what is possible would be to create a background view and then add multiple custom subviews (NSView subclass), each with their own custom class to control them, and even custom controllers.
As to accomplish something that looks similar to the screenshot, you can select a few UI elements in interface builder and do Embed In > Box to group them like in the screenshot.

Related

Cocoa Image Picker Popover

Several places in OS X (in this example, the Users & Groups pane in System Preferences) have circular image views that allow the user to either drag in an image, like in an editable NSImageView but also allow them to click to show a popover that allows various other choices of image sources.
I have checked the ImageKit framework, but the only thing I found similar is the image taking sheet.
How can I make use of this feature in my own Cocoa applications? I'd imagine it is implemented in some standard framework—but any pointers on implementing something like this would be quite appreciated.
You will have to go down the custom control root as this is not available as a stand alone control.
However you have all the prerequisites.
The circular image view
There a several ways to implement this. You could try using a standard Cocoa button and customise as needed. Although it might just be easier to build from scratch by subclassing NSView. This was you can avoid all the NSCell stuff. I would do the latter.
The popover
Roll your own master-details type view controller to be displayed as the popover's content. In the left have a NSTableView (the master), the right have a NSCollectionView (the details). Below the collection view add some buttons.

Xcode MVC Issue - Need a multi Model - single View

I've recently started working with Xcode, having come from a C# background. I'm struggling to implement something for OSX that I'd find fairly trivial in C#.
Basically, I want to create a model that contains, say, two points. I then want to open a window which contains a Custom View that is linked to an object that is a subclass of NSView. I then want to draw a line between those two points using the dirtyRect function of my NSView based object.
I've followed examples for this & it works fine. However, I want to be able to open a number of windows, each of the same type of view so the data is displayed using the same technique, but having each one associated with a different model.
How can I let my NSView based object know what model data it should be drawing? I assume I'm missing something stupidly simple here...
Thanks,
Tom.

In MonoTouch, is it possible to mix standard Views and iPhoneOSGameViews?

Is it possible to have like a main menu based on a let's say a DialogViewController, and navigate to a OpenGL-ES based iPhoneOSGameView ?
Yes. You can even add multiple OpenGL ES views as subviews of a standard UIView.
Though you ask about iPhoneOSGameView specifically, I recommend considering GLKView available as of iOS 5. This provides some of the same features as the iPhoneOSGameView as well as some of the generated boilerplate around animation and CADisplayLink. It would also give you the option of creating the view in the Interface Builder, should you desire. Finally, it is provided by Apple to fill a similar role and, arguably, would be more aligned with future development.
I have done the reverse. In fact, MonoGame supports opening iPhoneOSGameView as the main view and displaying standard modal view controllers over top of it. This functionality is in the GamerServices section of XNA.
I think you should create a simple example, print a solid color in the game view and try presenting it over top of a standard controller.
I would think it would work fine.

Advice needed for developing multiple window Mac application

I’ve been reading through several books on Mac development, but cannot find the information I’m looking for.
The books all describe how to make floating windows or panes, but never mention how to make them all in one window. A simplified example of what I’m looking to create is shown below:
Basically, there will be three windows; A selector window with radio buttons to choose which NSDocument is currently being used, a window underneath that with buttons that show different windows to the right that allow viewing and manipulation of certain data.
For a example, each NSDocument may have a color value that can be set in the window shown by clicking view A, and some text strings that can be set in the window shown by clicking view B.
So the questions are:
Is it appropriate to use a single NSDocument sub-class for each Doc #1 and Doc #2?
Which classes should I use to set up the application as shown? NSWindowController? NSWindow? NSPanel?
I’m only looking for guidance on what to read up on, so any pointers are appreciated.
EDIT:
To clarify this further, I want to have a table view where the buttons are (View A & B), and by clicking them they will cause the other window/view to change it's contents.
It's like the split view in the iPad settings application, there is a table view on the left, and when it's pressed the right side changes.
The radio buttons are there only to illustrate that I want more than one Document. I'm guessing I need more than one to handle this? Or perhaps I should place them all in a single NSDocument? Somehow that doesn't seem right.
To achieve what you want you need one window (NSWindow), one window controller and various views each with their own view controller. There are several ways you could set this up, all depending on your requirements:
You'd have at least 3 views (instances of NSView): one for the selection of the document class, one for the view selection and one for the content. Each view is controlled by a view controller (instance of NSViewController). Additionally you can opt to wrap the views in split views (NSSplitView) so your user can resize the real estate available to each view.
You have one window with a window controller. If you choose a Document based app template in Xcode, Xcode will generate a subclass of NSDocument which you can use as your window controller (or choose to use Core Data and Xcode will generate a subclass of NSPersistentDocument with all bells and whistles you need to access Core Data for document persistency).
So to come back to your questions:
1: Yes, but depending on your requirements. If Doc #1 is a completely different thing than Doc #2 than you might need to re-evaluate. For example Doc #1 might have completely different persistent requirements than #2.
2: There's no single scenario here, but one that worked for me: Take the project template for a document based app (with or without Core Data). Use the generated subclass of NSDocument (or NSPersistentDocument) as your window controller. Use NSView to implement the views in your window where each view is managed by its own controller, which is an instance of NSViewController.
I know this is an old question, but a way to do it how you want would be to use: ContainerViews and set their embed segue to be the view controllers you want.

Cocoa OSX custom widgets/controls

I want to know how can I create custom widgets/controls in Cocoa.
Not a full tutorial, but some guidance on what to start looking into. I'm confused by custom views, Core Animation, etc. I feel lost.
I see a lot of cool looking controls, like in Reeder App, or Sparrow etc. For example:
The left side is a collapsable menu that includes animations etc. How can I achieve something similar? I thought of using a WebView + HTML + JavaScript, but that doesn't seem like a very optimized solution.
Controls are views, so if custom views confuse you, you'll need to get that figured out before moving on to custom controls. Although you should really read the entire View Programming Guide, the section called Creating a Custom View will get you started on creating your own views. Try creating a simple view that draws a circle, for example, or the time.
When you've got views figured out, move on to custom controls. Most controls work about the same way. The user touches them, and the control responds by: a) tracking the user's input, b) changing its value, c) sending its action message to its target, and d) giving the user some feedback by redrawing itself. To get started, first make sure that you know how to use controls. Reading Control and Cell Programming Topics should help, and the section titled Subclassing NSControl covers (obviously) creating your own subclasses.
The example you provided is pretty clearly Apple's Mail.app. The view on the left side of the window might be an instance of NSOutlineView, or it might be a custom class. Either way, NSOutlineView would be a good starting point if you want to duplicate that functionality. NSOutlineView is a subclass of NSTableView, which in turn is a subclass of NSControl, which in turn is a subclass of NSView. Read Outline View Programming Topics for help getting started -- tables and outlines are extremely useful, but also more complicated to use than basic controls like buttons and text fields.
I know it's only a part of the UI, but I've recently coded something similar to the sidebar. If you look though the source-code it may give you some help on learning how to use custom controls and cells.
You can check it out on Github:
https://github.com/iluuu1994/ITSidebar

Resources