Blender  V3.3
text_header.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "BLI_blenlib.h"
13 
14 #include "BKE_context.h"
15 #include "BKE_screen.h"
16 
17 #include "ED_screen.h"
18 
19 #include "WM_types.h"
20 
21 #include "UI_interface.h"
22 
23 #include "text_intern.h"
24 
25 /* ************************ header area region *********************** */
26 
27 /************************** properties ******************************/
28 
30 {
31  ARegion *region, *arnew;
32 
34  if (region) {
35  return region;
36  }
37 
38  /* add subdiv level; after header */
40 
41  /* is error! */
42  if (region == NULL) {
43  return NULL;
44  }
45 
46  arnew = MEM_callocN(sizeof(ARegion), "properties region");
47 
48  BLI_insertlinkafter(&area->regionbase, region, arnew);
49  arnew->regiontype = RGN_TYPE_UI;
50  arnew->alignment = RGN_ALIGN_LEFT;
51 
52  arnew->flag = RGN_FLAG_HIDDEN;
53 
54  return arnew;
55 }
56 
58 {
59  return (CTX_wm_space_text(C) != NULL);
60 }
61 
63 {
67 
68  if (region) {
69  if (region->flag & RGN_FLAG_HIDDEN) {
70  ED_region_toggle_hidden(C, region);
71  }
72 
73  UI_panel_category_active_set(region, "Text");
74 
75  /* cannot send a button activate yet for case when region wasn't visible yet */
76  /* flag gets checked and cleared in main draw callback */
77  st->flags |= ST_FIND_ACTIVATE;
78 
79  ED_region_tag_redraw(region);
80  }
81  return OPERATOR_FINISHED;
82 }
83 
85 {
86  /* identifiers */
87  ot->name = "Find";
88  ot->description = "Start searching text";
89  ot->idname = "TEXT_OT_start_find";
90 
91  /* api callbacks */
94 }
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition: context.c:806
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:301
#define UNUSED(x)
@ RGN_FLAG_HIDDEN
@ RGN_TYPE_UI
@ RGN_TYPE_HEADER
@ RGN_ALIGN_LEFT
@ ST_FIND_ACTIVATE
@ OPERATOR_FINISHED
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region)
Definition: area.c:2117
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:655
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
void UI_panel_category_active_set(struct ARegion *region, const char *idname)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
static void area(int d1, int d2, int e1, int e2, float weights[2])
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
short alignment
short regiontype
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
void TEXT_OT_start_find(wmOperatorType *ot)
Definition: text_header.c:84
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
Definition: text_header.c:62
static bool text_properties_poll(bContext *C)
Definition: text_header.c:57
static ARegion * text_has_properties_region(ScrArea *area)
Definition: text_header.c:29
wmOperatorType * ot
Definition: wm_files.c:3479