Lisp HUG Maillist Archive

Dynamically creating panes for tab-layout

Hi

I'd like to create a tab-layout and add new panes to it later in a 
dynamic way.

However, it seems that each layout wants its children to be completely 
specified at construction time.

What I have in mind is to have a list (or tree) view widget on the side 
and open up tabs for each selected item.

Has anybody tried to do this?

Thanks

marco



--
Marco Antoniotti					http://bioinformatics.nyu.edu
NYU Courant Bioinformatics Group		tel. +1 - 212 - 998 3488
715 Broadway 10th FL				fax. +1 - 212 - 998 3484
New York, NY, 10003, U.S.A.


Re: Dynamically creating panes for tab-layout

Hello Marco,

| Hi
|
| I'd like to create a tab-layout and add new panes to it later in a
| dynamic way.
|
| However, it seems that each layout wants its children to be completely
| specified at construction time.
|
| What I have in mind is to have a list (or tree) view widget on the side
| and open up tabs for each selected item.
|
| Has anybody tried to do this?

The example of using capi:tab-layout in callback mode is as follows.

(capi:define-interface event-face ()
....
(tab-layout capi:tab-layout '(general entries)
    :items '(general entries)
    :visible-child-function nil
    :selection-callback 'tab-on-select
   :callback-type :interface-data) ...)

(defun manipulate-event-tabs (event-face &key add delete)
 ;;; Add or remove tab pages
  (or add delete (return-from manipulate-event-tabs))
  (let* ((tab-layout (slot-value event-face 'tab-layout))
         (items (capi:collection-items tab-layout))
         (fixed-items (list (elt items 0) (elt items 1))) ; General and
Entries tabs
         (fixed-panes (remove-if 'drawboard-p (capi:tab-layout-panes
tab-layout)))
         (old (remove-if-not 'drawboard-p (capi:layout-description
tab-layout)))
         (new (cond (add
                            (append (mapcar 'make-drawboard (listify add))
old))
                           (delete
                            (setq delete (listify delete))
                            (remove-if (lambda (draw) (member draw delete))
                                       old
                                       :key 'draw)))))
    (setf (capi:layout-description tab-layout) (append fixed-panes new)
          (capi:collection-items tab-layout) (append fixed-items new))))

The trick is that you need to change both the description and items
simultaneously.

There is a CAPI peculiarity (or a bug?): the deletion from the
layout-description seems not to imply the deletion from the
library-tab-layout. In case it is a hinder, you can exploit the following hack:

(setf (capi:layout-description (capi-internals:pane-implementation tl))
  (capi:layout-description tl))

BTW, using both the list/tree view and tabs for navigation purpose is an
overkill. IMHO, capi:switchable-layout would be enough.
--
Sincerely,
Dmitri Ivanov
lisp.ystok.ru


Updated at: 2020-12-10 08:55 UTC