Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/resources.cc
- This file was moved from source/blender/editors/interface/resources.c.
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <math.h> | #include <cmath> | ||||
| #include <stdlib.h> | #include <cstdlib> | ||||
| #include <string.h> | #include <cstring> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| Show All 12 Lines | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "GPU_framebuffer.h" | #include "GPU_framebuffer.h" | ||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| /* global for themes */ | |||||
| typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); | |||||
| /* be sure to keep 'bThemeState' in sync */ | /* be sure to keep 'bThemeState' in sync */ | ||||
| static struct bThemeState g_theme_state = { | static bThemeState g_theme_state = { | ||||
| NULL, | nullptr, | ||||
| SPACE_VIEW3D, | SPACE_VIEW3D, | ||||
| RGN_TYPE_WINDOW, | RGN_TYPE_WINDOW, | ||||
| }; | }; | ||||
| void ui_resources_init(void) | void ui_resources_init() | ||||
| { | { | ||||
| UI_icons_init(); | UI_icons_init(); | ||||
| } | } | ||||
| void ui_resources_free(void) | void ui_resources_free() | ||||
| { | { | ||||
| UI_icons_free(); | UI_icons_free(); | ||||
| } | } | ||||
| /* ******************************************************** */ | /* ******************************************************** */ | ||||
| /* THEMES */ | /* THEMES */ | ||||
| /* ******************************************************** */ | /* ******************************************************** */ | ||||
| const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) | const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) | ||||
| { | { | ||||
| ThemeSpace *ts = NULL; | ThemeSpace *ts = nullptr; | ||||
| static uchar error[4] = {240, 0, 240, 255}; | static uchar error[4] = {240, 0, 240, 255}; | ||||
| static uchar alert[4] = {240, 60, 60, 255}; | static uchar alert[4] = {240, 60, 60, 255}; | ||||
| static uchar header_active[4] = {0, 0, 0, 255}; | static uchar header_active[4] = {0, 0, 0, 255}; | ||||
| static uchar back[4] = {0, 0, 0, 255}; | static uchar back[4] = {0, 0, 0, 255}; | ||||
| static uchar setting = 0; | static uchar setting = 0; | ||||
| const uchar *cp = error; | const uchar *cp = error; | ||||
| /* ensure we're not getting a color after running BKE_blender_userdef_free */ | /* ensure we're not getting a color after running BKE_blender_userdef_free */ | ||||
| ▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | else { | ||||
| cp = ts->button_title; | cp = ts->button_title; | ||||
| } | } | ||||
| break; | break; | ||||
| case TH_HEADER: | case TH_HEADER: | ||||
| cp = ts->header; | cp = ts->header; | ||||
| break; | break; | ||||
| case TH_HEADER_ACTIVE: | case TH_HEADER_ACTIVE: { | ||||
| cp = ts->header; | cp = ts->header; | ||||
| const int factor = 5; | const int factor = 5; | ||||
| /* Lighten the header color when editor is active. */ | /* Lighten the header color when editor is active. */ | ||||
| header_active[0] = cp[0] > 245 ? cp[0] - factor : cp[0] + factor; | header_active[0] = cp[0] > 245 ? cp[0] - factor : cp[0] + factor; | ||||
| header_active[1] = cp[1] > 245 ? cp[1] - factor : cp[1] + factor; | header_active[1] = cp[1] > 245 ? cp[1] - factor : cp[1] + factor; | ||||
| header_active[2] = cp[2] > 245 ? cp[2] - factor : cp[2] + factor; | header_active[2] = cp[2] > 245 ? cp[2] - factor : cp[2] + factor; | ||||
| header_active[3] = cp[3]; | header_active[3] = cp[3]; | ||||
| cp = header_active; | cp = header_active; | ||||
| break; | break; | ||||
| } | |||||
| case TH_HEADER_TEXT: | case TH_HEADER_TEXT: | ||||
| cp = ts->header_text; | cp = ts->header_text; | ||||
| break; | break; | ||||
| case TH_HEADER_TEXT_HI: | case TH_HEADER_TEXT_HI: | ||||
| cp = ts->header_text_hi; | cp = ts->header_text_hi; | ||||
| break; | break; | ||||
| case TH_PANEL_HEADER: | case TH_PANEL_HEADER: | ||||
| ▲ Show 20 Lines • Show All 764 Lines • ▼ Show 20 Lines | else { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return (const uchar *)cp; | return (const uchar *)cp; | ||||
| } | } | ||||
| void UI_theme_init_default(void) | void UI_theme_init_default() | ||||
| { | { | ||||
| /* we search for the theme with name Default */ | /* we search for the theme with name Default */ | ||||
| bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); | bTheme *btheme = static_cast<bTheme *>( | ||||
| if (btheme == NULL) { | BLI_findstring(&U.themes, "Default", offsetof(bTheme, name))); | ||||
| btheme = MEM_callocN(sizeof(bTheme), __func__); | if (btheme == nullptr) { | ||||
| btheme = MEM_cnew<bTheme>(__func__); | |||||
| BLI_addtail(&U.themes, btheme); | BLI_addtail(&U.themes, btheme); | ||||
| } | } | ||||
| UI_SetTheme(0, 0); /* make sure the global used in this file is set */ | UI_SetTheme(0, 0); /* make sure the global used in this file is set */ | ||||
| const int active_theme_area = btheme->active_theme_area; | const int active_theme_area = btheme->active_theme_area; | ||||
| memcpy(btheme, &U_theme_default, sizeof(*btheme)); | memcpy(btheme, &U_theme_default, sizeof(*btheme)); | ||||
| btheme->active_theme_area = active_theme_area; | btheme->active_theme_area = active_theme_area; | ||||
| } | } | ||||
| void UI_style_init_default(void) | void UI_style_init_default() | ||||
| { | { | ||||
| BLI_freelistN(&U.uistyles); | BLI_freelistN(&U.uistyles); | ||||
| /* gets automatically re-allocated */ | /* gets automatically re-allocated */ | ||||
| uiStyleInit(); | uiStyleInit(); | ||||
| } | } | ||||
| void UI_SetTheme(int spacetype, int regionid) | void UI_SetTheme(int spacetype, int regionid) | ||||
| { | { | ||||
| if (spacetype) { | if (spacetype) { | ||||
| /* later on, a local theme can be found too */ | /* later on, a local theme can be found too */ | ||||
| g_theme_state.theme = U.themes.first; | g_theme_state.theme = static_cast<bTheme *>(U.themes.first); | ||||
| g_theme_state.spacetype = spacetype; | g_theme_state.spacetype = spacetype; | ||||
| g_theme_state.regionid = regionid; | g_theme_state.regionid = regionid; | ||||
| } | } | ||||
| else if (regionid) { | else if (regionid) { | ||||
| /* popups */ | /* popups */ | ||||
| g_theme_state.theme = U.themes.first; | g_theme_state.theme = static_cast<bTheme *>(U.themes.first); | ||||
| g_theme_state.spacetype = SPACE_PROPERTIES; | g_theme_state.spacetype = SPACE_PROPERTIES; | ||||
| g_theme_state.regionid = regionid; | g_theme_state.regionid = regionid; | ||||
| } | } | ||||
| else { | else { | ||||
| /* for safety, when theme was deleted */ | /* for safety, when theme was deleted */ | ||||
| g_theme_state.theme = U.themes.first; | g_theme_state.theme = static_cast<bTheme *>(U.themes.first); | ||||
| g_theme_state.spacetype = SPACE_VIEW3D; | g_theme_state.spacetype = SPACE_VIEW3D; | ||||
| g_theme_state.regionid = RGN_TYPE_WINDOW; | g_theme_state.regionid = RGN_TYPE_WINDOW; | ||||
| } | } | ||||
| } | } | ||||
| bTheme *UI_GetTheme(void) | bTheme *UI_GetTheme() | ||||
| { | { | ||||
| return U.themes.first; | return static_cast<bTheme *>(U.themes.first); | ||||
| } | } | ||||
| void UI_Theme_Store(struct bThemeState *theme_state) | void UI_Theme_Store(bThemeState *theme_state) | ||||
| { | { | ||||
| *theme_state = g_theme_state; | *theme_state = g_theme_state; | ||||
| } | } | ||||
| void UI_Theme_Restore(struct bThemeState *theme_state) | void UI_Theme_Restore(bThemeState *theme_state) | ||||
| { | { | ||||
| g_theme_state = *theme_state; | g_theme_state = *theme_state; | ||||
| } | } | ||||
| void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, uchar col[4]) | void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, uchar col[4]) | ||||
| { | { | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| r = coloffset + (int)cp[0]; | r = coloffset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = coloffset + (int)cp[1]; | g = coloffset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = coloffset + (int)cp[2]; | b = coloffset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| a = alphaoffset + (int)cp[3]; | a = alphaoffset + int(cp[3]); | ||||
| CLAMP(a, 0, 255); | CLAMP(a, 0, 255); | ||||
| col[0] = r; | col[0] = r; | ||||
| col[1] = g; | col[1] = g; | ||||
| col[2] = b; | col[2] = b; | ||||
| col[3] = a; | col[3] = a; | ||||
| } | } | ||||
| Show All 36 Lines | void UI_FontThemeColor(int fontid, int colorid) | ||||
| uchar color[4]; | uchar color[4]; | ||||
| UI_GetThemeColor4ubv(colorid, color); | UI_GetThemeColor4ubv(colorid, color); | ||||
| BLF_color4ubv(fontid, color); | BLF_color4ubv(fontid, color); | ||||
| } | } | ||||
| float UI_GetThemeValuef(int colorid) | float UI_GetThemeValuef(int colorid) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| return ((float)cp[0]); | return (float(cp[0])); | ||||
| } | } | ||||
| int UI_GetThemeValue(int colorid) | int UI_GetThemeValue(int colorid) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| return ((int)cp[0]); | return (int(cp[0])); | ||||
| } | } | ||||
| float UI_GetThemeValueTypef(int colorid, int spacetype) | float UI_GetThemeValueTypef(int colorid, int spacetype) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | ||||
| return ((float)cp[0]); | return (float(cp[0])); | ||||
| } | } | ||||
| int UI_GetThemeValueType(int colorid, int spacetype) | int UI_GetThemeValueType(int colorid, int spacetype) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | ||||
| return ((int)cp[0]); | return (int(cp[0])); | ||||
| } | } | ||||
| void UI_GetThemeColor3fv(int colorid, float col[3]) | void UI_GetThemeColor3fv(int colorid, float col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| col[0] = ((float)cp[0]) / 255.0f; | col[0] = (float(cp[0])) / 255.0f; | ||||
| col[1] = ((float)cp[1]) / 255.0f; | col[1] = (float(cp[1])) / 255.0f; | ||||
| col[2] = ((float)cp[2]) / 255.0f; | col[2] = (float(cp[2])) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColor4fv(int colorid, float col[4]) | void UI_GetThemeColor4fv(int colorid, float col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| col[0] = ((float)cp[0]) / 255.0f; | col[0] = (float(cp[0])) / 255.0f; | ||||
| col[1] = ((float)cp[1]) / 255.0f; | col[1] = (float(cp[1])) / 255.0f; | ||||
| col[2] = ((float)cp[2]) / 255.0f; | col[2] = (float(cp[2])) / 255.0f; | ||||
| col[3] = ((float)cp[3]) / 255.0f; | col[3] = (float(cp[3])) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]) | void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | ||||
| col[0] = ((float)cp[0]) / 255.0f; | col[0] = (float(cp[0])) / 255.0f; | ||||
| col[1] = ((float)cp[1]) / 255.0f; | col[1] = (float(cp[1])) / 255.0f; | ||||
| col[2] = ((float)cp[2]) / 255.0f; | col[2] = (float(cp[2])) / 255.0f; | ||||
| col[3] = ((float)cp[3]) / 255.0f; | col[3] = (float(cp[3])) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]) | void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| int r, g, b; | int r, g, b; | ||||
| r = offset + (int)cp[0]; | r = offset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + (int)cp[1]; | g = offset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + (int)cp[2]; | b = offset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| col[0] = ((float)r) / 255.0f; | col[0] = float(r) / 255.0f; | ||||
| col[1] = ((float)g) / 255.0f; | col[1] = float(g) / 255.0f; | ||||
| col[2] = ((float)b) / 255.0f; | col[2] = float(b) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorShade3ubv(int colorid, int offset, uchar col[3]) | void UI_GetThemeColorShade3ubv(int colorid, int offset, uchar col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| int r, g, b; | int r, g, b; | ||||
| r = offset + (int)cp[0]; | r = offset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + (int)cp[1]; | g = offset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + (int)cp[2]; | b = offset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| col[0] = r; | col[0] = r; | ||||
| col[1] = g; | col[1] = g; | ||||
| col[2] = b; | col[2] = b; | ||||
| } | } | ||||
| void UI_GetThemeColorBlendShade3ubv( | void UI_GetThemeColorBlendShade3ubv( | ||||
| Show All 12 Lines | void UI_GetThemeColorBlendShade3ubv( | ||||
| unit_float_to_uchar_clamp_v3(col, blend); | unit_float_to_uchar_clamp_v3(col, blend); | ||||
| } | } | ||||
| void UI_GetThemeColorShade4ubv(int colorid, int offset, uchar col[4]) | void UI_GetThemeColorShade4ubv(int colorid, int offset, uchar col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| int r, g, b; | int r, g, b; | ||||
| r = offset + (int)cp[0]; | r = offset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + (int)cp[1]; | g = offset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + (int)cp[2]; | b = offset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| col[0] = r; | col[0] = r; | ||||
| col[1] = g; | col[1] = g; | ||||
| col[2] = b; | col[2] = b; | ||||
| col[3] = cp[3]; | col[3] = cp[3]; | ||||
| } | } | ||||
| void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]) | void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| r = coloffset + (int)cp[0]; | r = coloffset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = coloffset + (int)cp[1]; | g = coloffset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = coloffset + (int)cp[2]; | b = coloffset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| a = alphaoffset + (int)cp[3]; | a = alphaoffset + int(cp[3]); | ||||
| CLAMP(a, 0, 255); | CLAMP(a, 0, 255); | ||||
| col[0] = ((float)r) / 255.0f; | col[0] = float(r) / 255.0f; | ||||
| col[1] = ((float)g) / 255.0f; | col[1] = float(g) / 255.0f; | ||||
| col[2] = ((float)b) / 255.0f; | col[2] = float(b) / 255.0f; | ||||
| col[3] = ((float)a) / 255.0f; | col[3] = float(a) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3]) | void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3]) | ||||
| { | { | ||||
| const uchar *cp1 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid1); | const uchar *cp1 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid1); | ||||
| const uchar *cp2 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid2); | const uchar *cp2 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid2); | ||||
| int r, g, b; | int r, g, b; | ||||
| CLAMP(fac, 0.0f, 1.0f); | CLAMP(fac, 0.0f, 1.0f); | ||||
| r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); | r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); | g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); | b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| col[0] = ((float)r) / 255.0f; | col[0] = float(r) / 255.0f; | ||||
| col[1] = ((float)g) / 255.0f; | col[1] = float(g) / 255.0f; | ||||
| col[2] = ((float)b) / 255.0f; | col[2] = float(b) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]) | void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4]) | ||||
| { | { | ||||
| const uchar *cp1 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid1); | const uchar *cp1 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid1); | ||||
| const uchar *cp2 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid2); | const uchar *cp2 = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid2); | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| CLAMP(fac, 0.0f, 1.0f); | CLAMP(fac, 0.0f, 1.0f); | ||||
| r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); | r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); | g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); | b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| a = floorf((1.0f - fac) * cp1[3] + fac * cp2[3]); /* No shading offset. */ | a = floorf((1.0f - fac) * cp1[3] + fac * cp2[3]); /* No shading offset. */ | ||||
| CLAMP(a, 0, 255); | CLAMP(a, 0, 255); | ||||
| col[0] = ((float)r) / 255.0f; | col[0] = float(r) / 255.0f; | ||||
| col[1] = ((float)g) / 255.0f; | col[1] = float(g) / 255.0f; | ||||
| col[2] = ((float)b) / 255.0f; | col[2] = float(b) / 255.0f; | ||||
| col[3] = ((float)a) / 255.0f; | col[3] = float(a) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColor3ubv(int colorid, uchar col[3]) | void UI_GetThemeColor3ubv(int colorid, uchar col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| col[0] = cp[0]; | col[0] = cp[0]; | ||||
| col[1] = cp[1]; | col[1] = cp[1]; | ||||
| col[2] = cp[2]; | col[2] = cp[2]; | ||||
| } | } | ||||
| void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]) | void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| int r, g, b, a; | int r, g, b, a; | ||||
| r = offset + (int)cp[0]; | r = offset + int(cp[0]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| g = offset + (int)cp[1]; | g = offset + int(cp[1]); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| b = offset + (int)cp[2]; | b = offset + int(cp[2]); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| a = (int)cp[3]; /* no shading offset... */ | a = int(cp[3]); /* no shading offset... */ | ||||
| CLAMP(a, 0, 255); | CLAMP(a, 0, 255); | ||||
| col[0] = ((float)r) / 255.0f; | col[0] = float(r) / 255.0f; | ||||
| col[1] = ((float)g) / 255.0f; | col[1] = float(g) / 255.0f; | ||||
| col[2] = ((float)b) / 255.0f; | col[2] = float(b) / 255.0f; | ||||
| col[3] = ((float)a) / 255.0f; | col[3] = float(a) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColor4ubv(int colorid, uchar col[4]) | void UI_GetThemeColor4ubv(int colorid, uchar col[4]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid); | ||||
| col[0] = cp[0]; | col[0] = cp[0]; | ||||
| col[1] = cp[1]; | col[1] = cp[1]; | ||||
| col[2] = cp[2]; | col[2] = cp[2]; | ||||
| col[3] = cp[3]; | col[3] = cp[3]; | ||||
| } | } | ||||
| void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3]) | void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | ||||
| col[0] = ((float)cp[0]) / 255.0f; | col[0] = (float(cp[0])) / 255.0f; | ||||
| col[1] = ((float)cp[1]) / 255.0f; | col[1] = (float(cp[1])) / 255.0f; | ||||
| col[2] = ((float)cp[2]) / 255.0f; | col[2] = (float(cp[2])) / 255.0f; | ||||
| } | } | ||||
| void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3]) | void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3]) | ||||
| { | { | ||||
| const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid); | ||||
| col[0] = cp[0]; | col[0] = cp[0]; | ||||
| col[1] = cp[1]; | col[1] = cp[1]; | ||||
| col[2] = cp[2]; | col[2] = cp[2]; | ||||
| Show All 36 Lines | bool UI_GetIconThemeColor4ubv(int colorid, uchar col[4]) | ||||
| return true; | return true; | ||||
| } | } | ||||
| void UI_GetColorPtrShade3ubv(const uchar cp[3], uchar col[3], int offset) | void UI_GetColorPtrShade3ubv(const uchar cp[3], uchar col[3], int offset) | ||||
| { | { | ||||
| int r, g, b; | int r, g, b; | ||||
| r = offset + (int)cp[0]; | r = offset + int(cp[0]); | ||||
| g = offset + (int)cp[1]; | g = offset + int(cp[1]); | ||||
| b = offset + (int)cp[2]; | b = offset + int(cp[2]); | ||||
| CLAMP(r, 0, 255); | CLAMP(r, 0, 255); | ||||
| CLAMP(g, 0, 255); | CLAMP(g, 0, 255); | ||||
| CLAMP(b, 0, 255); | CLAMP(b, 0, 255); | ||||
| col[0] = r; | col[0] = r; | ||||
| col[1] = g; | col[1] = g; | ||||
| col[2] = b; | col[2] = b; | ||||
| Show All 21 Lines | |||||
| void UI_ThemeClearColor(int colorid) | void UI_ThemeClearColor(int colorid) | ||||
| { | { | ||||
| float col[3]; | float col[3]; | ||||
| UI_GetThemeColor3fv(colorid, col); | UI_GetThemeColor3fv(colorid, col); | ||||
| GPU_clear_color(col[0], col[1], col[2], 1.0f); | GPU_clear_color(col[0], col[1], col[2], 1.0f); | ||||
| } | } | ||||
| int UI_ThemeMenuShadowWidth(void) | int UI_ThemeMenuShadowWidth() | ||||
| { | { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC); | return int(btheme->tui.menu_shadow_width * UI_DPI_FAC); | ||||
| } | } | ||||
| void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axis) | void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axis) | ||||
| { | { | ||||
| uchar col[3]; | uchar col[3]; | ||||
| switch (axis) { | switch (axis) { | ||||
| case 'X': | case 'X': | ||||
| Show All 16 Lines | |||||