Blender  V2.93
sequencer_buttons.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 by Blender Foundation
17  * All rights reserved.
18  */
19 
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "BLI_listbase.h"
30 #include "BLI_utildefines.h"
31 
32 #include "BLT_translation.h"
33 
34 #include "BKE_context.h"
35 #include "BKE_global.h"
36 #include "BKE_screen.h"
37 
38 #include "ED_screen.h"
39 #include "ED_sequencer.h"
40 
41 #include "IMB_imbuf.h"
42 #include "IMB_imbuf_types.h"
43 
44 #include "sequencer_intern.h"
45 
46 /* **************************** buttons ********************************* */
47 
48 #if 0
49 static bool sequencer_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt))
50 {
51  SpaceSeq *sseq = CTX_wm_space_seq(C);
52 
53  /* Don't show the gpencil if we are not showing the image. */
55 }
56 #endif
57 
59 {
60  SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
61  if (space_sequencer == NULL) {
62  return false;
63  }
64  return ED_space_sequencer_check_show_imbuf(space_sequencer);
65 }
66 
67 static void metadata_panel_context_draw(const bContext *C, Panel *panel)
68 {
69  /* Image buffer can not be acquired during render, similar to
70  * draw_image_seq(). */
71  if (G.is_rendering) {
72  return;
73  }
74  struct Main *bmain = CTX_data_main(C);
76  struct Scene *scene = CTX_data_scene(C);
77  ARegion *region = CTX_wm_region(C);
78  SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
79  /* NOTE: We can only reliably show metadata for the original (current)
80  * frame when split view is used. */
81  const bool show_split = (scene->ed && (scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) &&
82  (space_sequencer->mainb == SEQ_DRAW_IMG_IMBUF));
83  if (show_split && space_sequencer->overlay_type == SEQ_DRAW_OVERLAY_REFERENCE) {
84  return;
85  }
86  /* NOTE: We disable multiview for drawing, since we don't know what is the
87  * from the panel (is kind of all the views?). */
88  ImBuf *ibuf = sequencer_ibuf_get(
89  bmain, region, depsgraph, scene, space_sequencer, scene->r.cfra, 0, "");
90  if (ibuf != NULL) {
92  IMB_freeImBuf(ibuf);
93  }
94 }
95 
97 {
98  PanelType *pt;
99 
100 #if 0
101  pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
102  strcpy(pt->idname, "SEQUENCER_PT_gpencil");
103  strcpy(pt->label, N_("Grease Pencil"));
105  pt->draw_header = ED_gpencil_panel_standard_header;
106  pt->draw = ED_gpencil_panel_standard;
107  pt->poll = sequencer_grease_pencil_panel_poll;
108  BLI_addtail(&art->paneltypes, pt);
109 #endif
110 
111  pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel metadata");
112  strcpy(pt->idname, "SEQUENCER_PT_metadata");
113  strcpy(pt->label, N_("Metadata"));
118  pt->order = 10;
119  BLI_addtail(&art->paneltypes, pt);
120 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct SpaceSeq * CTX_wm_space_seq(const bContext *C)
Definition: context.c:827
struct Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
Definition: context.c:1415
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
@ PANEL_TYPE_DEFAULT_CLOSED
Definition: BKE_screen.h:297
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
#define UNUSED(x)
#define BLT_I18NCONTEXT_DEFAULT_BPYRNA
#define N_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
#define SEQ_EDIT_OVERLAY_SHOW
@ SEQ_DRAW_OVERLAY_REFERENCE
@ SEQ_DRAW_IMG_IMBUF
void ED_region_image_metadata_panel_draw(struct ImBuf *ibuf, struct uiLayout *layout)
Definition: area.c:3531
bool ED_space_sequencer_check_show_imbuf(struct SpaceSeq *sseq)
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
Scene scene
const Depsgraph * depsgraph
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
void sequencer_buttons_register(ARegionType *art)
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
ImBuf * sequencer_ibuf_get(struct Main *bmain, ARegion *region, struct Depsgraph *depsgraph, Scene *scene, SpaceSeq *sseq, int timeline_frame, int frame_ofs, const char *viewname)
ListBase paneltypes
Definition: BKE_screen.h:216
Definition: BKE_main.h:116
void(* draw)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:266
bool(* poll)(const struct bContext *C, struct PanelType *pt)
Definition: BKE_screen.h:260
void(* draw_header)(const struct bContext *C, struct Panel *panel)
Definition: BKE_screen.h:262
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:241
char translation_context[BKE_ST_MAXNAME]
Definition: BKE_screen.h:244
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:242
struct uiLayout * layout
struct Editing * ed
struct RenderData r
#define G(x, y, z)