2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup editorui
|
2011-02-21 07:25:24 +00:00
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2021-02-09 09:42:58 +11:00
|
|
|
/* Required for #eIconSizes which can't be forward declared if this file is included in C++. */
|
|
|
|
#include "DNA_ID_enums.h"
|
2021-02-08 15:09:49 -06:00
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-09-30 11:51:13 +10:00
|
|
|
struct Collection;
|
2015-01-07 12:31:25 +01:00
|
|
|
struct ID;
|
This commit frees list ui items from their dependencies to Panel, and hence from all the limitations this implied (mostly, the "only one list per panel" one).
It introduces a new (py-extendable and registrable) RNA type, UIList (roughly similar to Panel one), which currently contains only "standard" list's scroll pos and size (but may be expended to include e.g. some filtering data, etc.). This now makes lists completely independent from Panels!
This UIList has a draw_item callback which allows to customize items' drawing from python, that all addons can now use. Incidentally, this also greatly simplifies the C code of this widget, as we do not code any "special case" here anymore!
To make all this work, other changes were also necessary:
* Now all buttons (uiBut struct) have a 'custom_data' void pointer, used currently to store the uiList struct associated with a given uiLayoutListBox.
* DynamicPaintSurface now exposes a new bool, use_color_preview (readonly), saying whether that surface has some 3D view preview data or not.
* UILayout class has now four new (static) functions, to get the actual icon of any RNA object (important e.g. with materials or textures), and to get an enum item's UI name, description and icon.
* UILayout's label() func now takes an optional 'icon_value' integer parameter, which if not zero will override the 'icon' one (mandatory to use "custom" icons as generated for material/texture/... previews).
Note: not sure whether we should add that one to all UILayout's prop funcs?
Note: will update addons using template list asap.
2012-12-28 09:20:16 +00:00
|
|
|
struct PointerRNA;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct PreviewImage;
|
|
|
|
struct Scene;
|
|
|
|
struct bContext;
|
2008-11-25 18:27:41 +00:00
|
|
|
|
|
|
|
typedef struct IconFile {
|
|
|
|
struct IconFile *next, *prev;
|
2012-05-12 20:39:39 +00:00
|
|
|
char filename[256]; /* FILE_MAXFILE size */
|
2008-11-25 18:27:41 +00:00
|
|
|
int index;
|
|
|
|
} IconFile;
|
|
|
|
|
2022-10-20 16:37:07 +02:00
|
|
|
typedef struct IconTextOverlay {
|
|
|
|
char text[5];
|
|
|
|
} IconTextOverlay;
|
|
|
|
|
|
|
|
#define UI_NO_ICON_OVERLAY_TEXT NULL
|
|
|
|
|
2008-11-25 18:27:41 +00:00
|
|
|
#define ICON_DEFAULT_HEIGHT 16
|
2012-05-12 20:39:39 +00:00
|
|
|
#define ICON_DEFAULT_WIDTH 16
|
2011-06-05 14:00:06 +00:00
|
|
|
|
2018-06-10 16:42:19 +02:00
|
|
|
#define ICON_DEFAULT_HEIGHT_TOOLBAR 32
|
2018-04-25 21:01:36 +02:00
|
|
|
|
2011-09-25 12:33:51 +00:00
|
|
|
#define ICON_DEFAULT_HEIGHT_SCALE ((int)(UI_UNIT_Y * 0.8f))
|
|
|
|
#define ICON_DEFAULT_WIDTH_SCALE ((int)(UI_UNIT_X * 0.8f))
|
2011-06-05 14:00:06 +00:00
|
|
|
|
2015-05-11 16:29:12 +02:00
|
|
|
#define PREVIEW_DEFAULT_HEIGHT 128
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2020-03-14 11:05:09 -07:00
|
|
|
typedef enum eAlertIcon {
|
|
|
|
ALERT_ICON_WARNING = 0,
|
|
|
|
ALERT_ICON_QUESTION = 1,
|
|
|
|
ALERT_ICON_ERROR = 2,
|
|
|
|
ALERT_ICON_INFO = 3,
|
|
|
|
ALERT_ICON_BLENDER = 4,
|
|
|
|
ALERT_ICON_MAX,
|
|
|
|
} eAlertIcon;
|
|
|
|
|
2020-09-18 10:24:14 +10:00
|
|
|
struct ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon);
|
2020-03-14 11:05:09 -07:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2012-03-03 16:31:46 +00:00
|
|
|
* Resizable Icons for Blender
|
|
|
|
*/
|
2018-07-24 12:43:21 +02:00
|
|
|
void UI_icons_init(void);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
* Reload the textures for internal icons.
|
|
|
|
* This function will release the previous textures.
|
|
|
|
*/
|
2019-05-09 15:53:44 +02:00
|
|
|
void UI_icons_reload_internal_textures(void);
|
2019-05-09 19:19:52 +02:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
* NOTE: returns unscaled by DPI.
|
|
|
|
*/
|
2008-11-25 19:23:54 +00:00
|
|
|
int UI_icon_get_width(int icon_id);
|
|
|
|
int UI_icon_get_height(int icon_id);
|
2019-05-09 17:37:26 +02:00
|
|
|
bool UI_icon_get_theme_color(int icon_id, unsigned char color[4]);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2022-01-26 15:05:31 +01:00
|
|
|
* Render a #PreviewImage for the data block.
|
|
|
|
*
|
2021-12-09 00:55:11 +11:00
|
|
|
* Note that if an ID doesn't support jobs for preview creation, \a use_job will be ignored.
|
|
|
|
*/
|
2020-09-18 10:24:14 +10:00
|
|
|
void UI_icon_render_id(const struct bContext *C,
|
2015-01-12 14:44:54 +01:00
|
|
|
struct Scene *scene,
|
|
|
|
struct ID *id,
|
2022-01-07 11:38:08 +11:00
|
|
|
enum eIconSizes size,
|
|
|
|
bool use_job);
|
2022-01-26 15:05:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the data block into the provided #PreviewImage.
|
|
|
|
*/
|
|
|
|
void UI_icon_render_id_ex(const struct bContext *C,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct ID *id_to_render,
|
|
|
|
const enum eIconSizes size,
|
|
|
|
const bool use_job,
|
|
|
|
struct PreviewImage *r_preview_image);
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
* Render size for preview images and icons
|
|
|
|
*/
|
2020-09-18 10:24:14 +10:00
|
|
|
int UI_icon_preview_to_render_size(enum eIconSizes size);
|
2015-01-07 12:31:25 +01:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2022-05-06 17:56:59 +10:00
|
|
|
* Draws icon with DPI scale factor.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2008-11-25 19:23:54 +00:00
|
|
|
void UI_icon_draw(float x, float y, int icon_id);
|
2017-02-22 16:02:43 +01:00
|
|
|
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha);
|
2019-05-09 19:19:52 +02:00
|
|
|
void UI_icon_draw_preview(float x, float y, int icon_id, float aspect, float alpha, int size);
|
|
|
|
|
|
|
|
void UI_icon_draw_ex(float x,
|
|
|
|
float y,
|
|
|
|
int icon_id,
|
|
|
|
float aspect,
|
|
|
|
float alpha,
|
|
|
|
float desaturate,
|
2019-08-06 04:20:17 +10:00
|
|
|
const uchar mono_color[4],
|
2022-10-20 16:37:07 +02:00
|
|
|
bool mono_border,
|
|
|
|
const struct IconTextOverlay *text_overlay);
|
2019-05-09 19:19:52 +02:00
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
void UI_icons_free(void);
|
2008-11-25 19:23:54 +00:00
|
|
|
void UI_icons_free_drawinfo(void *drawinfo);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2018-03-31 19:32:28 +02:00
|
|
|
void UI_icon_draw_cache_begin(void);
|
|
|
|
void UI_icon_draw_cache_end(void);
|
|
|
|
|
2008-11-25 19:23:54 +00:00
|
|
|
struct ListBase *UI_iconfile_list(void);
|
2010-11-19 02:14:18 +00:00
|
|
|
int UI_iconfile_get_index(const char *filename);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2013-01-22 11:18:41 +00:00
|
|
|
struct PreviewImage *UI_icon_to_preview(int icon_id);
|
|
|
|
|
2022-01-07 11:38:08 +11:00
|
|
|
int UI_icon_from_rnaptr(const struct bContext *C, struct PointerRNA *ptr, int rnaicon, bool big);
|
|
|
|
int UI_icon_from_idcode(int idcode);
|
2020-09-18 10:24:14 +10:00
|
|
|
int UI_icon_from_library(const struct ID *id);
|
2022-01-07 11:38:08 +11:00
|
|
|
int UI_icon_from_object_mode(int mode);
|
2020-09-18 10:24:14 +10:00
|
|
|
int UI_icon_color_from_collection(const struct Collection *collection);
|
2008-11-25 18:27:41 +00:00
|
|
|
|
2022-10-20 16:37:07 +02:00
|
|
|
void UI_icon_text_overlay_init_from_count(struct IconTextOverlay *text_overlay,
|
|
|
|
const int icon_indicator_number);
|
|
|
|
|
2020-03-02 15:09:10 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|