[racket] toy graphical list editor

Showing 1-6 of 6 messages
[racket] toy graphical list editor Marijn 5/23/11 7:04 AM
Hi,

I'm trying to implement a toy graphical list editor program to get a
feel for GUI programming in racket. Basic idea is a graphical
representation of a list with text-field%s alternated with buttons to
insert items and on the side of each text-field% a button to remove that
item. When the program is destroyed it should print the constructed list
on the console (when started from one). My understanding so far calls
for a doubly-linked list to hold the items (and their graphical
manifestation), although this seems very unlispy... Is there a better way?

Sample code showing graphical layout and rudimentary functioning of the
program is attached.

Side-question: why does pressing an insert-button resize the top-level
frame%?

Any help appreciated,

Marijn

Re: [racket] toy graphical list editor Matthew Flatt 5/23/11 8:02 PM
At Mon, 23 May 2011 16:04:24 +0200, Marijn wrote:
> I'm trying to implement a toy graphical list editor program to get a
> feel for GUI programming in racket. Basic idea is a graphical
> representation of a list with text-field%s alternated with buttons to
> insert items and on the side of each text-field% a button to remove that
> item. When the program is destroyed it should print the constructed list
> on the console (when started from one). My understanding so far calls
> for a doubly-linked list to hold the items (and their graphical
> manifestation), although this seems very unlispy... Is there a better way?

My preference for this sort of problem is to abandon MVC and let the
GUI represent the model. That is, to build the result list in this
case, I'd traverse the GUI hierarchy to extract the elements.

To keep the model separate, though, I don't have a better suggestion
than a doubly-linked list.

> Sample code showing graphical layout and rudimentary functioning of the
> program is attached.
>
> Side-question: why does pressing an insert-button resize the top-level
> frame%?

When a text field has a non-empty string as its initial value, the
minimum width is based on the string. If the initial value is an empty
string, then a default is used, and the default turns out to be wider
than one character. The "insert" buttons create empty fields, while the
three initial fields have non-empty initial content.

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Re: [racket] toy graphical list editor Marijn 5/24/11 6:54 AM
Hi Matthew,

After changing all the values to "1", when pressing an insert-button
*sometimes* the window is resized horizontally (slightly larger width)
and *sometimes* the window flickers to slightly larger horizontally, but
remains the same width. According to `get-graphical-min-size' the
horizontal width stays constant at, for me, 58. I wrote another program
which exhibits this flickering behavior for me which I attached. Again
the size output seems to be fine, at least on the granularity
instrumented. Is this expected behavior?

Thanks,

Marijn

Re: [racket] toy graphical list editor Matthew Flatt 5/24/11 11:59 AM
At Tue, 24 May 2011 15:54:55 +0200, Marijn wrote:
> After changing all the values to "1", when pressing an insert-button
> *sometimes* the window is resized horizontally (slightly larger width)
> and *sometimes* the window flickers to slightly larger horizontally, but
> remains the same width. According to `get-graphical-min-size' the
> horizontal width stays constant at, for me, 58. I wrote another program
> which exhibits this flickering behavior for me which I attached. Again
> the size output seems to be fine, at least on the granularity
> instrumented. Is this expected behavior?

No --- I've pushed a fix to repair the resize flicker.

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Re: [racket] toy graphical list editor Marijn 5/25/11 1:19 AM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Matthew,

On 05/24/11 20:59, Matthew Flatt wrote:
> At Tue, 24 May 2011 15:54:55 +0200, Marijn wrote:
>> After changing all the values to "1", when pressing an insert-button
>> *sometimes* the window is resized horizontally (slightly larger width)
>> and *sometimes* the window flickers to slightly larger horizontally, but
>> remains the same width. According to `get-graphical-min-size' the
>> horizontal width stays constant at, for me, 58. I wrote another program
>> which exhibits this flickering behavior for me which I attached. Again
>> the size output seems to be fine, at least on the granularity
>> instrumented. Is this expected behavior?
>
> No --- I've pushed a fix to repair the resize flicker.

Thanks for the quick (as usual) fix! I'd be interested to know what was
happening before the fix. Also the code now runs much faster, although
that might also be because I enabled the jit this time.

Thanks,

Marijn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3cu5UACgkQp/VmCx0OL2xNgACgqWeIRnXXgDcwR5In8fn3MBei
5tEAoMYBr0Zbau/Q1+dwzjhfC93FKqN9
=AUdF
-----END PGP SIGNATURE-----


_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Re: [racket] toy graphical list editor Matthew Flatt 5/25/11 2:15 AM
At Wed, 25 May 2011 10:19:33 +0200, Marijn wrote:
> On 05/24/11 20:59, Matthew Flatt wrote:
> > At Tue, 24 May 2011 15:54:55 +0200, Marijn wrote:
> >> After changing all the values to "1", when pressing an insert-button
> >> *sometimes* the window is resized horizontally (slightly larger width)
> >> and *sometimes* the window flickers to slightly larger horizontally, but
> >> remains the same width. According to `get-graphical-min-size' the
> >> horizontal width stays constant at, for me, 58. I wrote another program
> >> which exhibits this flickering behavior for me which I attached. Again
> >> the size output seems to be fine, at least on the granularity
> >> instrumented. Is this expected behavior?
> >
> > No --- I've pushed a fix to repair the resize flicker.
>
> Thanks for the quick (as usual) fix! I'd be interested to know what was
> happening before the fix.

A `text-field%' is internally constructed as a panel and an
`editor-canvas%'. The minimum width and height are configured after the
pieces are created. I'm not clear on why the frame size bounced, but
the GUI toolbox unnecessarily updating the window layout for the
intermediate states of `text-field%' construction. The repair was to
wrap the internal creation and configuration of a `text-field%' with
`begin-container-sequence' and `end-container-sequence'.

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users