Lisp HUG Maillist Archive

Removing all evidence of a tab layout

I have a nested tab layout which I populate from my program.  I'd like 
to be able to return the interface to its initial, clean state before 
the tabs were populated.

I have experimented with setting collection-items and 
layout-descriptions to nil, but haven't managed to remove the pinboard 
from the interface.

This example displays the nested tabs which are initialized from the 
"Init tabs" menu item.  I would like everything to be cleaned up by the 
"Remove tabs" menu item. Thanks for any advice.

(capi:define-interface tab-test ()
   ()
   (:layouts
    (test-tab-layout
     capi:tab-layout
     '()
     :accessor test-tab-layout
     :print-function 'first
     :visible-child-function 'second)
    (main-layout
     capi:row-layout
     '(test-tab-layout)))
   (:menus
    (file-menu
     "Actions"
     (("Init tabs"
       :callback 'initialize-test-tabs
       :callback-type :interface)
      ("Remove tabs"
       :callback 'remove-tabs
       :callback-type :interface))))
   (:menu-bar file-menu)
   (:default-initargs
    :layout 'main-layout
    :best-height 400
    :best-width 400))

(defun initialize-test-tabs (tab-interface)
   (let ((level-1-tab-layout))
     (dotimes (i 3)
       (setf level-1-tab-layout
             (make-instance
              'capi:tab-layout
              :tabs-position :bottom
              :items '("One" "Two")
              :description
              (list (make-instance
                     'capi:pinboard-layout
                     :background (nth i (list :white :blue :red))
                     :visible-border t
                     :interface tab-interface))))
       (capi:append-items
        (test-tab-layout tab-interface)
        (list (list
               (nth i (list "Tab One" "Tab Two" "Tab Three"))
               level-1-tab-layout))))))

(defun remove-tabs (tab-interface)
   (dotimes (i (length (capi:collection-items (test-tab-layout 
tab-interface))))
     (setf (capi:layout-description
            (second
             (svref (capi:collection-items (test-tab-layout 
tab-interface)) i)))
           nil)
     (setf (capi:collection-items
            (second
             (svref (capi:collection-items (test-tab-layout 
tab-interface)) i)))
           nil))
   (setf (capi:collection-items (test-tab-layout tab-interface))
         nil))

(defun test-tab ()
   (capi:display (make-instance 'tab-test)))

(test-tab)


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