Actionscript: Position elements one after another automatically - actionscript

Is it possible to make Sprites position themselves one after another automatically.
Similar to display:display-block in CSS.
For example i'm adding Sprites to some parent in a row, the way they are in xml skin file and they are automatically position themselves next to each other.
Is there an event, which tells that a child were added to the parent?
I could implement some extended Sprite, to position pushed elements automatically, by calculating where the last element is located?
Why the hell Actionscipt doesn't have something like CSS in it? It's a pain in the ass to build UI inside it, compared to HTML...
Madness...

In case of "raw" ActionScript you should either search for an appropriate library or do it your self. ActionScript doesn't define any CSS like logic.
On the other hand Flex does, but you will not find any CSS that let you define layout. CSS is used to modify visual appearance of containers and components in Flex. Layout is usually done with the layout property of the container classes provided by Flex. For example yo can use a Group and set its layout property to an instance of HorizontalLayout or VerticalLayout. This will automatically position all child components of the group either in x or in y direction. In case of using Flex you cannot use sprites directly, but there are many components you can use. Maybe there is one for your purposes.
See the Flex API documentation. The spark.components package will be a good starting point.

Related

Creating and Rendering a Custom Container Box and Container Items in C++ Builder/FMX

I am looking into sub-classing a container component to act as a "listbox" container of sub-classed TPanels that are acting as "listitem" members. Basically, my CustomListItems are TPanels that contain some images, labels, and/or other controls. These CustomListItems will be created dynamically and will have dynamic sizes. Their widths shall be equal to that of their parent container, but their heights might differ.
I want my container "listbox" to mostly behave like a standard TListBox, in that it shall be vertically SCROLLABLE, and that the added items shall be stacked on top of each other in the most automatic way possible. For example, doing:
CustomListItem* myCustomListItem = new CustomListItem(this, param1, param2, param3); // this = TOwner
myCustomListItem->Parent = myCustomListBox;
will automatically position the added child TPanel item in the first vacant slot of its CustomListBox container.
What I am seeking is the most standard way for implementing this parent/child, container/contained relationship. I am unsure what container component to sub-class and how to go about this. I am considering two approaches:
Possibly using a TLayout, TGridLayout, or TGridPanelLayout container if it is vertically scrollable and if it will handle rendering/positioning the added child TPanels (my CustomListItems) automatically.
If there is no "easy" or "standard" way to implement the above behavior, I would maybe consider using a plain TVertScrollBox as the "listbox" container, and then custom-handle the positioning and repositioning of the added items "manually".
For the latter approach, what I need is information about which events might trigger the insertion and removal of child items, and how to handle those events properly. For example, I would keep track of added items and their positions relative to the parent container. When new items are inserted, I can then manually handle positioning them correctly in the container. I can do that "internally" by overriding/overloading (not sure) the AddObject method, but I would still need to handle certain events for "external" insertion/removal of objects (e.g: myCustomListItem->Parent = myCustomListBox;)
I hope I made my question clear enough. Any help would be highly appreciated.

Responsiveness of Vaadin FormLayout

I am starting to make my Vaadin web app responsive. Reading Vaadin docs, I managed to make a CssLayout flexible such that an image is shown either to the left of a text section or in a separate row depending on available width.
Now I want to make my login form flexible. By default, captions are moved to the left of the fields. How can I achieve that the captions are moved to the top of the fields when a certain width is reached? Is that even possible with FormLayout?
Can't really imagine that it is possible with CSS because the FormLayout is rendered as HTML table. If so, what is a simple alternative?
That is not possible with FormLayout. Structure of FormLayout is not flexible. Also there is not simple alternative for that. You can use CssLayout or create your own component container.
Starting point for this can be extending AbstractComponentContainer as described in Creating a simple component container

Embedding other widgets in a GTK+ text entry

I would like to embed another widget in one end of a GTK+ 3 text entry box, a bit like many browsers do with search or protocol security "chips":
I know I can set an icon on a text entry with
entry = Gtk.Entry()
entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, icon_name)
Even if I pass my own GdkPixbuf to set_icon_from_pixbuf this still limits me to icon sizes, when I want some arbitrary size (at least horizontally) depending on the "chip" content.
I also tried to "shunt" the text over with set_margin_left, but this moved the left edge of the whole entry box over, rather than the text within the box.
What would be an effective way to embed some other GTK+ widget (hopefully of any complexity, so I can make the chip more interactive) within a text entry?
GtkEntry is not a container, so it cannot have child widgets.
The appropriate way to implement what you see in the screenshot is to use a separate container and style it appropriately.
Have you considered putting the entry inside a frame, and restyling stuff to make it look like it was inside an entry? Then you could use standard containers to put whatever widgets next to the text entry spaces that you wanted.
The downside is that clicking your "icon" doesn't focus the entry automatically, but it makes that action totally configurable.

Deciding between NgComponent and NgDirective

Is there some rule of thumb to be followed while deciding to implement custom element as NgComponent or NgDirective?
What are the issues to keep in mind while deciding to choose either of them?
If you want to add functionality/behavior to existing tags/elements you use a directive (like ng-class or ng-hide).
You can apply a directive to different tags.
To create a new element/tag you create a component (like accordion, carousel, modal, ...).
A component is a new custom element that can have a template that defines its shadow DOM content.
You can use a directive to dynamically add/remove html content too, but with a component you can create new elements that have a clear boundary between inside and outside.
A component has it's own scope that is not part of the application scope hierarchy.
You can't easily reach inside a components content.
Html generated from a directive is like any other html tags. You have transclusion with components (I think someone is working on components without shadow DOM and transclusion like in Angular.js but I don't know how far this is and how this will look like.)
You can use directives inside a component, and a component inside a component.

AngularDart Element onResize event not linked to window

I'm working on a responsive, full-width layout and I need to do some element processing when the size changes. This has to not be linked to the window, as the size can change without the window size being modified e.g. changing number of columns.
I'm working with AngularDart directives and components and it would be nice to have a directive say, "resizable" which implements such an event for the element.
I've come across the attributeChanged() method in the Dart Element class but don't really know how to tap into that without creating custom elements.

Resources