User Interface on Top Rajawali Surface View - rajawali

Anyone who knows how to add User Inteface on top of Rajawali Surface View?
I check the rajawali documentation but it doesn't work

The following approach worked for me: Create your UI elements that you want to add to your layout, I used a ConstraintLayout as a container. Do not create the SurfaceView by xml, but instead programmatically. Create it in a way that it will overlap all other UI elements and that it uses all available space. By this, the UI elements are still visible even though technically they should be hidden by the SurfaceView which is in front.
Below is my code how I setup the SurfaceView. Note that constraintLayout is the name of the container layout that has other buttons in it as well.
surfaceView = new SurfaceView(getContext());
surfaceView.setFrameRate(30.0);
surfaceView.setRenderMode(ISurface.RENDERMODE_WHEN_DIRTY);
surfaceView.setSurfaceRenderer(YOUR_RENDERER);
surfaceView.setLayoutParams(new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_CONSTRAINT, ConstraintLayout.LayoutParams.MATCH_CONSTRAINT));
surfaceView.setId(View.generateViewId());
constraintLayout.addView(surfaceView, 0);
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(constraintLayout);
constraintSet.connect(surfaceView.getId(), ConstraintSet.LEFT, ConstraintSet.PARENT_ID, ConstraintSet.LEFT);
constraintSet.connect(surfaceView.getId(), ConstraintSet.RIGHT, ConstraintSet.PARENT_ID, ConstraintSet.RIGHT);
constraintSet.connect(surfaceView.getId(), ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM);
constraintSet.connect(surfaceView.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
constraintSet.applyTo(constraintLayout);

Related

Drag/marquee selection inside custom maya UI

Is there a way to select several buttons inside a formLayout (or any other layout) with a drag selection?
Like how you would do with maya objects in viewport, but inside a custom MEL UI
i know you can use getModifiers to know if Shift is pressed to not and thus mimick shift selection etc
but drag/marquee selection seems, very hard, to replicate...
I don't think you can use Maya's standard interface objects to achieve that, but yes, you can absolutely do it with PySide in Python.
Check out examples for QtWidgets.QGraphicsView and QtWidgets.QGraphicsScene. Their framework is setup so that you can create items inside their view, and be able to select multiple with a marquee. They can also support moving via dragging the items, so you can even go as far as having a body picker creator without having to hard-code it. You could even be fancy as to create path items with beziers handles (like Photoshop) so that the user can create their own custom shapes, though you would have to manually make that framework.

How to put shapes (oval, rectangle, line) in VisualBasic tableLayoutPanel?

Sounds like a silly problem, but whenever I drag an oval to the table, an error pops out: "Cannot create component of type 'Shape' in container of type 'TableLayoutPanel'. Is there a way I can work around this?
The Shape classes require a container, an instance of the ShapeContainer class, pretty invisible when you use the designer to drop shapes on a form. Technically you can find it back from the control selector combobox at the top of the Properties window, the default name is "shapeContainer1" and has no properties at all. The surface of this container class is used to draw the shapes.
All of this is done completely automatically with a custom designer, it ensures that the ShapeContainer instance is created when you drag a shape from the toolbox onto the form. Problem is, this designer isn't quite smart enough to deal with the TableLayoutPanel class. What it should do is create a ShapeContainer that can be embedded in a cell of the TLP, it doesn't. Instead it just gives up and displays the message box. Or to put it another way, you are seeing the Microsoft programmer having given up on making this work. It is not very simple to do correctly, pretty hard to get rid of those otherwise invisible containers again.
Only workaround you have is to write the code yourself. You do so in the constructor of the form. A simple example that puts a LineShape in the upper/left table cell:
public Form1() {
InitializeComponent();
var line = new Microsoft.VisualBasic.PowerPacks.LineShape() {
X1 = 0, Y1 = 0, X2 = 50, Y2 = 20
};
var container = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
container.Shapes.Add(line);
container.Size = new System.Drawing.Size(50, 20);
tableLayoutPanel1.Controls.Add(container, 0, 0);
}
I know this is an old thread... but for the sake of someone who might be looking into an easier option in the future this is the solution I found:
Insert a Panel inside of your TablePanelLayout where you want to place a shape and VisualStudio should allow you to place the shape inside the newly created panel.
Good luck.

How to fix overlapping objects on the stage in AS3

I have a flash game where I have a picture designed to be the textbox for a prompt and textbox inside with the relevant text but the textbox is being hidden by the image. Anyone know how to make is so that the textbox is guaranteed to be on top or whatever I need to do to keep this from happening?
The other answer using setChildIndex will definitely work, however, I think a different design approach is really what you should be doing to remove the headache altogether.
For example in a game I might have different layers such as :
backgroundLayer
gameLayer
interfaceLayer
Those 3 Sprite layers would get added to the stage in that order. I would then add display objects to the appropriate layers. So anything I added to the backgroundLayer or gameLayer would ALWAYS be 'behind' my user interface on the interfaceLayer.
That allows you to not have to worry about the layering constantly. The answer with setChildIndex will fix the problem for that moment, but should something else be added to the container it will overlap your textbox, which is something I don't assume you want.
here's an example :
var backgroundLayer:Sprite = new Sprite;
var gameLayer:Sprite = new Sprite;
var interfaceLayer:Sprite = new Sprite;
addChild(backgroundLayer);
addChild(gameLayer);
addChild(interfaceLayer);
now, whatever you add to interfaceLayer, will ALWAYS be on top of objects you add to gameLayer or backgroundLayer.
So in the case of your text box, just add it to your interfaceLayer and any other objects you want behind it, you add to the gameLayer or backgroundLayer.
The order of adding display objects to display object containers effect their z-order, in other words the front to back order. The last added display object becomes the frontmost. So the child index of the children of a display object container is important for drawing of overlapped children.
If you put picture and text on the same DisplayObjectContainer such as a MovieClip:
Lets say your DisplayObjectContainer is mc.
And your textbox is txt
Please try this:
mc.setChildIndex(txt, mc.numChildren-1);

Adding several nodes as TabPane content

I am currently trying to add some content to a tabPane with the method:
tab.setContent(label, combobox);
Sadly this method only allows me to add 1 component to my tab so how do I work around this limitation? Do I need to create a new class and add that stage as a component or is there another way?
Update:
I'm sorry my original question was not clear enough here is a brief explanation:
So I've created my GUI in JavaFx Scene builder and i have created a tabPane where i have three different tabs. All of which needs to contain different things now depending on which button you click on in my GUI i want to change the content of the tabs therefore i need to write the code my self my.
My problem is that i want to add components to my tab manually yet i am unable to because the tab.setContent method allows me to only add 1 component! also i am unable to set the component where i want it to be it kinda stays in the top left corner!
Use any layout manager as content:
FlowPane pane = new FlowPane();
pane.getChildren().addAll(new Label("Hello"), new Label(", world"));
tab.setContent(pane);

How to place a windowless control on top of a windows control?

Say, I have an Image control (which seems to be a window-less control) and I want to make sure that it is on top of a TextBox. No matter what I do, the Image control will not appear on top of the Text box.
Is there a way?
P.S. I know I can use a PictureBox, but it does not support transparency, thus I must have the Image control.
There is no way to place an image control over a normal textbox as they are drawn onto the form itself so will always be below any other windowed components.
If you have VB6 installation media there are drawn (windowless) versions of controls including a TextBox you can use that will (probably) do what you want; http://support.microsoft.com/kb/184687
A custom usercontrol of some kind if probably better .. what is it exactly you want to overlay the textbox with?
The Image Control is considered a graphical control, like shapes, so it is always inferior to text controls. If you really want a transparent image, you can use a Microsoft 2.0 Form instead(only if you have it). Images there can be on top of textboxes, and you can make it transparent by setting the Backstyle to Transparent(0).
Completely different approach to my other answer (hence the seperate Answer), but you can set AutRedraw and ClipControls on your Form to false and it will allow the Image control to render on the same layer as a windowed control. You can get some flakey redrawing in some cases but for a quick solution you could try it.
http://msdn.microsoft.com/en-us/library/aa733621(v=vs.60)
I've created a tranparent overlay control to add a kind of annotation layer on top of a VB6 app. I'll attempt to describe it from memory, and if that doesn't provide enough information then you can post back and I'll try to dig up the code.
First, add a new USerControl to you application. Give it a name like ImageEx, PictureEx, or TransparntImage. There are several properties that you will need to use. Ensure the control is Windowed, so it can sit on top of other windowed controls. Locate the MaskColor property and set it to Cyan (or whatever color you elect to use to indicate a tranparent area. There might be an addition property enable the masking behavior, just browse the properties. Set the control background color to that of the MaskColor. At this point you have an invisible control. In my control I painted on top of the surface for annotations, but you can PaintPicture or maybe even set the image property for a really simple approach.
Of course, to make this a re-usable control, you will want to code in your own properties that allow the MaskColor and image, etc to be set so that you can the drop one of these on any form you want.
Some links:
MaskColor Property
MackPicture Property
1) Remove all your textboxes , labels and ... (But memorize their name and location in the form)
2) Go to (project > components) and mark the (Microsoft Forms 2.0 Object Library) then click ok
3) Now you can see new controls under your default controls in your toolbox...
4) Use its textbox and label controls instead of the default controls
5) Right click on your Image Control then click (Bring To Front)

Resources