Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

help? dynamic images

 [1/8] from: russ:portone at: 28-Oct-2001 13:50


Hi... Wonder if anyone can help with this View problem: I'd like to dynamically add (append) images to a layout. That I can do. But then I'd like to selectively REMOVE them from the layout... by name or other identifier or index. I have achieved removing the LAST one I added, but have not figured how to create an index or identifier so that I can selectively remove a PARTICULAR one. Anyone point me in the right direction here? Thanks, Russ

 [2/8] from: greggirwin:mindspring at: 28-Oct-2001 11:46


Hi Russ, << I'd like to dynamically add (append) images to a layout. That I can do. But then I'd like to selectively REMOVE them from the layout... by name or other identifier or index. I have achieved removing the LAST one I added, but have not figured how to create an index or identifier so that I can selectively remove a PARTICULAR one. >> I haven't done it by index, but I have done it by face. I.e. the user can click on a face (an image in your case) and hit Ctrl+Delete. I watch for keystrokes and if I see Ctrl+Delete in a face, I do this: remove find face/parent-face/pane face My code is actually a little more involved because I have multiple "related" faces that need to be deleted if *any* of them are deleted, but that's the basic idea. --Gregg

 [3/8] from: russ:portone at: 28-Oct-2001 15:01


Hey Gregg, Thanks! I've done just what you say here. The thing is, in your case it seems that the name of the face is known. But how can I create "any" number of faces automatically, with index or name to which I can refer to it later when I wish to delete it? I don't know in advance how many faces there will be, and there could be 20+ of them. So I don't want to define each one at a time manually in advance. Guess what I'd like is sort of an array of them, with each dynamically defined as it arises... and thus the ability to remove it when it's no longer needed. Hope I'm making myself clear... :) Your comment about "multiple related faces" seems intriguing... and more along the lines of what I seek. Can you say more? Russ At 01:46 PM 10/28/01, you wrote:

 [4/8] from: james:mustard at: 29-Oct-2001 10:01


> >I haven't done it by index, but I have done it by face. I.e. the user can > >click on a face (an image in your case) and hit Ctrl+Delete. I watch for > >keystrokes and if I see Ctrl+Delete in a face, I do this:
Hi Russ, just done something similar in my gui builder - when creating objects i set a global called current-object that points to the face just created. I also bind feel/engage to reset the current-object to the object receiving the event, eg: make-this: func ['obj] [ hide-popup-list if not work-form-hidden [ append work-form/pane v: make-face obj current-object: v v/offset: creation-point if none? v/color [v/color: white] v/feel: make v/feel [ engage: func [face action event][ current-object: face if action = 'down [ start: event/offset stop: false hide-popup-list remove find face/parent-face/pane face append face/parent-face/pane face ] if action = 'alt-down [ stop: true show-popup-list face event "object" ] if not stop [ if find [over away] action [ hide-popup-list face/offset: face/offset + event/offset - start if snap-to-grid [face/offset: face/offset - (face/offset // grid-size)] show face ] ] ] ] show v show work-form ] ] Modifying the feel/engage lets me add context sensitive help and do direct object manipulation when I otherwise wouldn't know which face was being accessed. From this point deletion is fairly simple with: delete-current-object: does [ if none? current-object [exit] if work-form-exists [ remove find work-form/pane current-object show work-form ] current-object: none ] Regards, James

 [5/8] from: greggirwin:mindspring at: 28-Oct-2001 23:18


Hi Russ, << The thing is, in your case it seems that the name of the face is known.
>>
Nope, it isn't. I created a style and in that style I defined an engage function. The engage function passes you the face that got the event, so I just pass that on to my function that removes the faces. << Your comment about "multiple related faces" seems intriguing... and more along the lines of what I seek. Can you say more? >> Sure. Let's use a generic paint program example where the only tool in the toolbox is a line tool. When you draw a line I'd take the two end-points and create a line object using a small box face for each end-point. I create those two faces and append them to the parent face, storing references to them in my line object, which is put into a block of line objects. When you delete an end-point, I scan through my block of line objects to find the line object it belongs to. Once I know which line object I'm after, I can remove the object from the block of lines and all the faces (two in this case) it references. --Gregg

 [6/8] from: russ:portone at: 29-Oct-2001 19:14


James, Between what you said here and what Gregg Irwin offered, I am now handling my dynamic image faces just fine! THANK YOU :) However... one problem remains: Since I am using images I followed your lead in how you did v/offset and put a v/size in my code. But it seems that now, rather than SCALING the image to fit the face size it simply crops the upper-left corner of the image into the available space! I'm new to View, so can you tell me what I should be doing so that the entire image appears in my dynamic face scaled properly? Thanks in advance, Russ At 04:01 PM 10/28/01, you wrote:

 [7/8] from: greggirwin:mindspring at: 29-Oct-2001 16:43


Hi Russ, <<...can you tell me what I should be doing so that the entire image appears in my dynamic face scaled properly? >> You need to make sure the 'fit effect is still being used. It's on by default, but if you modify the effect facet you might be turning it off. Not sure if your size thing could be doing it. --Gregg

 [8/8] from: russ:portone at: 29-Oct-2001 19:58


Gregg, THANKS! That was exactly it! Had nothing to do with the size parameter. I do lots of altering of the image and its effects and knew nothing about the 'fit needing to be in there under 'effects. Got it now.. and everything is perking just great!! :) Russ At 06:43 PM 10/29/01, you wrote: