This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/editors/space_text/text_header.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

95 lines
2.0 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup sptext
*/
#include "DNA_windowmanager_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "ED_screen.h"
#include "WM_types.h"
#include "UI_interface.h"
#include "text_intern.h"
/* ************************ header area region *********************** */
/************************** properties ******************************/
static ARegion *text_has_properties_region(ScrArea *area)
{
ARegion *region, *arnew;
region = BKE_area_find_region_type(area, RGN_TYPE_UI);
if (region) {
return region;
}
/* add subdiv level; after header */
region = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
/* is error! */
if (region == NULL) {
return NULL;
}
arnew = MEM_callocN(sizeof(ARegion), "properties region");
BLI_insertlinkafter(&area->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_LEFT;
arnew->flag = RGN_FLAG_HIDDEN;
return arnew;
}
static bool text_properties_poll(bContext *C)
{
return (CTX_wm_space_text(C) != NULL);
}
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *area = CTX_wm_area(C);
ARegion *region = text_has_properties_region(area);
SpaceText *st = CTX_wm_space_text(C);
if (region) {
if (region->flag & RGN_FLAG_HIDDEN) {
ED_region_toggle_hidden(C, region);
}
UI_panel_category_active_set(region, "Text");
/* cannot send a button activate yet for case when region wasn't visible yet */
/* flag gets checked and cleared in main draw callback */
st->flags |= ST_FIND_ACTIVATE;
ED_region_tag_redraw(region);
}
return OPERATOR_FINISHED;
}
void TEXT_OT_start_find(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Find";
ot->description = "Start searching text";
ot->idname = "TEXT_OT_start_find";
/* api callbacks */
ot->exec = text_text_search_exec;
ot->poll = text_properties_poll;
}