Is there a simple way to cache the contents of each tab in a tab control so that I do not have to recreate them over and over? I am trying to create a tabbed source editor, and I need the contents, scroll position and selection of each text editor to persist when I switch back and forth between each tab.
Thanks, Carl Gundel http://www.libertybasic.com http://www.runbasic.com _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Carl,
How did you populate the tabs? It's quite a normal pattern to store the app model as-is and not recreate it every time you visit the tab, in fact I can't think of any use for tabs otherwise. -Boris -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Carl Gundel Sent: 16 June 2011 21:59 To: VWNC Subject: [vwnc] Caching the contents of tab controls Is there a simple way to cache the contents of each tab in a tab control so that I do not have to recreate them over and over? I am trying to create a tabbed source editor, and I need the contents, scroll position and selection of each text editor to persist when I switch back and forth between each tab. Thanks, Carl Gundel http://www.libertybasic.com http://www.runbasic.com _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Boris,
The method that I've seen is to use the client:spec: method to add a user interface to the tab control. This makes a new user interface every time. So, after I add a UI in this fashion, how to grab it and reinstall it later? -Carl On Jun 16, 2011, at 10:07 PM, Boris Popov, DeepCove Labs wrote: > Carl, > > How did you populate the tabs? It's quite a normal pattern to store the > app model as-is and not recreate it every time you visit the tab, in > fact I can't think of any use for tabs otherwise. > > -Boris > > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On > Behalf Of Carl Gundel > Sent: 16 June 2011 21:59 > To: VWNC > Subject: [vwnc] Caching the contents of tab controls > > Is there a simple way to cache the contents of each tab in a tab control > so that I do not have to recreate them over and over? I am trying to > create a tabbed source editor, and I need the contents, scroll position > and selection of each text editor to persist when I switch back and > forth between each tab. > > Thanks, > > Carl Gundel > http://www.libertybasic.com > http://www.runbasic.com > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Carl Gundel
On Jun 16, 2011, at 6:59 PM, Carl Gundel wrote:
> Is there a simple way to cache the contents of each tab in a tab control so that I do not have to recreate them over and over? I am trying to create a tabbed source editor, and I need the contents, scroll position and selection of each text editor to persist when I switch back and forth between each tab. TabControl is not well set up to do this, IMO. Everytime you change the client: of the tabControl subcanvas, it's going to do a full release of your current view tree below the canvas. And now you're stuck with the ugly problem of recreating it. What makes it harder, is that your model doesn't have all the state you'd like to preserve. In the case of a tabbed set of text editors, your individual app models may capture things like the text, but it won't capture the current cursor position, the scroll, the selection range, etc. You'll have to write code to capture it all yourself. Or... we can quit pretending that the app model gives us very good model/ui separation (after all, if it did, we wouldn't need to have our app models hold on to something analogous of a C linker to get at the objects produced and then write code left and right like "(self widgetAt: #blah) component component etc"), and realize that the widgets have meaningful state, and throwing them all away, rebuilding is not what we always want. PartPort was introduced to the system to try and get around this problem. It's basically a dynamic view cache, with the idea that at any time, one and only one of its dynamically created child views is the "active" one. In this way, we can build all the views for a given tabset, and then just swap which one is active. In the case of a TabControl, rather than swapping clients on the subcanvas, I add a single PartPort child to the subcanvas (the subcanvas is just a standard CompositePart). And then I let that PartPort instance do all the work. The bottom half of the RB is managed this way since 7.5.1 (or was it 7.6?). It gets rid of a whole bunch of ugly code. In your case carl, the one tricky part, is that a click on the tab control, defocuses the current text editor, and a new one shows up. But text editors don't show their selectionRange unless they're focused. So you have to arrange for the tab switch to refocus the newly activated texteditor. I wrote a quick and dirty example of this and have attached it as a filein. I did it from a recent 7.8 build. It might work in 7.7.1 or earlier. YMMV. -- Travis Griggs Objologist "I did not have time to write you a short program, so I wrote you a long one instead." _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc ForCarl.st (4K) Download Attachment |
We use live UI caching/swapping in tab controls in 7.6. One gotcha we've found is with keyboardProcessor. We've added a set of extensions to go through the UI being swapped out to disconnect it from keyboard processors, and [re]connect the widgets of the UI being swapped back in. Without it we get widgets from the cached / swapped out UIs complaining that their container is nil, or some such. But in a more recent version of VW (I forget which) the keyboard processor has been reworked to avoid the need for our extensions. [hidden email] From: Travis Griggs <[hidden email]> To: VWNC NC <[hidden email]> Sent: Thu, June 16, 2011 11:23:53 PM Subject: Re: [vwnc] Caching the contents of tab controls On Jun 16, 2011, at 6:59 PM, Carl Gundel wrote: > Is there a simple way to cache the contents of each tab in a tab control so that I do not have to recreate them over and over? I am trying to create a tabbed source editor, and I need the contents, scroll position and selection of each text editor to persist when I switch back and forth between each tab. TabControl is not well set up to do this, IMO. Everytime you change the client: of the tabControl subcanvas, it's going to do a full release of your current view tree below the canvas. And now you're stuck with the ugly problem of recreating it. What makes it harder, is that your model doesn't have all the state you'd like to preserve. In the case of a tabbed set of text editors, your individual app models may capture things like the text, but it won't capture the current cursor position, the scroll, the selection range, etc. You'll have to write code to capture it all yourself. Or... we can quit pretending that the app model gives us very good model/ui separation (after all, if it did, we wouldn't need to have our app models hold on to something analogous of a C linker to get at the objects produced and then write code left and right like "(self widgetAt: #blah) component component etc"), and realize that the widgets have meaningful state, and throwing them all away, rebuilding is not what we always want. PartPort was introduced to the system to try and get around this problem. It's basically a dynamic view cache, with the idea that at any time, one and only one of its dynamically created child views is the "active" one. In this way, we can build all the views for a given tabset, and then just swap which one is active. In the case of a TabControl, rather than swapping clients on the subcanvas, I add a single PartPort child to the subcanvas (the subcanvas is just a standard CompositePart). And then I let that PartPort instance do all the work. The bottom half of the RB is managed this way since 7.5.1 (or was it 7.6?). It gets rid of a whole bunch of ugly code. In your case carl, the one tricky part, is that a click on the tab control, defocuses the current text editor, and a new one shows up. But text editors don't show their selectionRange unless they're focused. So you have to arrange for the tab switch to refocus the newly activated texteditor. I wrote a quick and dirty example of this and have attached it as a filein. I did it from a recent 7.8 build. It might work in 7.7.1 or earlier. YMMV. -- Travis Griggs Objologist "I did not have time to write you a short program, so I wrote you a long one instead." _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Carl Gundel
Carl
One way to do this is to create your own tab control. This control would use visibility to remove and add the subcanvases. You could probably use the current TabControlBarView and simply replace the TabControlComposite with your own. Terry =========================================================== Terry Raymond Crafted Smalltalk 80 Lazywood Ln. Tiverton, RI 02878 (401) 624-4517 [hidden email] <http://www.craftedsmalltalk.com> =========================================================== > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On Behalf Of Carl Gundel > Sent: Thursday, June 16, 2011 9:59 PM > To: VWNC > Subject: [vwnc] Caching the contents of tab controls > > Is there a simple way to cache the contents of each tab in a tab control so that I do not have to > recreate them over and over? I am trying to create a tabbed source editor, and I need the contents, > scroll position and selection of each text editor to persist when I switch back and forth between each > tab. > > Thanks, > > Carl Gundel > http://www.libertybasic.com > http://www.runbasic.com > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Or simply size the tab control to only show the tabs and use the change
notification from the list to show/hide your own subcanvases underneath instead of calling #client:spec: on the tabs. I hadn't looked at the code Travis sent though, for all I know that might be exactly what it's doing or something similar. -Boris -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Terry Raymond Sent: 17 June 2011 10:59 To: 'Carl Gundel'; 'VWNC' Subject: Re: [vwnc] Caching the contents of tab controls Carl One way to do this is to create your own tab control. This control would use visibility to remove and add the subcanvases. You could probably use the current TabControlBarView and simply replace the TabControlComposite with your own. Terry =========================================================== Terry Raymond Crafted Smalltalk 80 Lazywood Ln. Tiverton, RI 02878 (401) 624-4517 [hidden email] <http://www.craftedsmalltalk.com> =========================================================== > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] On > Behalf Of Carl Gundel > Sent: Thursday, June 16, 2011 9:59 PM > To: VWNC > Subject: [vwnc] Caching the contents of tab controls > > Is there a simple way to cache the contents of each tab in a tab > control so that I do not have to recreate them over and over? I am > trying to create a tabbed source editor, and I need the contents, > scroll position and selection of each text editor to persist when I > > Thanks, > > Carl Gundel > http://www.libertybasic.com > http://www.runbasic.com > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |