Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:31 03 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : GUI screen pack pure MMBasic

     Page 3 of 4    
Author Message
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:55am 06 Apr 2021
Copy link to clipboard 
Print this post

  CaptainBoing said  Thanks Steve.

I have updated the code to provide your cursor controls inside the slider touch processor.

Can't see that the checkbox needs any tweaking? Could you grab a closeup on the CMM2?

F4 LCD Panel:


Sure thing Captain. Here is a screen grab showing the correct checked boxes and incorrect unchecked state, where you can see the small white square is not centered in the frame. Adding +2 to the x,y values inside Case 3 of GuiObjDraw fixes this on my CMM2. Maybe I futzed around and broke this at some point. I no longer have a 'virgin' copy of the code I originally downloaded and with the updates on the Wiki page changing between some lines combined by using colons and then not...it's more difficult to compare from one version to the next to see what's changed....not to mention my own 'CMM2' customizations! I'm pretty sure it was this way when I first got this to run on my machine....but...memory is a funny thing...

Steve

 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 02:27pm 06 Apr 2021
Copy link to clipboard 
Print this post

yes the code that was "released" standardized the function names etc and I colon-ised some of the lines with common task i.e. drawing boxes etc. to save a little bit of space - it's not a problem for big boys toys but most of my work is on the minuscule '170 with just 60K of precious program space.

I have just notice something else with the CMM2 GUI Bitmap work-a-like, the tick in the disabled checkbox should be grey (same as the writing). The colour is switched appropriately in GUIObjDraw.

On the subject of the grey box, yes I can see clearly it is shifted up and left. I think the CMM2 switch in GUI bitmap needs investigating - if the bitmap is right for the tick, but wrong for the grey box,  co-ordinates are co-ordinates.

The GUI Bitmap (native to non CMM2 MMBasic) does the positioning correctly:



so the mis-location must be in the emulation but why only for the blanking effect?



the native version (below that) does indeed use the +2 offset as you mentioned and as is shown in the close-up

EDIT: I am going to move the two Local defs inside the IF to streamline and save some RAM - only going to matter of the micromite and functionally the same... so...
Edited 2021-04-07 03:47 by CaptainBoing
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 09:09pm 06 Apr 2021
Copy link to clipboard 
Print this post

  CaptainBoing said  yes the code that was "released" standardized the function names etc and I colon-ised some of the lines with common task i.e. drawing boxes etc. to save a little bit of space - it's not a problem for big boys toys but most of my work is on the minuscule '170 with just 60K of precious program space.

I have just notice something else with the CMM2 GUI Bitmap work-a-like, the tick in the disabled checkbox should be grey (same as the writing). The colour is switched appropriately in GUIObjDraw.

On the subject of the grey box, yes I can see clearly it is shifted up and left. I think the CMM2 switch in GUI bitmap needs investigating - if the bitmap is right for the tick, but wrong for the grey box,  co-ordinates are co-ordinates.

The GUI Bitmap (native to non CMM2 MMBasic) does the positioning correctly:



so the mis-location must be in the emulation but why only for the blanking effect?



the native version (below that) does indeed use the +2 offset as you mentioned and as is shown in the close-up

EDIT: I am going to move the two Local defs inside the IF to streamline and save some RAM - only going to matter of the micromite and functionally the same... so...


If you want what I would call the background of the checkbox to be grey, then change
dc=&hffffff in GUI_bitmap to dc=&hdddddd. That being done, it looks like there is 1 bit/pixel that remains white when checked....only noticeable if you put your nose up to the screen. I have no idea how to figure that one out!

Steve
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 10:24pm 06 Apr 2021
Copy link to clipboard 
Print this post

Running the current version V0.64 on a CMM2 I get



CMM2 doesn't have BACKLIGHT so I moved that line into the SELECT CASE block.
Case Else
   Backlight 80' 100 is off
End Select


The checkbox offsets are obvious so I removed the +2 from the GUI BITMAP lines and re-inserted them in the main loop where you call gui_bitmap. That way both methods have the same offset.

