[Bf-blender-cvs] [7a1e73e] temp-text_editor_cursor_api: move text-space api func into rna_space_api.c
Campbell Barton
noreply at git.blender.org
Tue Dec 30 10:49:48 CET 2014
Commit: 7a1e73e006fc740f905d4217b2b79b0557bb8904
Author: Campbell Barton
Date: Tue Dec 30 20:49:15 2014 +1100
Branches: temp-text_editor_cursor_api
https://developer.blender.org/rB7a1e73e006fc740f905d4217b2b79b0557bb8904
move text-space api func into rna_space_api.c
===================================================================
M source/blender/makesrna/intern/rna_internal.h
M source/blender/makesrna/intern/rna_space.c
M source/blender/makesrna/intern/rna_space_api.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 051e727..64a50d4 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -287,6 +287,7 @@ void RNA_api_ui_layout(struct StructRNA *srna);
void RNA_api_window(struct StructRNA *srna);
void RNA_api_wm(struct StructRNA *srna);
void RNA_api_space_node(struct StructRNA *srna);
+void RNA_api_space_text(struct StructRNA *srna);
void RNA_api_region_view3d(struct StructRNA *srna);
void RNA_api_sensor(struct StructRNA *srna);
void RNA_api_controller(struct StructRNA *srna);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7b87cf1..5c0c32b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -210,7 +210,6 @@ static EnumPropertyItem buttons_texture_context_items[] = {
#include "ED_view3d.h"
#include "ED_sequencer.h"
#include "ED_clip.h"
-#include "ED_text.h"
#include "GPU_material.h"
@@ -851,16 +850,6 @@ static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain), Scene *UNUSED(
WM_main_add_notifier(NC_TEXT | NA_EDITED, st->text);
}
-static void rna_SpaceTextEditor_cursor_to_pixel_space(ID *id, SpaceText *st, int cursor_co[2], int r_pixel_pos[2])
-{
- bScreen *sc = (bScreen *)id;
- ScrArea *sa = BKE_screen_find_area_from_space(sc, (SpaceLink *)st);
- if (sa) {
- ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- ED_text_cursor_to_pixel_space(st, ar, cursor_co, r_pixel_pos);
- }
-}
-
/* Space Properties */
/* note: this function exists only to avoid id refcounting */
@@ -2645,8 +2634,7 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
static void rna_def_space_text(BlenderRNA *brna)
{
StructRNA *srna;
- PropertyRNA *prop, *parm;
- FunctionRNA *func;
+ PropertyRNA *prop;
srna = RNA_def_struct(brna, "SpaceTextEditor", "Space");
RNA_def_struct_sdna(srna, "SpaceText");
@@ -2754,13 +2742,7 @@ static void rna_def_space_text(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TEXT, NULL);
- func = RNA_def_function(srna, "cursor_to_pixel_space", "rna_SpaceTextEditor_cursor_to_pixel_space");
- RNA_def_function_ui_description(func, "Retrieve the screen position in pixels from the given line and character position");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID);
- parm = RNA_def_int_array(func, "cursor", 2, 0, 0, INT_MAX, "", "Text Position, line and character in line", 0, INT_MAX);
- RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_int_array(func, "result", 2, 0, -1, INT_MAX, "", "Screen Position in Pixels", -1, INT_MAX);
- RNA_def_function_output(func, parm);
+ RNA_api_space_text(srna);
}
static void rna_def_space_dopesheet(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_space_api.c b/source/blender/makesrna/intern/rna_space_api.c
index aed7737..ae12e47 100644
--- a/source/blender/makesrna/intern/rna_space_api.c
+++ b/source/blender/makesrna/intern/rna_space_api.c
@@ -31,6 +31,8 @@
#ifdef RNA_RUNTIME
+#include "ED_text.h"
+
static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
{
bScreen *sc = (bScreen *)id;
@@ -49,6 +51,16 @@ static void rna_RegionView3D_update(ID *id, RegionView3D *rv3d)
}
}
+static void rna_SpaceTextEditor_cursor_to_pixel_space(ID *id, SpaceText *st, int cursor_co[2], int r_pixel_pos[2])
+{
+ bScreen *sc = (bScreen *)id;
+ ScrArea *sa = BKE_screen_find_area_from_space(sc, (SpaceLink *)st);
+ if (sa) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ ED_text_cursor_to_pixel_space(st, ar, cursor_co, r_pixel_pos);
+ }
+}
+
#else
void RNA_api_region_view3d(StructRNA *srna)
@@ -74,4 +86,18 @@ void RNA_api_space_node(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
}
+void RNA_api_space_text(StructRNA *srna)
+{
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ func = RNA_def_function(srna, "cursor_to_pixel_space", "rna_SpaceTextEditor_cursor_to_pixel_space");
+ RNA_def_function_ui_description(func, "Retrieve the screen position in pixels from the given line and character position");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+ parm = RNA_def_int_array(func, "cursor", 2, 0, 0, INT_MAX, "", "Text Position, line and character in line", 0, INT_MAX);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_int_array(func, "result", 2, 0, -1, INT_MAX, "", "Screen Position in Pixels", -1, INT_MAX);
+ RNA_def_function_output(func, parm);
+}
+
#endif
More information about the Bf-blender-cvs
mailing list