GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Enumerations | Functions
gp_widgets_color_scheme.h File Reference

Colors and color scheme. More...

#include <widgets/gp_widget_types.h>

Go to the source code of this file.

Enumerations

enum  gp_widgets_color_scheme { GP_WIDGET_COLOR_SCHEME_DEFAULT , GP_WIDGET_COLOR_SCHEME_LIGHT , GP_WIDGET_COLOR_SCHEME_DARK }
 A color scheme. More...
 
enum  gp_widgets_color {
  GP_WIDGETS_COL_TEXT = 0 , GP_WIDGETS_COL_FG = 1 , GP_WIDGETS_COL_BG = 2 , GP_WIDGETS_COL_HIGHLIGHT = 3 ,
  GP_WIDGETS_COL_SELECT = 4 , GP_WIDGETS_COL_ALERT = 5 , GP_WIDGETS_COL_WARN = 6 , GP_WIDGETS_COL_ACCEPT = 7 ,
  GP_WIDGETS_COL_FILL = 8 , GP_WIDGETS_COL_DISABLED = 9 , GP_WIDGETS_THEME_COLORS = 10 , GP_WIDGETS_COL_BLACK = 10 ,
  GP_WIDGETS_COL_RED = 11 , GP_WIDGETS_COL_GREEN = 12 , GP_WIDGETS_COL_YELLOW = 13 , GP_WIDGETS_COL_BLUE = 14 ,
  GP_WIDGETS_COL_MAGENTA = 15 , GP_WIDGETS_COL_CYAN = 16 , GP_WIDGETS_COL_GRAY = 17 , GP_WIDGETS_COL_BR_BLACK = 18 ,
  GP_WIDGETS_COL_BR_RED = 19 , GP_WIDGETS_COL_BR_GREEN = 20 , GP_WIDGETS_COL_BR_YELLOW = 21 , GP_WIDGETS_COL_BR_BLUE = 22 ,
  GP_WIDGETS_COL_BR_MAGENTA = 23 , GP_WIDGETS_COL_BR_CYAN = 24 , GP_WIDGETS_COL_WHITE = 25 , GP_WIDGETS_COL_CNT
}
 Widget theme colors. More...
 

Functions

enum gp_widgets_color gp_widgets_color_name_idx (const char *name)
 Converts a color name into a color index.
 
gp_pixel gp_widgets_color (const gp_widget_render_ctx *ctx, enum gp_widgets_color color)
 Returns a pixel given an color index.
 
void gp_widgets_color_scheme_toggle (void)
 Toggles current color scheme.
 
void gp_widgets_color_scheme_set (enum gp_widgets_color_scheme color_scheme)
 Sets a color scheme.
 
enum gp_widgets_color_scheme gp_widgets_color_scheme_get (void)
 Returns current color scheme.
 
gp_widgetgp_widget_color_scheme_switch (void)
 Creates a color scheme switch widget.
 

Detailed Description

Colors and color scheme.

Color theme provies a mapping from an abstract color names such as text color or background color to indexes into a global color table gp_widget_render_ctx::colors.

JSON Theme colors

Color name Color definition
"text" Text color
"fg" Foreground color
"bg Background color
"highlight" Highlighted background
"alert" Alert (error) color, usually red
"warn" Warning color, usually yellow
"accept" Accept color, usually green

JSON 16 colors names

Color names
"black" "red" "green" "yellow"
"blue" "magenta" "cyan" "gray"
"bright black" "bright red" "bright green" "bright yellow"
"bright blue" "bright magenta" "bright cyan" "white"

Label colors example

{
"info": {"version": 1, "license": "GPL-2.0-or-later"},
"layout": {
"rows": 6,
"widgets": [
{"type": "label", "align": "hfill", "padd": 1,
"bg_color": "highlight", "tattr": "center",
"text": "bg_color=highlight"},
{"type": "label", "align": "hfill", "padd": 1,
"bg_color": "text", "tattr": "center", "text_color": "bg",
"text": "bg_color=text, text_color=bg"},
{"type": "label", "padd": 1,
"text_color": "alert", "text": "text_color=alert"},
{"type": "label", "padd": 1,
"text_color": "warn", "text": "text_color=warn"},
{"type": "label", "padd": 1,
"bg_color": "alert", "reverse_colors": true,
"text": "bg_color=alert, reverse_colors=true"},
{"type": "label", "align": "hfill", "padd": 1,
"bg_color": "black", "text_color": "green", "tattr": "center",
"text": "bg_color=black, text_color=green"}
]
}
}

