[XUI] B4XView and B4XLabel, B4XPanel, B4XEditText

Star-Dust

Expert
Licensed User
Longtime User
Coming soon

Since I'm focusing on XUI now I'm trying to create an XUI library that allows you to create views (panel label, edittext) directly from code and design (CustomView) avoiding the double passage
B4X:
 Private Label1 as Label
Label1.Initialize("Label1")
Dim B4XLabel1 as B4XView = Label1
But doing so directly
B4X:
 Private B4XLabel1 as B4XLabel
B4XLabel1.Initialize(Me,"B4XLabel1")
Also being able to create various views from design.

They will also be implementing all properties, methods and even all view events. Making the creation of uniform views on all platforms and not rewriting the code but re-using it internally on all B4X platforms
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
first images of new XUI objects, with relative prorpietà and perfectly functioning Events like the native ones


 

Attachments

  • upload_2018-5-3_12-49-42.png
    302.5 KB · Views: 377
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
One of the concepts behind B4XView is that any view can be a B4XView. You don't really need a B4XEditText and B4XLabel views. You just add the regular views with the designer and change their type to B4XView.

B4XView itself includes many properties and methods specific to some views: https://www.b4x.com/android/help/xui.html#b4xview
 

Star-Dust

Expert
Licensed User
Longtime User
This is true, but in design or code I have to create native views and then declare B4XView variables and assign native views.

I want to do everything in one step, get the B4XLabel views in the design. Another advantage of this library I'm creating is to have uniform events for all platforms, like the touche or mouse event. The code would be totally reusable. All without having to use #IF B4A or #IF B4J

Finally I would like to add all the basic views, already you have created ListView, Spinner, ChexkBox for my same reason.
I would add also Grid, ScrollView, etc. ..
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have to create native views and then declare B4XView variables and assign native views.
No. You can directly change the views types to B4XView.

B4X:
Sub Globals
   Private EditText1 As B4XView
   Private Label1 As B4XView
   Private ScrollView1 As B4XView
End Sub

In the future you will be able to generate B4XView directly from the designer. However even without it, it is very simple to switch to B4XView.

See step #2 in the tutorial: https://www.b4x.com/android/forum/threads/b4x-xui-cross-platform-native-ui-library.84359/#content
 

Star-Dust

Expert
Licensed User
Longtime User
I did not know this, only then the question of events and design would be missing

Now only the question remains this future, in which we could have Design, how far it is
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
What I want to get is this

B4X:
Dim Label1 as B4XLabel
Dim EditText1 as B4XEditText

Label1.Initialize(me,"Label1")
EditText1.Initialize(me,"EditText1")

Sub Label1_Click
End Sub

Sub Label1_LongClick
End Sub

Sub Label1_DoubleClick
End Sub

Sub Label1_Touch(action as int, Coordinate as Tcoordinate)
End Sub

Sub EditText1_TextChanged(Old as String, New as String)
End Sub

Now this is not possible with just the XUI library.
I'm getting it with my class
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
"In the future you will be able to generate B4XView directly from the designer."

Do you remember when, for b4j, was not available the "internal designer" and you had only the Scene Builder? Bad times

"Tomorrow" we will have a single Designer, I'm pretty sure.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
"In the future you will be able to generate B4XView directly from the designer."
To avoid confusion you can already build the layout with the designer. You just need to change the generated line from:
B4X:
Private EditText1 As EditText
To:
B4X:
Private EditText1 As B4XView

"Tomorrow" we will have a single Designer, I'm pretty sure.
Don't be too sure that a single designer will be an improvement. It sounds nice and can be nice in small examples. However a desktop app shouldn't look like a mobile app, and there are also expected differences between Android and iOS apps.

Now this is not possible with just the XUI library.
Many of the events are already the same and more events will be added as needed. For example Button Click event was added to B4J (instead of Action) and Touch event will be added in the next version to B4J Panes.

As I wrote in the tutorial about XUI, it doesn't try to replace the native views. It completes them. It is very simple to switch back and forth between B4XView and the native views.
There is nothing bad with using conditional compilation as long as the main logic can be shared. The upside is that you are not limited to the least common denominator features.
 

Star-Dust

Expert
Licensed User
Longtime User
Thanks for the explanation and I agree that it does not have to replace the native views but as I wrote above the purpose is to make code writing on the different platforms uniform.

I am pleased to know that in the future there will be the possibility to design the B4X Views in the design and that the events will be uniform. It means that I arrived first I joke
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't know what this code is doing however you can change the text color like this:
B4X:
View.TextColor = Color
It works on all three platforms.

Anyway, I think that my points are clear. You can of course continue to build any framework or library or solution that you like. I just wanted to explain the existing features and the concepts behind them.
 

Star-Dust

Expert
Licensed User
Longtime User
It is already possible now...
Excuse me I understood another thing, thanks for all the explanations.

Probably I will continue to develop the library but thanks to your observations I will developer to another direction
 
Last edited:

klaus

Expert
Licensed User
Longtime User
The image in post#12 from LucasMs comes from the xChart Class.
It set variables for text colors as properties which are used with a Canvas.
For these properties, the user enters native colors, like for any other view / node, which means Color as Int in B4A and B4i and Color As Paint for B4J.
The conversion is done in the class code.
I know that I could ask the user to enter xui.Colors and then there would be no conditional code in the class.
But, for now, I wanted properties behave like the other properties in the different products.
This may evolve in the future.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…