B4A Class AnalogWheel

Unlike the Horizontal wheel (see WheelView class) , this wheel is analog - it can set or get any value in the range of the wheel, not just the labels.
It can be designed in the designer as custom view, or added by code.
In the case of code you have to call CodeCreationView after the initialization.
The "natural" range is 0-100 but you can set any range by setting the start and end points.
These point are parameters in CodeCreationView, in the designer put them in "Text" separated by comma.
The Methods are simple and there is a _Roll event which pass the wheel value to the calling module.
In the demo, WC1 is the upper wheel designed by code, the second wheel is by the designer. On WC2 I put a panel which does not belong to the class, just to demonstrate a possibility for the look of the wheel.

Edit: VAnalogWheel added, the same thing but vertically. The name of the Horizontal Analog Wheel is changed to HAnalogWheel

Edit:
an updated version 2 uses api 23+ with resumable subs. There is a memory problem, depends on the resolution of the device. In 1080x1920 the max width is about 59%x.
For the vertical analog wheel the max height is 40%y.
 

Attachments

  • screen.png
    screen.png
    53.7 KB · Views: 835
  • screen.png
    screen.png
    23.3 KB · Views: 756
  • HAnalogWheel2.zip
    15.9 KB · Views: 131
  • VAnalogWheel2.zip
    13.6 KB · Views: 118
Last edited:

hzchrisfang

Member
Licensed User
Hi derez, If I have a Numerical range of the cycle, for example, the orientation number range loops in 0-359, this means when current value of wheel is 0, it will show 359 on the left position if I continue to scroll the wheel from left to right. How can I create this effect?
 

derez

Expert
Licensed User
if I continue to scroll the wheel from left to right.
I'm not sure if this is what you want but if I declare
B4X:
Private flag As Int = 0
in class globals and modify to the following code I get change of the wheel from zero to max by scrolling left, max to zero when scrolling right.
The flag should eliminate continuous jump between the states.
Try it in the HAnalogWheel class.

B4X:
Private Sub sv_ScrollChanged(Position As Int)
newposition = Position
If Position = 100*WWidth/104 AND flag <> 1 Then
    sv.FullScroll(False)
    flag = -1
Else If Position = 0 AND flag <> -1 Then
    sv.FullScroll(True)
    flag = 1
Else
    flag = 0
End If
tmr.Enabled = True
End Sub
In the vertical it will probably be the same after replacing WWidth with WHeight
 

hzchrisfang

Member
Licensed User
I'm not sure if this is what you want but if I declare
B4X:
Private flag As Int = 0
in class globals and modify to the following code I get change of the wheel from zero to max by scrolling left, max to zero when scrolling right.
The flag should eliminate continuous jump between the states.
Try it in the HAnalogWheel class.

B4X:
Private Sub sv_ScrollChanged(Position As Int)
newposition = Position
If Position = 100*WWidth/104 AND flag <> 1 Then
    sv.FullScroll(False)
    flag = -1
Else If Position = 0 AND flag <> -1 Then
    sv.FullScroll(True)
    flag = 1
Else
    flag = 0
End If
tmr.Enabled = True
End Sub
In the vertical it will probably be the same after replacing WWidth with WHeight

Lots of thanks! That's exactly what I needed.
 

hzchrisfang

Member
Licensed User
derez, I have another problem. When I add <android:targetSdkVersion="14"> into manifest file, the scale on the label disappeared. I can't find which code in your class cause this problem.
 

derez

Expert
Licensed User
This issue is not related to the class, I guess you run the app on version 5 which has some "interesting" display features (=problems).
The solution is not to add this line to the manifest, or to check the forum for other solutions (read "material design" first).
 

hzchrisfang

Member
Licensed User
This issue is not related to the class, I guess you run the app on version 5 which has some "interesting" display features (=problems).
The solution is not to add this line to the manifest, or to check the forum for other solutions (read "material design" first).

I think I found the reason: the size of ScrollView(size of canvas). If we set the WWidth large enough, for example set WWidth = 300 * Wwheelstep (different device has different tipping point) , the scale on the label will disappear, no warning information display just like 'out of memory'. IF we add <android:targetSdkVersion="14"> into manifest file will reduce the tipping point.
 

derez

Expert
Licensed User
I see it but can't explain. What are the advantages with the added line <android:targetSdkVersion="14"> ?
 

derez

Expert
Licensed User
Version 2 is uploaded to the first post, using resumeable subs and API 23+. I have found a problem which is probably due to memory size. Because of the width/length of the canvas the max width of the H View is limited to 59%X and the max height of the vertical wheel is limited to 40%Y.
 
Top