Definition in file gp_widgets_color_scheme.h.

Enumeration Type Documentation

◆ gp_widgets_color

Widget theme colors.

The first 10 colors are theme colors, such as default text color, foreground and background color and the next are standard 16 colors.

Enumerator
GP_WIDGETS_COL_TEXT 

Default text color.

Text color is also used for widget frames.

GP_WIDGETS_COL_FG 

Default foreground color.

Foreground is usually used to paint inner parts of the widgets.

GP_WIDGETS_COL_BG 

Default background color.

Background is used to fill in areas between widgets.

GP_WIDGETS_COL_HIGHLIGHT 

Default highlighted color.

GP_WIDGETS_COL_SELECT 

Default selection color.

Selected text, active widget, etc.

GP_WIDGETS_COL_ALERT 

Default alert color.

Used to highlight errors, usually red.

GP_WIDGETS_COL_WARN 

Default warning color.

Used to highlight warnings, usually yelow.

GP_WIDGETS_COL_ACCEPT 

Default accept color.

Used to highlight accepted input, agreement etc., usually green.

GP_WIDGETS_COL_FILL 

Default fill color.

This is used to fill in background when application is smaller than backend.

GP_WIDGETS_COL_DISABLED 

Default disabled widget color.

This color replaces text color when widget is disabled.

GP_WIDGETS_THEME_COLORS 

The number of theme colors.

GP_WIDGETS_COL_BLACK 

Black in standard 16 colors.

GP_WIDGETS_COL_RED 

Red in standard 16 colors.

GP_WIDGETS_COL_GREEN 

Green in standard 16 colors.

GP_WIDGETS_COL_YELLOW 

Yellow in standard 16 colors.

GP_WIDGETS_COL_BLUE 

Blue in standard 16 colors.

GP_WIDGETS_COL_MAGENTA 

Magenta in standard 16 colors.

GP_WIDGETS_COL_CYAN 

Cyan in standard 16 colors.

GP_WIDGETS_COL_GRAY 

Gray in standard 16 colors.

GP_WIDGETS_COL_BR_BLACK 

Bright black in standard 16 colors.

GP_WIDGETS_COL_BR_RED 

Bright red in standard 16 colors.

GP_WIDGETS_COL_BR_GREEN 

Bright green in standard 16 colors.

GP_WIDGETS_COL_BR_YELLOW 

Bright yellow in standard 16 colors.

GP_WIDGETS_COL_BR_BLUE 

Bright blue in standard 16 colors.

GP_WIDGETS_COL_BR_MAGENTA 

Bright magenta in standard 16 colors.

GP_WIDGETS_COL_BR_CYAN 

Bright cyan in standard 16 colors.

GP_WIDGETS_COL_WHITE 

White in standard 16 colors.

GP_WIDGETS_COL_CNT 

The number of widget colors.

Definition at line 74 of file gp_widgets_color_scheme.h.

◆ gp_widgets_color_scheme

A color scheme.

Decides if the pixmaps generated by application should have dark or light background. There is also default light and dark scheme compiled in the library.

Enumerator
GP_WIDGET_COLOR_SCHEME_DEFAULT 

Default color scheme.

GP_WIDGET_COLOR_SCHEME_LIGHT 

Light color scheme.

GP_WIDGET_COLOR_SCHEME_DARK 

Dark color scheme.

Definition at line 59 of file gp_widgets_color_scheme.h.

Function Documentation

◆ gp_widget_color_scheme_switch()

gp_widget * gp_widget_color_scheme_switch ( void  )

Creates a color scheme switch widget.

Returns
TODO!

◆ gp_widgets_color()

Returns a pixel given an color index.

Parameters
ctxA widget rendering context.
colorA color index.
Returns
A pixel value.

◆ gp_widgets_color_name_idx()

enum gp_widgets_color gp_widgets_color_name_idx ( const char *  name)

Converts a color name into a color index.

Parameters
namea color name
Returns
An enum gp_widgets_color or -1 on a failure.

◆ gp_widgets_color_scheme_get()

enum gp_widgets_color_scheme gp_widgets_color_scheme_get ( void  )

Returns current color scheme.

Returns
Current color scheme.

◆ gp_widgets_color_scheme_set()

void gp_widgets_color_scheme_set ( enum gp_widgets_color_scheme  color_scheme)

Sets a color scheme.

Reloads colors, redraws application.

Parameters
color_schemeNew color scheme.

◆ gp_widgets_color_scheme_toggle()

void gp_widgets_color_scheme_toggle ( void  )

Toggles current color scheme.

Reloads colors, redraws application.