gutopia-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [rgui-dev] RE: Backend


From: Tom Sawyer
Subject: Re: [rgui-dev] RE: Backend
Date: 06 Sep 2002 01:48:52 -0600

On Wed, 2002-09-04 at 16:56, Kero van Gelder wrote:
 
> OK, I've been looking a bit at it.

great.
 
> I must say, I have no idea where a component comes from...
> What is it? What fields does it have? How is it made?

let me see if i can help explain. in components.rb all the GUtopIa
component classes are defined. of course these are going to change now
that we've started on the categories idea. but the basic idea should
stay the same.

so lets take Button from components.rb as an example:

  class Button < Component
  
    attribute(:text)
    attribute(:image)
    
    event(:press)
    event(:pointer_enter)
    event(:pointer_leave)
    
    def initialize(attr_hash=nil, &block)
      @text = ''
      @image = nil
      super
    end
    
  end  # Button

there's a couple things to notice here. first attribute() is a module
method that acts sort of like attr_accessor, but does more. this sets up
attributes of the component. our button as defined here simply has a
text attribute and an image attribute. while not used in this example,
attribute() can accept a validation proc.

event() is a module method like attribute() but only defines an
event-action that can take place, not a container of data.

take a look at the definitions of attribute() and event() in the
Component class, which is very important b/c all the components inherit
from this master class.

initialize sets default values for the attributes, then calls the super
class's initialize (of Component). that's where hash notation and eval
notation's are taken care of.

the most significant thing about the Component Class is that it has an
instance varaible that holds a reference to the native backend
component. that's how a GUtopIa widget is linked to the "real" widget.
see the #create method in the Component class. that's where the backend
widget is created.

of course much of this is likely to change if we drop support for
multiple backends and just support our own (i.e. ruby-wise)

> Plus, without a more detailed discussion I do not feel like choosing
> :grid atm (the HList and VList suit my simple needs fine, whereas
> :grid will certainly require a rows-field, so widgets take up more
> than one row, that is, in a 3x3 matrix suddenly less than 9 widgets
> fit). An advantage of :grid is that all toolkits have a grid layout,
> afaik.

actually HList and VList are just subsets of grid with the approach
we've so far taken with layout management. simply specify :grid as the
layout and use a linear array in body. i.e.

# HLIST
layout = :grid
body = [ [ widget1, widget2, widget3] ]

# VLIST
layout = :grid
body = [ [ widget1 ],
         [ widget2 ],
         [ widget3 ] ]


> Otherwise, I couldn't get much further than the attached wise.rb
> which is almost an insult.

:-) to create a backend, with how things are currently arranged, you
have to define a backend widget class for each gutopia widget class,
with the exact same names. the backend widget is where the real action
takes place. did you take a look at the gtk version? that one works to a
large extent.

> What I'm missing is a picture like the Rouge alpha/beta/gamma.
> Ruby-Wise was intended as the pure Ruby gamma implementation,
> i.e. old-fashioned toolkit (but with all great features from
> tk/gtk/andmore combined). Anything like XML, IDE, functional
> reactivity, who-knows-what (maybe even layout managers?) is in layers
> above.

not perfect or super detailed, but look at the picture here:

  http://www.rubygui.org/cgi-bin/wiki.pl?GUtopIa_Common_Meta-API

wise.rb is one of these backend wrappers.

> So, I've done a bit of setup for the runtime choice of native toolkit,
> attached toolkit.rb

i looked at this but didn't quite follow. could you explain a little?

also, the question as to whether we should even bother with other
backends is up in the air. i really am leaning toward just supporting
ruby-wise and developing it into the versitle "Chameleon".

i'm not sure what Leon'a stance on ParaGUI with GUtopIa is at this
point. i know his goal for ParaGUI was to create a game, and perhaps
he's already started into that with his bindings. of course my first
thought was that ParaGUI would be able to serve as this chameleon tk,
but Leon suggested that ParaGUI might not be up to the task. haven't
heard anything about that since, only his suggestion that ruby-wise
would probably the better route.

> After which I did a bit of hacking in Wise, where I got lost in
>   "Some String".instance_of? String   => false
> which is wrong, of course. But it doesn't help for productivity :(

how about kind_of?

-- 
tom sawyer, aka transami
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]