All Manuals > CAPI User Guide and Reference Manual > 24 COLOR Reference Entries

create-light-dark-switchable-color

light-dark-switchable-color-p

light-dark-switchable-color-light-color

light-dark-switchable-color-dark-color

light-dark-switchable-color-set-colors Functions

Summary

Functions that create and access a "switchable-color" object that automatically switches between dark mode and light mode when used as a color by CAPI or Graphics Ports.

Package

color

Signatures

create-light-dark-switchable-color light-mode-color dark-mode-color => switchable-color

light-dark-switchable-color-p object => boolean

light-dark-switchable-color-light-color switchable-color => color-specifier

light-dark-switchable-color-dark-color switchable-color => color-specifier

light-dark-switchable-color-set-colors switchable-color new-light-mode-color new-dark-mode-color

Arguments
light-mode-color, dark-mode-color
Color specifications.
object
A Lisp object.
switchable-color
An object that was created by create-light-dark-switchable-color.
new-light-mode-color, new-dark-mode-color
Color specifications or nil.
Values
switchable-color
An opaque object that can be used as color.
boolean
A boolean.
color-specifier
A color specification or a color name.
Description

The function create-light-dark-switchable-color creates a "switchable-color" object that can be used where CAPI or Graphics Ports functions require a color. The "switchable-color" object uses light-mode-color when the screen is in light mode, and dark-mode-color when the screen is in dark mode.

light-mode-color and dark-mode-color can be anything that can be interpreted as color, that is either a color spec or a color name. See 15 The Color System for details.

The function light-dark-switchable-color-p returns true if object is a "switchable-color" object created by create-light-dark-switchable-color and false otherwise.

The functions light-dark-switchable-color-light-color and light-dark-switchable-color-dark-color return the light mode color and dark mode color respectively of their argument switchable-color.

The function light-dark-switchable-color-set-colors can be used to set the colors of a "switchable-color" object. Either new-light-mode-color or new-dark-mode-color may be nil, in which case the corresponding color does not change. Note that light-dark-switchable-color-set-colors does not force a redisplay of anything that is using the color, so if you want to see the change on the screen then you have to force a redisplay of the users. Use redisplay-element for output-panes and pinboard-objects and set the relevant color again using (setf simple-pane-foreground) or (setf simple-pane-background) for other panes.

Examples

Creating display pane that uses different colors in different modes:

(let ((background (color:create-light-dark-switchable-color
                   :lightcyan :navy))
      (foreground (color:create-light-dark-switchable-color
                   :black :white)))
  (capi:contain (make-instance 'capi:display-pane
                               :text "A pane with switchable color"
                               :foreground foreground
                               :background background)))
See also

15 The Color System


CAPI User Guide and Reference Manual (Windows version) - 18 Feb 2025 15:35:58