Blender
V2.93
source
blender
editors
space_text
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
24
#include "
DNA_windowmanager_types.h
"
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
45
static
ARegion
*
text_has_properties_region
(
ScrArea
*
area
)
46
{
47
ARegion
*region, *arnew;
48
49
region =
BKE_area_find_region_type
(
area
,
RGN_TYPE_UI
);
50
if
(region) {
51
return
region;
52
}
53
54
/* add subdiv level; after header */
55
region =
BKE_area_find_region_type
(
area
,
RGN_TYPE_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
73
static
bool
text_properties_poll
(
bContext
*
C
)
74
{
75
return
(
CTX_wm_space_text
(
C
) !=
NULL
);
76
}
77
78
static
int
text_text_search_exec
(
bContext
*
C
,
wmOperator
*
UNUSED
(op))
79
{
80
ScrArea
*
area
=
CTX_wm_area
(
C
);
81
ARegion
*region =
text_has_properties_region
(
area
);
82
SpaceText
*st =
CTX_wm_space_text
(
C
);
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
100
void
TEXT_OT_start_find
(
wmOperatorType
*
ot
)
101
{
102
/* identifiers */
103
ot
->
name
=
"Find"
;
104
ot
->
description
=
"Start searching text"
;
105
ot
->
idname
=
"TEXT_OT_start_find"
;
106
107
/* api callbacks */
108
ot
->
exec
=
text_text_search_exec
;
109
ot
->
poll
=
text_properties_poll
;
110
}
BKE_context.h
CTX_wm_area
struct ScrArea * CTX_wm_area(const bContext *C)
Definition:
context.c:714
CTX_wm_space_text
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition:
context.c:782
BKE_screen.h
BKE_area_find_region_type
struct ARegion * BKE_area_find_region_type(const struct ScrArea *area, int type)
BLI_blenlib.h
BLI_insertlinkafter
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition:
listbase.c:352
UNUSED
#define UNUSED(x)
Definition:
BLI_utildefines.h:683
RGN_ALIGN_LEFT
@ RGN_ALIGN_LEFT
Definition:
DNA_screen_types.h:664
RGN_FLAG_HIDDEN
@ RGN_FLAG_HIDDEN
Definition:
DNA_screen_types.h:682
RGN_TYPE_UI
@ RGN_TYPE_UI
Definition:
DNA_screen_types.h:633
RGN_TYPE_HEADER
@ RGN_TYPE_HEADER
Definition:
DNA_screen_types.h:630
ST_FIND_ACTIVATE
@ ST_FIND_ACTIVATE
Definition:
DNA_space_types.h:1453
DNA_windowmanager_types.h
OPERATOR_FINISHED
@ OPERATOR_FINISHED
Definition:
DNA_windowmanager_types.h:550
ED_screen.h
ED_region_toggle_hidden
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *region)
Definition:
area.c:2059
ED_region_tag_redraw
void ED_region_tag_redraw(struct ARegion *region)
Definition:
area.c:667
MEM_guardedalloc.h
Read Guarded memory(de)allocation.
C
#define C
Definition:
RandGen.cpp:39
UI_interface.h
UI_panel_category_active_set
void UI_panel_category_active_set(struct ARegion *region, const char *idname)
Definition:
interface_panel.c:2299
WM_types.h
NULL
return NULL
Definition:
bmesh_operator_api_inline.h:224
MEM_callocN
void *(* MEM_callocN)(size_t len, const char *str)
Definition:
mallocn.c:45
blender::compositor::area
static void area(int d1, int d2, int e1, int e2, float weights[2])
Definition:
COM_SMAAOperation.cc:123
ARegion
Definition:
DNA_screen_types.h:439
ARegion::flag
short flag
Definition:
DNA_screen_types.h:458
ARegion::alignment
short alignment
Definition:
DNA_screen_types.h:456
ARegion::regiontype
short regiontype
Definition:
DNA_screen_types.h:454
ScrArea
Definition:
DNA_screen_types.h:360
SpaceText
Definition:
DNA_space_types.h:1392
SpaceText::flags
short flags
Definition:
DNA_space_types.h:1410
bContext
Definition:
context.c:69
wmOperatorType
Definition:
WM_types.h:719
wmOperatorType::name
const char * name
Definition:
WM_types.h:721
wmOperatorType::idname
const char * idname
Definition:
WM_types.h:723
wmOperatorType::poll
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition:
WM_types.h:776
wmOperatorType::description
const char * description
Definition:
WM_types.h:726
wmOperatorType::exec
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition:
WM_types.h:736
wmOperator
Definition:
DNA_windowmanager_types.h:512
TEXT_OT_start_find
void TEXT_OT_start_find(wmOperatorType *ot)
Definition:
text_header.c:100
text_text_search_exec
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
Definition:
text_header.c:78
text_properties_poll
static bool text_properties_poll(bContext *C)
Definition:
text_header.c:73
text_has_properties_region
static ARegion * text_has_properties_region(ScrArea *area)
Definition:
text_header.c:45
text_intern.h
ot
wmOperatorType * ot
Definition:
wm_files.c:3156
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1