Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-06-08 09:38:27 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2016-06-08 22:45:40 +0300
commit83d794728a4cddfeddcb20731c5f7f9922ed7bb1 (patch)
treead3fcf1eb1fdbfe343916a493555bcde4e88d93b
parent321086c0de79f3aecdfc27ac617cf5f9b520ce48 (diff)
3D Text: move undo into its own file
-rw-r--r--source/blender/editors/curve/CMakeLists.txt1
-rw-r--r--source/blender/editors/curve/editfont.c58
-rw-r--r--source/blender/editors/curve/editfont_undo.c99
-rw-r--r--source/blender/editors/include/ED_curve.h6
4 files changed, 104 insertions, 60 deletions
diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt
index ebdf6bb43ff..2f5b2ab6e87 100644
--- a/source/blender/editors/curve/CMakeLists.txt
+++ b/source/blender/editors/curve/CMakeLists.txt
@@ -43,6 +43,7 @@ set(SRC
editcurve_paint.c
editcurve_select.c
editfont.c
+ editfont_undo.c
curve_intern.h
)
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 7c1fe0cadf0..053a7ee5023 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -1794,64 +1794,6 @@ void FONT_OT_unlink(wmOperatorType *ot)
ot->exec = font_unlink_exec;
}
-
-/* **************** undo for font object ************** */
-
-static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata))
-{
- Curve *cu = (Curve *)ecu;
- EditFont *ef = cu->editfont;
- const char *str = strv;
-
- ef->pos = *((const short *)str);
- ef->len = *((const short *)(str + 2));
-
- memcpy(ef->textbuf, str + 4, (ef->len + 1) * sizeof(wchar_t));
- memcpy(ef->textbufinfo, str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->len * sizeof(CharInfo));
-
- ef->selstart = ef->selend = 0;
-
-}
-
-static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata))
-{
- Curve *cu = (Curve *)ecu;
- EditFont *ef = cu->editfont;
- char *str;
-
- /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */
- str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo");
-
- /* Copy the string and string information */
- memcpy(str + 4, ef->textbuf, (ef->len + 1) * sizeof(wchar_t));
- memcpy(str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->textbufinfo, ef->len * sizeof(CharInfo));
-
- *((short *)(str + 0)) = ef->pos;
- *((short *)(str + 2)) = ef->len;
-
- return str;
-}
-
-static void free_undoFont(void *strv)
-{
- MEM_freeN(strv);
-}
-
-static void *get_undoFont(bContext *C)
-{
- Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_FONT) {
- return obedit->data;
- }
- return NULL;
-}
-
-/* and this is all the undo system needs to know */
-void undo_push_font(bContext *C, const char *name)
-{
- undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL);
-}
-
/**
* TextBox selection
*/
diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c
new file mode 100644
index 00000000000..cee10698039
--- /dev/null
+++ b/source/blender/editors/curve/editfont_undo.c
@@ -0,0 +1,99 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/curve/editfont_undo.c
+ * \ingroup edcurve
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "DNA_curve_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_context.h"
+#include "BKE_font.h"
+
+#include "ED_curve.h"
+#include "ED_util.h"
+
+/* TODO, remove */
+#define MAXTEXT 32766
+
+static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata))
+{
+ Curve *cu = (Curve *)ecu;
+ EditFont *ef = cu->editfont;
+ const char *str = strv;
+
+ ef->pos = *((const short *)str);
+ ef->len = *((const short *)(str + 2));
+
+ memcpy(ef->textbuf, str + 4, (ef->len + 1) * sizeof(wchar_t));
+ memcpy(ef->textbufinfo, str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->len * sizeof(CharInfo));
+
+ ef->selstart = ef->selend = 0;
+
+}
+
+static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata))
+{
+ Curve *cu = (Curve *)ecu;
+ EditFont *ef = cu->editfont;
+ char *str;
+
+ /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */
+ str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo");
+
+ /* Copy the string and string information */
+ memcpy(str + 4, ef->textbuf, (ef->len + 1) * sizeof(wchar_t));
+ memcpy(str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->textbufinfo, ef->len * sizeof(CharInfo));
+
+ *((short *)(str + 0)) = ef->pos;
+ *((short *)(str + 2)) = ef->len;
+
+ return str;
+}
+
+static void free_undoFont(void *strv)
+{
+ MEM_freeN(strv);
+}
+
+static void *get_undoFont(bContext *C)
+{
+ Object *obedit = CTX_data_edit_object(C);
+ if (obedit && obedit->type == OB_FONT) {
+ return obedit->data;
+ }
+ return NULL;
+}
+
+/* and this is all the undo system needs to know */
+void undo_push_font(bContext *C, const char *name)
+{
+ undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL);
+}
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index 278e3f97ba7..859d45e9c86 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -72,8 +72,7 @@ void ED_curve_deselect_all(struct EditNurb *editnurb);
void ED_curve_select_all(struct EditNurb *editnurb);
void ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles);
-/* editfont.h */
-void undo_push_font(struct bContext *C, const char *name);
+/* editfont.c */
void ED_curve_editfont_load(struct Object *obedit);
void ED_curve_editfont_make(struct Object *obedit);
void ED_curve_editfont_free(struct Object *obedit);
@@ -89,6 +88,9 @@ bool ED_curve_active_center(struct Curve *cu, float center[3]);
bool ED_curve_editfont_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+/* editfont_undo.c */
+void undo_push_font(struct bContext *C, const char *name);
+
#if 0
/* debug only */
void printknots(struct Object *obedit);