SapphireSteel Forum
Welcome, Guest. Please login or register.
May 19, 2013, 01:11:39 AM

Login with username, password and session length
Search:     Advanced search
Welcome to the SapphireSteel forum - for discussion of the Ruby In Steel and Amethyst IDEs
3883 Posts in 799 Topics by 669 Members
Latest Member: m
* Home Help Search Login Register
+  SapphireSteel Forum
|-+  General
| |-+  Amethyst
| | |-+  Support for controlBarContent?
« previous next »
Pages: [1] Print
Author Topic: Support for controlBarContent?  (Read 1325 times)
russ
Newbie
*
Posts: 22


« on: June 03, 2011, 02:41:03 PM »

Is there a way to add controlBarContent (the Flex 4 replacement for ApplicationControlBar) to an application in design mode?

Design mode still seems to work when I add it to code mode manually.  Is there any risk doing things like this, or does design mode simply ignore tags that it doesn't support?

Small example below.

Code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application height="600" width="800"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
  <fx:Script source="Russtest1.designer.as"/>
<s:Button id="Button1" height="22" width="65" label="Button" x="161" y="90" name="Button" click="button1_click(event)"/>
<s:TextArea id="TextArea1" x="161" y="143" name="TextArea" content="12345"/>
<s:controlBarContent>
<s:Button id="Button2" height="22" width="65" label="Control bar button!"/>
<mx:ColorPicker/>
</s:controlBarContent>
</s:Application>
Logged
Dermot
Administrator
Hero Member
*****
Posts: 1005


« Reply #1 on: June 03, 2011, 04:07:33 PM »

It doesn't do any harm to do what you are doing: if the Designer doesn't know about a control, it doesn't display it. But I think we should support ControlBarContent properly in the Designer.

Most of the controls supported by the Designer are defined an a data file, and I think at the minimum, we can use that to map it into something like a Group and represent it accordingly.  You can add and change things in the database quite easily - it's XML - but we haven't documented how to do this. There is a way of modifying the XML using the Amethyst Component Manager menu item.

But I think we might be able to do better with a small amount of code in the Editor/Designer interface.

I'll get back to you once I've done a bit of experimenting.

Dermot

Logged
Huw Collingbourne
Administrator
Hero Member
*****
Posts: 933



« Reply #2 on: June 05, 2011, 11:10:14 AM »

I've just been discussing this with Dermot. As I'm the person who (mostly) programmed the Amethyst Designer, he's asked me to answer this.

The current position is that the controlBarContent component is supported for Panel but not for Application. As Dermot says, you can create it in mxml but the Designer will not display it. Let me give you a bit of technical background on why this is the case.

It turns out that controlBarContent defines, in essence, a runtime (rather than design-time) behaviour. Unlike normal containers such as Panel or Group, controlBarContent is not a UIComponent. In fact, it is not a visual control of any description. For reasons which may make sense to Adobe (but I'd have to say, don't make much sense to me), controlBarContent is defined as an Array. This array is a property of Application. The controls which it contains are objects that are inserted into the array. Behind the scenes, Flex creates a group and adds Components to it in the traditional manner. But from the end programmer's perspective, the controlBarContent  is not a group and controls cannot be added to it as 'children' or 'elements'.

Since the Amethyst Designer (the Amethyst drag-and-drop design environment) is a Flex application, it has to operate within the realms of the possible as defined by Flex. Only when it receives a real container can it add child controls to them. When, as in this case, it receives an array property, it cannot automatically do this. Flash Builder does a 'special fix' whereby it pretends that controlBarContent is a container. The downside is that Flash Builder does not work like a real Flex application. That's why, when you resize controls in Flash Builder you don't see anything happening (that is, the contents of the controls are not resized dynamically) until you stop resizing. With Amethyst, you see controls respond to each resize operation pixel by pixel. So, most of the time, Amethyst gives a more accurate 'live' representation of the design than Flash Builder. But when (as here) Adobe has broken the normal rules by hiding the container behind an array property, child controls cannot be added.

In order for us to add design-time support for controlBarContent we'd have to do a pretty horrible hack (to emulate what Flash Builder does!  Grin) that would expose the Group that is hidden behind the controlBarContent property. We've had to do few of these before - for example, to implement DataGrid columns which, once again, are non-UIComponents) and also to implement controlBarContent for Panel. The reason, by the way, that we do it for Panel but not for Application is that, as the Designer is an Application, we have to be very cautious about doing anything which would alter the fundamental behaviour of the Application (thereby changing the behaviour of the Designer).

For the time being, we propose to leave the current level of support - namely, by allowing controlBarContent to be defined in mxml code and letting the Designer silently ignore it. We'll look at this problem again at a future date, however. I'm sure we can find a way of getting around this but it wouldn't be a 'quick fix'.

Logged
russ
Newbie
*
Posts: 22


« Reply #3 on: June 07, 2011, 08:49:55 AM »

Great response... thanks!  It is definitely appreciated and educational.  The reason for replacing the ApplicationControlBar container with the weird controlBarContent property is strange to begin with...

Not having controlBarContent support for Application is not a huge loss... especially since you support Panel. 

Suggestion: I'm not sure how deep the Visual Studio hooks you have are, but it would be nice to have a "Designer status" tab that could simply show any issues that exist with a given MXML file.  For example, you could indicate that "controlBarContent detected in Application, but is not supported by the designer", or also indicate what actual components are found, but are not recognized or supported.  Although the latter list may get long for some people, I think it would be better than what is effectively a silent failure at the moment.

Since I'm thinking about it, I might as well suggest a bit more (sorry)...  Were such a suggestion possible, making the panel a sortable list/grid view with headers like "tag', "issue", "details", would be great.  eg: For controlBarContent... tag=Application, issue="controlBarContent not supported",  details="Although controlBarContent is not supported by the designer, it will still work in the compiled application.  Consider putting controlBarContent in a Panel, where it is supported by the designer."

Logged
Huw Collingbourne
Administrator
Hero Member
*****
Posts: 933



« Reply #4 on: June 07, 2011, 09:36:10 AM »

In terms of what I might call 'enhanced code analysis and reporting', I think you might be interested in something else we have in the pipeline. These tools are still in the very early stages of development at present and I don't want to go into any detail. However, suffice to say, when they are released they will address all the issues you mention and a great deal more besides!  Wink
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!