[Bf-blender-cvs] [fdb2c24c097] master: Cleanup: move some drawing code into ed_draw.c
Christoph Lendenfeld
noreply at git.blender.org
Mon Mar 1 16:23:26 CET 2021
Commit: fdb2c24c097d9a4613493659533863efc3c6f809
Author: Christoph Lendenfeld
Date: Mon Mar 1 16:20:55 2021 +0100
Branches: master
https://developer.blender.org/rBfdb2c24c097d9a4613493659533863efc3c6f809
Cleanup: move some drawing code into ed_draw.c
Move some drawing code from `area.c` and `ed_util.c` into `ed_draw.c`.
This is to support the new generic slider that wil be used in T81785.
No functional changes.
Reviewed By: #animation_rigging, #user_interface, Severin, sybren
Maniphest Tasks: T81785
Differential Revision: https://developer.blender.org/D9313
===================================================================
M source/blender/editors/gpencil/gpencil_uv.c
M source/blender/editors/include/ED_screen.h
M source/blender/editors/include/ED_space_api.h
M source/blender/editors/include/ED_util.h
M source/blender/editors/mesh/editmesh_bevel.c
M source/blender/editors/mesh/editmesh_inset.c
M source/blender/editors/screen/area.c
M source/blender/editors/space_clip/clip_draw.c
M source/blender/editors/space_image/image_draw.c
M source/blender/editors/space_image/space_image.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/util/CMakeLists.txt
A source/blender/editors/util/ed_draw.c
M source/blender/editors/util/ed_util.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c
index 677451eaabc..6bd0540a9d4 100644
--- a/source/blender/editors/gpencil/gpencil_uv.c
+++ b/source/blender/editors/gpencil/gpencil_uv.c
@@ -44,6 +44,7 @@
#include "ED_numinput.h"
#include "ED_screen.h"
#include "ED_space_api.h"
+#include "ED_util.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index deb6b7502c7..61e1f0fdf7d 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -123,8 +123,6 @@ void ED_region_info_draw_multiline(ARegion *region,
const char *text_array[],
float fill_color[4],
const bool full_redraw);
-void ED_region_image_metadata_draw(
- int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout);
void ED_region_grid_draw(struct ARegion *region, float zoomx, float zoomy, float x0, float y0);
float ED_region_blend_alpha(struct ARegion *region);
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index c50bbc2f1e9..fc474ea464d 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -76,11 +76,6 @@ void ED_region_draw_cb_exit(struct ARegionType *, void *);
void ED_region_draw_cb_remove_by_type(struct ARegionType *art,
void *draw_fn,
void (*free)(void *));
-/* generic callbacks */
-/* ed_util.c */
-void ED_region_draw_mouse_line_cb(const struct bContext *C,
- struct ARegion *region,
- void *arg_info);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 073186f6335..953f26aa45f 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -53,6 +53,14 @@ void ED_spacedata_id_remap(struct ScrArea *area,
void ED_operatortypes_edutils(void);
+/* Drawing */
+void ED_region_draw_mouse_line_cb(const struct bContext *C,
+ struct ARegion *region,
+ void *arg_info);
+
+void ED_region_image_metadata_draw(
+ int x, int y, struct ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy);
+
/* ************** XXX OLD CRUFT WARNING ************* */
void apply_keyb_grid(
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 66a7b97b440..340a7ae92ff 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -50,6 +50,7 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_transform.h"
+#include "ED_util.h"
#include "ED_view3d.h"
#include "mesh_intern.h" /* own include */
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 9000a942e50..73d79805f60 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -46,6 +46,7 @@
#include "ED_screen.h"
#include "ED_space_api.h"
#include "ED_transform.h"
+#include "ED_util.h"
#include "ED_view3d.h"
#include "mesh_intern.h" /* own include */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 2c71345699f..bd2b1c4c553 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -3516,297 +3516,6 @@ void ED_region_info_draw(ARegion *region,
ED_region_info_draw_multiline(region, text_array, fill_color, full_redraw);
}
-#define MAX_METADATA_STR 1024
-
-static const char *meta_data_list[] = {
- "File",
- "Strip",
- "Date",
- "RenderTime",
- "Note",
- "Marker",
- "Time",
- "Frame",
- "Camera",
- "Scene",
-};
-
-BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int offset)
-{
- return (IMB_metadata_get_field(
- ibuf->metadata, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) &&
- r_str[0]);
-}
-
-BLI_INLINE bool metadata_is_custom_drawable(const char *field)
-{
- /* Metadata field stored by Blender for multilayer EXR images. Is rather
- * useless to be viewed all the time. Can still be seen in the Metadata
- * panel. */
- if (STREQ(field, "BlenderMultiChannel")) {
- return false;
- }
- /* Is almost always has value "scanlineimage", also useless to be seen
- * all the time. */
- if (STREQ(field, "type")) {
- return false;
- }
- return !BKE_stamp_is_known_field(field);
-}
-
-typedef struct MetadataCustomDrawContext {
- int fontid;
- int xmin, ymin;
- int vertical_offset;
- int current_y;
-} MetadataCustomDrawContext;
-
-static void metadata_custom_draw_fields(const char *field, const char *value, void *ctx_v)
-{
- if (!metadata_is_custom_drawable(field)) {
- return;
- }
- MetadataCustomDrawContext *ctx = (MetadataCustomDrawContext *)ctx_v;
- char temp_str[MAX_METADATA_STR];
- BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: %s", field, value);
- BLF_position(ctx->fontid, ctx->xmin, ctx->ymin + ctx->current_y, 0.0f);
- BLF_draw(ctx->fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- ctx->current_y += ctx->vertical_offset;
-}
-
-static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
-{
- char temp_str[MAX_METADATA_STR];
- int ofs_y = 0;
- const float height = BLF_height_max(fontid);
- const float margin = height / 8;
- const float vertical_offset = (height + margin);
-
- /* values taking margins into account */
- const float descender = BLF_descender(fontid);
- const float xmin = (rect->xmin + margin);
- const float xmax = (rect->xmax - margin);
- const float ymin = (rect->ymin + margin) - descender;
- const float ymax = (rect->ymax - margin) - descender;
-
- if (is_top) {
- for (int i = 0; i < 4; i++) {
- /* first line */
- if (i == 0) {
- bool do_newline = false;
- int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
- if (metadata_is_valid(ibuf, temp_str, 0, len)) {
- BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
- BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- do_newline = true;
- }
-
- len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
- if (metadata_is_valid(ibuf, temp_str, 1, len)) {
- int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
- BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- do_newline = true;
- }
-
- if (do_newline) {
- ofs_y += vertical_offset;
- }
- } /* Strip */
- else if (ELEM(i, 1, 2)) {
- int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
- if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
- BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
- BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- ofs_y += vertical_offset;
- }
- } /* Note (wrapped) */
- else if (i == 3) {
- int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
- if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
- struct ResultBLF info;
- BLF_enable(fontid, BLF_WORD_WRAP);
- BLF_wordwrap(fontid, ibuf->x - (margin * 2));
- BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
- BLF_draw_ex(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX, &info);
- BLF_wordwrap(fontid, 0);
- BLF_disable(fontid, BLF_WORD_WRAP);
- ofs_y += vertical_offset * info.lines;
- }
- }
- else {
- int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
- if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
- int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
- BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
- ofs_y += vertical_offset;
- }
- }
- }
- }
- else {
- MetadataCustomDrawContext ctx;
- ctx.fontid = fontid;
- ctx.xmin = xmin;
- ctx.ymin = ymin;
- ctx.current_y = ofs_y;
- ctx.vertical_offset = vertical_offset;
- IMB_metadata_foreach(ibuf, metadata_custom_draw_fields, &ctx);
- int ofs_x = 0;
- ofs_y = ctx.current_y;
- for (int i = 5; i < 10; i++) {
- int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
- if (metadata_is_valid(ibuf, temp_str, i, len)) {
- BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f);
- BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
-
- ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
- }
- }
- }
-}
-
-typedef struct MetadataCustomCountContext {
- int count;
-} MetadataCustomCountContext;
-
-static void metadata_custom_count_fields(const char *field, const char *UNUSED(value), void *ctx_v)
-{
- if (!metadata_is_custom_drawable(field)) {
- return;
- }
- MetadataCustomCountContext *ctx = (MetadataCustomCountContext *)ctx_v;
- ctx->count++;
-}
-
-static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
-{
- const float height = BLF_height_max(fontid);
- const float margin = (height / 8);
- char str[MAX_METADATA_STR] = "";
- short count = 0;
-
- if (is_top) {
- if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
- count++;
- }
- for (int i = 2; i < 5; i++) {
- if (metadata_is_valid(ibuf, str, i, 0)) {
- if (i == 4) {
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list