Android Scissor Bug?
Monkey Targets Forums/Android/Android Scissor Bug?
| ||
I'm writing a GUI for my Android Apps and after heavy use of scissors I noticed a bug: The GUi is based on rectangles(=gadget), which can contain other rectangles. I have a parent rectangle with 10 children rectangles and the textbox. This textbox is a outer rectangle, a inner rectangle and 20 rectangles for the text lines. There should be a lot on lines of text on the screen, but some lines are missing, when compiling to android. On the Html5 target everything works fine. This problem is caused by the scissor, which should limit the painting area to the size of the text line. If you switch off the scissor in Gadget.DrawOne() you can see all lines. For debug informations the text lines contain the borders of the the scissor, and you can see, that the values are correct and that the scissor should normaly show the text, when switched on. I reduced the testcode to the minimum, where i can still notice the bug. The bug only occurs with the other Gadgets. Reducing the amount of other rectangles also reduces the missing lines. Can anyboy please confirm the bug or tell me, that it is working fine on his mobil phone? I use Monkey 61b, apache-ant-1.8.4 and tested it on a Samsung GT-S5300 Android 2.3.6 [monkeycode]Strict Import mojo Const ON%=1,OFF%=0 Const TEXT_FIELD%=1 Global Debug$, DebugCount%,MausIn% Class Duett Extends App Method OnCreate%() Gadget.XRatio=DeviceWidth()/480.0 Gadget.YRatio=DeviceHeight()/320.0 ' id, x, y, b, h, Typ, Parent-ID Gadget.Create 1,0,0,480,320,3,0,"" ' Mutter aller Fenster Gadget.Create 6,5,265, 230,44,0,1, "" Gadget.Create 7,85,205, 70,44,0,1,"" Gadget.Create 8,5,205, 70,44,0,1,"" Gadget.Create 9,385,130, 80,44,0,1,"" Gadget.Create 15,165,205, 70,44,0,1,"" Gadget.Create 10,5,130,358,40,3,1,"" Gadget.Create 11,-440,3,900,34,3,10,"" Gadget.Create 12,0,3,470,14,4,11,"" Gadget.Create 13,470,3,440,14,3,11,"" Gadget.Create 14,245,180,225,133,0,1,"" Gadget.Create 20,10,10,460,300,5,1,"" TextBox.Creates 21,0,0,460,400,5,20,"" SetUpdateRate 15 Return 0 End Method OnUpdate%() If KeyHit(KEY_ESCAPE) Then Error "" Endif Return 0 End Method OnRender%() Gadget.Draw Return 0 End End Function Main%() New Duett New TextBox Return 0 End Class Gadget Global Liste: List <Gadget>= New List <Gadget> Global XRatio#=1,YRatio#=1 Field Id%,X#,Y#,B#,H#,Typ%,Text$ Field Parent:Gadget, Visible%, InnerScale#=1 Field Children:List<Gadget>= New List <Gadget> Function Create%(Id%,X%,Y%,B%,H%,Typ%,ElternID%,Text$="") Local loc:Gadget=New Gadget() loc.Id=Id loc.X=X loc.Y=Y loc.B=B loc.H=H loc.Typ=Typ loc.Text=Text loc.Visible=True If ElternID>0 loc.Parent=Gadget(ElternID) loc.Parent.Children.AddLast loc Else loc.Parent=Null Endif Liste.AddLast loc Return 0 End Function Gadget:Gadget(Id%) For Local loc:Gadget = Eachin Liste If Id=loc.Id Then Return loc Next Return Null End Function Draw%() Scale XRatio,YRatio Liste.First().DrawOne 0,0,0,0,999,999,1 SetScissor 0,0,DeviceWidth(),DeviceHeight() Return 0 End Function Method DrawOne%(offX%,offY%,sX%,sY%,sX2%,sY2%,faktor#) Local v%=sY2 If Visible=False Then Return 0 offX=offX+X*faktor offY=offY+Y*faktor If offX>sX Then sX=offX If offY>sY Then sY=offY If offX+B*faktor<sX2 Then sX2=offX+B*faktor If offY+H*faktor<sY2 Then sY2=offY+H*faktor ' '************************************** SetScissor Int(sX*XRatio) , Int(sY*YRatio) , Int((sX2-sX)*XRatio) , Int((sY2-sY)*YRatio) '**************************************** SetFarbe 100+Typ*10 DrawRect X, Y,B,H SetFarbe 103+Typ*10 If Text<>"" Local T$ T="sX="+sX + " sY="+sY + " sB="+Int((sX2-sX)*XRatio)+ " sH="+Int((sY2-sY)*YRatio) DrawGadgetText T, X+5, Y+2,0 Endif PushMatrix Translate X+2,Y+2 Scale InnerScale,InnerScale faktor=faktor*InnerScale For Local loc:Gadget = Eachin Children loc.DrawOne (offX+2, offY+2, sX+2, sY+2, sX2-2, sY2-2, faktor) Next PopMatrix Return 0 End Method DrawGadgetText:Void(T$,X%,Y%,Style%) PushMatrix() Translate X,Y DrawText T, 0, 0,Style PopMatrix() End Function Check%() Return 0 End End Function SetFarbe:Void(FarbTon%) Select FarbTon Case 150 SetColor 1,1,1 Case 151 SetColor 1,1,1 Case 152 SetColor 250,50,70 Case 153 SetColor 222,222,222 Default SetColor 0,111,0 End Select End Function Class TextBox Extends Gadget Function Creates:Void(Id%,X%,Y%,B%,H%,Typ%,Parent_ID%,Text$) Local i%,Lang%,Zeile$, ZeileH%,Breite% Create Id,X,Y,B,H,Typ,Parent_ID,"" ZeileH=40 Breite=B-4 For i=1 To 20 Create Id*100+i,X,Y+i*ZeileH,Breite,ZeileH+2,5,Id,"Zeile " + i Next End End[/monkeycode] |
| ||
Hi, I'm getting identical results on Android/html5/XNA - 7 lines of text with a green border. The last 2 numbers on each line are different, I assume because it's to do with scaling. With SetScissor commented out, same thing only the bottom edge of the border is missing, and there's an extra border pixel or 3 at the top right. Again, looks the same to me on all targets. |
| ||
upps.... thanks you for this quick answer,... You can see all 7 lines? So it is a problem of my Android version or mobile? Which version do you use? I forgot to tell, that I set the orientation to "landscape", the resolution of the display is 320x240 and so the YRatio% and YRatio% = 0.667. To the text content: the text line only can differ in value "sY=..." . This is the scissor y-value for that line. the other values have to be the same in each line. only the 7th could be a little different, because the bottom of the display reduces the scissors height "sH=....". Could you please move this forum thread to "Android", that some more coders will test this behavior on different mobiles? thank you |