Shop OBEX P1 Docs P2 Docs Learn Events
First Graphical widget — Parallax Forums

First Graphical widget

Graham StablerGraham Stabler Posts: 2,507
edited 2007-10-15 22:52 in Propeller 1
A first graphical widget demo.

www.youtube.com/watch?v=_MMAMRoURcI

There are two functions, one draws a scale at an arbitrary position, over an aribrary angular range and with an arbitrary number of tick marks.

The second draws a pointer of with similar arbibrary parameters.

I hope the demo shows how these generalized functions can soon produce useful results with good code reusage.

Need suggestions for further functions.

Graham

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-10-14 22:24
    Have a look at QT smile.gif
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-15 01:09
    Where's widgets.spin?

    Post Edited (Fred Hawkins) : 10/15/2007 4:09:07 AM GMT
  • parts-man73parts-man73 Posts: 830
    edited 2007-10-15 01:24
    Nifty! going to publish it to the OBEX? or more work to be done to it first?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-15 01:25
    Buttons, drop down lists, text keypad, etc. For touch screens! smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-15 08:59
    DeSilva,

    I've got a book on QT, I guess I'll have to actually open it!

    Fred,

    All the code is in the one file, I've not created the actual object yet.

    Brian,

    Eventually when it has more than two widgets.

    Ken,

    by text keypad do you mean a numeric keypad?

    All,

    I'll be concentrating on display widgets to start with, meters, progress bars etc then I can look at user interface elements. I'd be MORE than happy for people to supply widgets to go in the library, they don't have to be complete, I can always do the generalizing, its good fun creating them.

    Graham
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-15 11:52
    In fact you can download the book I have here: http://www.informit.com/content/images/0131240722/downloads/blanchette_book.pdf

    which is one reason I was happy to buy it
  • rjo_rjo_ Posts: 1,825
    edited 2007-10-15 13:00
    Graham,

    Thank you very much. I haven't looked at graphics yet, but your widgets make it almost irresistable.

    This is nit picking, but the spokes (of your dial widget) don't seem to converge on the same point (looks like an aliasing problem).

    I think Parallax should offer a prize to the large model guys... first one to:

    http://www.povray.org/

    or

    http://en.wikipedia.org/wiki/VRML

    wins.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-15 13:07
    It's simply a lack of pixels on the screen and comes down to the graphics object rather than me, it occurs when the plotted lines make a small angle with rows/cols of the display. If you draw a line in paint very close to the horizontal you will see why adjacent lines may appear parallel when they are short.

    Graham
  • rjo_rjo_ Posts: 1,825
    edited 2007-10-15 14:38
    Graham,

    Your widgets out to be in the demo that Parallax sends out with the demo board... they spark the imagination and beg to be hacked.
    The minute I saw it... I wanted to hack my car. Of course, I can't do that yet... but that's what it did to me.

    Very sweet.

    Rich
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-10-15 20:52
    Graham,

    Very nicely done! I am impressed. I would love to be able to do the things you and many others are doing with the propeller!

    Some of my ideas for additional graphic widgets include bar graphs that are horizontal, vertical or curved and displayed as individual segments or a solid bar with or without a full range outline. Also round or polygon shapes that could be substituted in place of rectangular increment markers might make for some interesting displays.

    Thinking of the popularity of GPS systems these days, creating an arrow shaped pointer would seem to be an easy and very useful variation on what you already have.

    Finally, I think a resizable digit or hex display would also be very useful as well.

    I think your analog meter design is great! The way you have split the tick marks from the pointers will be very useful. Keep up the good work!


    - Sparks
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-10-15 21:10
    Sparks,

    All I am doing is using the functions in graphics.spin, no clever programming really this widget was done using vec, this just displays a vector sprite found in the DAT section at a given angle, positon and scale. So all I needed then for the scale was to have a loop drawing the tick vector. For the pointer it draws a single vector sprite. The only hard part was making it general so it works when the angle range crosses 0/360 degrees.

    As far as different pointers go, all you need to do is fiddle with the DAT section to make it match your hearts desire. Same for the scales, you might even change vec to pix which will display a pixel sprite, that could be a solid circle or even a small dog! I quite fancy doing a diving watch display demo.

    I'll definately be considering the bar graphs as well as slide bars.

    Another thing you can do with the hand widget is make the kind of display where two pointers cross each other.

    Graham
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-15 22:52
    Notice that Graham's example configures the TV for PAL mode; it will look MUCH nicer on most low-cost displays with NTSC, change this for it:
                  long    %0000      'mode  -- rather than 1
    .....
    .....
                  long    10         'hx  --- rather than 12,  (maybe you will even need 8)
    
Sign In or Register to comment.