components-based approach, two demos

Are you developing tools to extend the LiveCode environment? This is the place to talk about the nuts and bolts of extending our nuts and bolts. If you want to use a LiveCode or third party Environment extension, visit the Using Evironment Extensions forum.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
marielle
Livecode Opensource Backer
Livecode Opensource Backer

components-based approach, two demos

Post by marielle » Fri Apr 21, 2006 4:54 pm

In have uploaded in my revonline folder two demos of widgets illustrating a mvc approach to programming (Username=Marielle,category = programming).

1. file download widget
The widget doesn't do anything particularly exciting (you specify a url and a target directory and push on the download button and the file gets downloaded.

What is of interest is the way the widget is written. The view is completely separated from the model. The model doesn't need a view to work. The view requires no more than a group called "wg_file_download" with the appropriate functions on the card (could be made invisible). There is no need to put any script in the back of the stack. It is built-in to allow for localisation (thought I didn't fully implement this feature yet).

2. gradient widget
This is a bit more exciting in what it does. I outline a method to easily create using tips from "Simple Method Of Storing Colour Ramps" (Written By Paul Bourke, June 2003; Adapted from OGLE By Dr. Michael J. Gourlay)

What is illustrated here is how such a problem can be divided into 3 main components: (1) a speadsheet object for manipulating the gradient data and reformat, (2) a gradient creation utility that will create a gradient from these data, and (3) a snapshot utility for transforming the gradient in a permanent format

To the ones sceptical about components, I reckon that the script can appear somehow longer than the one you would have written to solve that problem. The interest of adding a few more lines of script the way i did is that you can easily define the widget components (view elements) and script parameters from outside the view. It takes more time to write a component. But any component you write this way is more robust (because used in multiple contexts)

Tested on a Mac only. Any feedback will be much appreciated.

Marielle

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Re: components-based approach, two demos

Post by marielle » Sun Apr 23, 2006 3:58 pm

marielle wrote:In have uploaded in my revonline folder two demos of widgets illustrating a mvc approach to programming
Now also in the components section of the stacks gallery

Or from your message box:

Code: Select all

go stack url "http://revolution.widged.com/stacks/open/components/filedownload_widget.rev"
go stack url "http://revolution.widged.com/stacks/open/components/gradient_widget.rev"

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Sun Apr 23, 2006 4:57 pm

Hi Marielle,

I get a "No such card" error in MSG when I try to load the gradient stack from the second link you posted.

All the best,

Malte

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Sun Apr 23, 2006 4:59 pm

Seems to be a broken link on your page. Browser download also fails.

All the best,

malte

marielle
Livecode Opensource Backer
Livecode Opensource Backer

Post by marielle » Sun Apr 23, 2006 6:26 pm

malte wrote:Seems to be a broken link on your page. Browser download also fails.
Oups. Sorry about that. Now corrected and tested:

go stack url "http://revolution.widged.com/stacks/ope ... widget.rev"

On the no such card, I have seen this happen with stacks that are correctly referenced (like it seems to have happened for the filedownload_widget.rev stack). Usually, clicking enter on the message box a few times does the trick. Not clear what the issue is. A guess is that the file is not fully loaded when you first press enter but is when after you try a few times.

Post Reply

Return to “Making IDE Plugins”