Blender  V2.93
text_header.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) 2008 Blender Foundation.
17  * All rights reserved.
18  */
19 
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "BLI_blenlib.h"
29 
30 #include "BKE_context.h"
31 #include "BKE_screen.h"
32 
33 #include "ED_screen.h"
34 
35 #include "WM_types.h"
36 
37 #include "UI_interface.h"
38 
39 #include "text_intern.h"
40 
41 /* ************************ header area region *********************** */
42 
43 /************************** properties ******************************/
44 
46 {
47  ARegion *region, *arnew;
48 
50  if (region) {
51  return region;
52  }
53 
54  /* add subdiv level; after header */
56 
57  /* is error! */
58  if (region == NULL) {
59  return NULL;
60  }
61 
62  arnew = MEM_callocN(sizeof(ARegion), "properties region");
63 
64  BLI_insertlinkafter(&area->regionbase, region, arnew);
65  arnew->regiontype = RGN_TYPE_UI;
66  arnew->alignment = RGN_ALIGN_LEFT;
67 
68  arnew->flag = RGN_FLAG_HIDDEN;
69 
70  return arnew;
71 }
72 
74 {
75  return (CTX_wm_space_text(C) != NULL);
76 }
77 
79 {
83 
84  if (region) {
85  if (region->flag & RGN_FLAG_HIDDEN) {
86  ED_region_toggle_hidden(C, region);
87  }
88 
89  UI_panel_category_active_set(region, "Text");
90 
91  /* cannot send a button activate yet for case when region wasn't visible yet */
92  /* flag gets checked and cleared in main draw callback */
93  st->flags |= ST_FIND_ACTIVATE;
94 
95  ED_region_tag_redraw(region);
96  }
97  return OPERATOR_FINISHED;
98 }
99 
101 {
102  /* identifiers */
103  ot->name = "Find";
104  ot->description = "Start searching text";
105  ot->idname = "TEXT_OT_start_find";
106 
107  /* api callbacks */
110 }
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition: context.c:782
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:352
#define UNUSED(x)
@ RGN_ALIGN_LEFT
@ RGN_FLAG_HIDDEN
@ RGN_TYPE_UI
@ RGN_TYPE_HEADER
@ ST_FIND_ACTIVATE
@ OPERATOR_FINISHED
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region)
Definition: area.c:2059
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
void UI_panel_category_active_set(struct ARegion *region, const char *idname)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void area(int d1, int d2, int e1, int e2, float weights[2])
short alignment
short regiontype
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
void TEXT_OT_start_find(wmOperatorType *ot)
Definition: text_header.c:100
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
Definition: text_header.c:78
static bool text_properties_poll(bContext *C)
Definition: text_header.c:73
static ARegion * text_has_properties_region(ScrArea *area)
Definition: text_header.c:45
wmOperatorType * ot
Definition: wm_files.c:3156