Class SwatchesTab

All Implemented Interfaces:
Drawable

public class SwatchesTab extends Composite
The Swatches tab of the SWT color chooser (CC-COLOR-CHOOSER-SWT-PANELS, 2026-10-10): the generated palette (SwatchPalette, 31 by 9) and, to its right under a "Recent:" label, the recently picked colors (RecentColors, 5 by 7). A pick on either grid sets the chooser's color opaque (ruling SC-D-5: a swatch replaces the alpha) and moves the color to the front of the recents, which the chooser persists.

The two grids and the label form one block, centred in the tab, and the cells of both grids follow the tab's size (CC-FIX-SWATCHES-SCALE, 2026-10-28): the largest cell at which the block and its margins fit, from ChooserMetrics.MIN_CELL up to ChooserMetrics.MAX_CELL_SCALE times the reference cell. The tab's preferred size is the block at the reference cell, so the chooser opens at the size it always had.

Author:
Christopher Mindus
  • Field Details

    • RECENT_COLUMNS

      public static final int RECENT_COLUMNS
      The recent grid columns and rows.
      See Also:
    • RECENT_ROWS

      public static final int RECENT_ROWS
      See Also:
    • RECENT_CAPACITY

      public static final int RECENT_CAPACITY
      The number of recent colors kept: the cells of the recent grid.
      See Also:
  • Constructor Details

    • SwatchesTab

      public SwatchesTab(Composite parent, ColorChooserComposite chooser, RecentColors recent, Font font, int fontHeight, ChooserColors colors)
      Creates the tab.
      Parameters:
      parent - The parent.
      chooser - The chooser.
      recent - The recent colors.
      font - The dialog font, or null for the default.
      fontHeight - The height of the dialog font's metrics in points, for the cell size.
      colors - The theme colors: this page's background, the grids' background and cell shade lines.
  • Method Details

    • getPaletteGrid

      public SwatchGridCanvas getPaletteGrid()
      Gets the palette grid.
    • getRecentGrid

      public SwatchGridCanvas getRecentGrid()
      Gets the recent grid.
    • getRecentLabel

      public Label getRecentLabel()
      Gets the label of the recent grid.
    • recentChanged

      public void recentChanged()
      The recent colors changed: the recent grid is redrawn.
    • setCellSize

      public void setCellSize(int cell)
      Sets the reference cell size in points, at least ChooserMetrics.MIN_CELL, and lays the tab out again: the tab's preferred size is the block at this cell, and the cells shown follow the tab's size up to ChooserMetrics.MAX_CELL_SCALE times it.