Next issue is the not-grey in the disabled tickbox.
This was fixed in the gui_bitmap sub
(if you don't specify a colour, the already set colour is sued, which is what we want)
For dx=0 To 7 : if Val(Mid$(cbin$,dy*8+dx+1,1)) then pixel x+dx,y+7-dy


The full GUI_bitmap sub:
Sub GUI_bitmap x As Integer, y As Integer, o As Integer
If CMM2 Then
Local Integer dx,dy
Local cbin$=bin$(o,64)
GUI Cursor Hide
For dy=0 To 7
For dx=0 To 7 : if Val(Mid$(cbin$,dy*8+dx+1,1)) then pixel x+dx,y+7-dy
Next dx,dy
GUI Cursor Show
Else
GUI Bitmap x,y,o
EndIf
End Sub


Result:



One issue I have. The tickbox can get the tick added with a click but it cannot get removed.

Jim
VK7JH
MMedit   MMBasic Help
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 09:43am 07 Apr 2021
Copy link to clipboard 
Print this post

Nice work Jim.

With regards the tick removal, if I understand you right, the tick doesn't get erased(?).

if o=0 you could simply draw a filled box in CGy to erase the tick, so...


If CMM2 Then
If o then
 Local Integer dx,dy
 Local cbin$=bin$(o,64)
 GUI Cursor Hide
 For dy=0 To 7
 For dx=0 To 7 : if Val(Mid$(cbin$,dy*8+dx+1,1)) then pixel x+dx,y+7-dy
 Next dx,dy
 GUI Cursor Show
Else
 Box x+1,y+1,10,10,CGy,CGy
EndIf
Else


Not exactly an emulation of GUI BitMap but should work (and fast too)

... or I could have entirely missed the point

the other way is to plot the pixel no matter what and use CGy for 0 pixels... again not a pure emulation but should erase the tick the sme way as it gets drawn.

All of the above is speculation as i can't test
Edited 2021-04-07 20:17 by CaptainBoing
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:41am 07 Apr 2021
Copy link to clipboard 
Print this post

In addition to TassyJim's mod to GUIbitmap sub, if you add a variable for color in GuiObjDraw and add the bitmap argument for both cases, adding the grey color for the unchecked state, the checkbox case like so:

   Case 3'checkbox
         If o(1,n,2) And 8 Then'visible
           Colour 0
           Line x,y,x,y+11'|
           Line x,y,x+11,y'-
           Colour &hffffff
           Line x+11,y,x+11,y+11'|
           Line x,y+11,x,y+11'_
           If o(1,n,2) And 4 Then'Enabled
             c = 0
           Else'ghosted
             c = &h999999            
           EndIf
           If o(1,n,2) And 32 Then'checked
             color c
             GUI_bitmap x+2,y+2,&h18386C6CC6020301
           Else
             COLOR &hdddddd
             GUI_bitmap x+2,y+2,&h18386C6CC6020301
           EndIf
           Text x+15,y+(h/2)-(FONTHEIGHT()/2),Ot(n),,,,c,cGy
         Else'disappear
           GUIObjCleanup n,1
         EndIf


gives you the desired result I think....for the CMM2 at least!

Steve
Edited 2021-04-07 20:53 by yock1960
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 02:01pm 07 Apr 2021
Copy link to clipboard 
Print this post

nope.

GuiObjDraw takes the attributes of the object as appropriate. this is starting to throw the baby out with the bathwater. A colour argument would be redundant on most objects.

Like I suggested earlier, perhaps you should fork the article and produce a specific CMM2 version - you suggested going to a three dimensional O() which is a big change... big enough for it's own version.  

You need to remember; the platform you are working on has few limits. Its many advantages could make for a much better experience if it were set free from having to be "backward" compatible.
Edited 2021-04-08 00:03 by CaptainBoing
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 09:19pm 07 Apr 2021
Copy link to clipboard 
Print this post

I went with:
SUB GUI_bitmap x AS INTEGER, y AS INTEGER, o AS INTEGER
 IF CMM2 THEN
   LOCAL INTEGER dx,dy
   LOCAL cbin$=BIN$(o,64)
   GUI CURSOR HIDE
   FOR dy=0 TO 7
     FOR dx=0 TO 7
       IF VAL(MID$(cbin$,dy*8+dx+1,1)) THEN
         PIXEL x+dx,y+7-dy
       ELSE
         PIXEL x+dx,y+7-dy,CGy
       ENDIF
   NEXT dx,dy
   GUI CURSOR SHOW
 ELSE
   GUI BITMAP x,y,o
 ENDIF
END SUB


Trying to cater for both results in inflated code so there has to be an easy way to remove the CMM2 sections.
While the compatibility functions are minimal and grouped together, that is quick to do.

Jim
VK7JH
MMedit   MMBasic Help
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 12:44am 08 Apr 2021
Copy link to clipboard 
Print this post

  TassyJim said  I went with:
SUB GUI_bitmap x AS INTEGER, y AS INTEGER, o AS INTEGER
 IF CMM2 THEN
   LOCAL INTEGER dx,dy
   LOCAL cbin$=BIN$(o,64)
   GUI CURSOR HIDE
   FOR dy=0 TO 7
     FOR dx=0 TO 7
       IF VAL(MID$(cbin$,dy*8+dx+1,1)) THEN
         PIXEL x+dx,y+7-dy
       ELSE
         PIXEL x+dx,y+7-dy,CGy
       ENDIF
   NEXT dx,dy
   GUI CURSOR SHOW
 ELSE
   GUI BITMAP x,y,o
 ENDIF
END SUB


Trying to cater for both results in inflated code so there has to be an easy way to remove the CMM2 sections.
While the compatibility functions are minimal and grouped together, that is quick to do.

Jim


Works for me! I've incorporated it into my bastard.  

Steve
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 06:41am 08 Apr 2021
Copy link to clipboard 
Print this post

... as shall I in mine  

small point, it should be GUI BITMAP x+2,y+2,o - see the closeup pic further up this thread
Edited 2021-04-08 18:30 by CaptainBoing
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 08:25am 08 Apr 2021
Copy link to clipboard 
Print this post

GUI BITMAP was originally removed from the CMM2 to save a command slot and also because there was no evidence that anyone had ever used it in any of the other MMbasic implementations. However, since it is now in use and since the CMM2 is now using the GUI command (GUI CURSOR) I will put it back. You can download CMM2 V5.07.00b26 from the usual place. This has GUI BITMAP with the normal (same as F4/MM2) syntax. The code is untested but is a simple cut and paste so should be OK
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 08:31am 08 Apr 2021
Copy link to clipboard 
Print this post

sorry about that

When the interested CMM2 peeps are updated, there is a tweaked version (0.66) here  which saves 385 bytes - considerable if you only have 60K to start with. Thanks Peter.

cheers

EDIT: V0.68... small improvement: supports coloured buttons. For backwards compatibility, GUIObjDef checks to see if you have specified zero for both colours and takes remedial steps. This also means shorter code if you only want conventional buttons.


Edited 2021-04-09 03:15 by CaptainBoing
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 09:41pm 08 Apr 2021
Copy link to clipboard 
Print this post

I haven't tried the V0.68 yet but can confirm that GUI BITMAP works on the CMM2
You do need to hide the cursor before placing the bitmap so my sub now looks like this:
SUB GUI_bitmap x AS INTEGER, y AS INTEGER, o AS INTEGER
 IF CMM2 THEN GUI CURSOR HIDE
   GUI BITMAP x,y,o
 IF CMM2 THEN GUI CURSOR SHOW
END SUB


Not the only way to write it but the one that takes up the minimum lines

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 09:47pm 08 Apr 2021
Copy link to clipboard 
Print this post

  Quote  You do need to hide the cursor before placing the bitmap so my sub now looks like this:


I'll can fix that, forgot to include the code that hides and restores the cursor

Try


CMM2V1.5.zip
Edited 2021-04-09 07:56 by matherp
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:00pm 08 Apr 2021
Copy link to clipboard 
Print this post

  TassyJim said  I haven't tried the V0.68 yet but can confirm that GUI BITMAP works on the CMM2
You do need to hide the cursor before placing the bitmap so my sub now looks like this:
SUB GUI_bitmap x AS INTEGER, y AS INTEGER, o AS INTEGER
 IF CMM2 THEN GUI CURSOR HIDE
   GUI BITMAP x,y,o
 IF CMM2 THEN GUI CURSOR SHOW
END SUB


Not the only way to write it but the one that takes up the minimum lines

Jim


Good catch! I missed it.  

Steve
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5911
Posted: 10:36pm 08 Apr 2021
Copy link to clipboard 
Print this post

Peter's latest update fixes the GUI BITMAP so we don't need the gui_bitmap SUB at all.

The only change I made to the V0.68 is
 Select Case MM.Device$
   Case "Colour Maximite 2"
     mp=MM.info(Option Mouse) ' mouse port
     CMM2=1
     Option Console Serial
     GUI Cursor On 0, 100,100,rgb(red)
     Controller Mouse Open mp
   Case Else
     Backlight 80' 100 is off
 End Select


I shifted the BACKLIGHT command into the IF ELSE routine.

Jim
VK7JH
MMedit   MMBasic Help
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 08:48am 09 Apr 2021
Copy link to clipboard 
Print this post

  TassyJim said  

I shifted the BACKLIGHT command into the IF ELSE routine.

Jim


The Backlight statement is really application specific - i.e your program. I have it simply to set my F4 to the right levels for me - YMMV and on micromites it is non-existent.

Consider it part of the demo code - perhaps I should move it to there to make it more obvious it isn't part of the GUI subsys?
Edited 2021-04-09 18:50 by CaptainBoing
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:31pm 10 Apr 2021
Copy link to clipboard 
Print this post

Still futzing around with this. I've added vertical sliders and I suppose I will eventually add the ability to specify which way the pointer points. This is probably too 'expensive' for non CMM2 hardware, but it's nice to have the option and doing this helps to better understand how everything works. And before the question is asked....I'm not planning on 'forking' CaptainBoing's Wiki page for a CMM2 version....more than I want to do!

Steve


gui_demo_6.zip


 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 06:37am 11 Apr 2021
Copy link to clipboard 
Print this post

see? that's nice - vertical slider - never occurred to me.

one point, I think H & V should really follow the same mechanism as progress bars for alignment otherwise we have inconsistency in specifying orientation, but it is entirely down to how you want to grow your own code. I will lift your vertical slider section of code and tweak it and include it in the next version.

Good work

see the Border type and alignment section

as an aside, I think if you right-click the mouse it will grab the screen for you rather than having to take a photo - jus' sayin'
Edited 2021-04-11 19:15 by CaptainBoing
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:11am 11 Apr 2021
Copy link to clipboard 
Print this post

  CaptainBoing said  see? that's nice - vertical slider - never occurred to me.

one point, I think H & V should really follow the same mechanism as progress bars for alignment otherwise we have inconsistency in specifying orientation, but it is entirely down to how you want to grow your own code. I will lift your vertical slider section of code and tweak it and include it in the next version.

Good work

see the Border type and alignment section

as an aside, I think if you right-click the mouse it will grab the screen for you rather than having to take a photo - jus' sayin'


DOH! Yes, much better than a photo! Getting rid of the H/V would be better, but as sliders don't have a border...I didn't have another idea there. It is a bit fiddly getting the desired result into linked objects, as they way the code works in ProcessTouch, up ends up low and vice-versa. There's probably a way around this...but I was unable to figure it out!

I'm currently working on the demo code that allows input into a textbox...trying to develop a general 'method' as it were. Trying to constrain text to the box dimensions is proving to be obstinate...perhaps I was just sleepy...dim witted is more likely!    

Steve
 
     Page 3 of 4    
Print this page
© JAQ Software 2024