From a8cd449ff28ea8259e987a58a7f134fcb3863aa8 Mon Sep 17 00:00:00 2001 From: David Botton Date: Wed, 17 Aug 2022 23:34:41 -0400 Subject: [PATCH] fit-layout to allow for panel-box-layout to recalculate size of panels based on contents --- source/clog-panel.lisp | 28 ++++++++++++++++++++++++++++ source/clog.lisp | 3 ++- tools/clog-builder-settings.lisp | 6 +++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/source/clog-panel.lisp b/source/clog-panel.lisp index dad67d2..49ad69f 100644 --- a/source/clog-panel.lisp +++ b/source/clog-panel.lisp @@ -261,6 +261,34 @@ if :HTML-ID \"myid\" then the HTML-ID for center will be: myid-center" :html-id (format nil "~A-bottom" html-id))) panel-box)) + +;;;;;;;;;;;;;;;; +;; fit-layout ;; +;;;;;;;;;;;;;;;; + +(defgeneric fit-layout (clog-panel-box-layout) + (:documentation "Recalculate layout based on size of outer panel content")) + +(defmethod fit-layout ((obj clog-panel-box-layout)) + (let ((top-height (scroll-height (top-panel obj))) + (bottom-height (scroll-height (bottom-panel obj))) + (left-width (scroll-width (left-panel obj))) + (right-width (scroll-width (right-panel obj)))) + (setf (height (top-panel obj)) top-height) + (setf (height (bottom-panel obj)) bottom-height) + (setf (width (left-panel obj)) left-width) + (setf (width (right-panel obj)) right-width) + (set-margin-side (left-panel obj) :top (unit :px top-height)) + (set-margin-side (right-panel obj) :top (unit :px top-height)) + (set-margin-side (left-panel obj) :bottom (unit :px bottom-height)) + (set-margin-side (right-panel obj) :bottom (unit :px bottom-height)) + (set-margin (center-panel obj) + (unit :px top-height) + (unit :px right-width) + (unit :px bottom-height) + (unit :px left-width)))) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-panel-box ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog.lisp b/source/clog.lisp index 6f60a76..c7d37b0 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -619,7 +619,8 @@ embedded in a native template application.)" (top-panel generic-function) (left-panel generic-function) (right-panel generic-function) - (bottom-panel generic-function)) + (bottom-panel generic-function) + (fit-layout generic-function)) (defsection @clog-style-block (:title "CLOG Style Blocks") "CLOG-Style-Block - CLOG Style Blocks" diff --git a/tools/clog-builder-settings.lisp b/tools/clog-builder-settings.lisp index 0f14ac3..b242a90 100644 --- a/tools/clog-builder-settings.lisp +++ b/tools/clog-builder-settings.lisp @@ -2268,14 +2268,14 @@ (defparameter *supported-templates* (list - '(:name "CLOG Builder - Panel Templates" + '(:name "CLOG Builder - Panel Projects" :code :group) '(:name "New Builder Panel Project" :code "nbp" :type :system :www "templates/www/" :loc "templates/projects/clog-panel/") - '(:name "CLOG Templates - General" + '(:name "CLOG - General Projects" :code :group) '(:name "New CLOG Basic HTML Project" :code "ncp" @@ -2297,7 +2297,7 @@ :type :system :www "templates/www/" :loc "templates/projects/clog-web-site/") - '(:name "CLOG/CLOG Builder - Extension Templates" + '(:name "CLOG/CLOG Builder - Extension Projects" :code :group) '(:name "New CLOG/CLOG-Builder Plugin Project" :code "ncplug"