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:
Diffstat (limited to 'source/blender/editors/space_text/space_text.c')
-rw-r--r--source/blender/editors/space_text/space_text.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 44aeb9158f0..7f3741e8e17 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -1,5 +1,5 @@
/**
- * $Id:
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -31,10 +31,6 @@
#include "DNA_text_types.h"
#include "DNA_object_types.h"
-#include "DNA_space_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_userdef_types.h"
#include "MEM_guardedalloc.h"
@@ -46,7 +42,6 @@
#include "BKE_context.h"
#include "BKE_screen.h"
-#include "ED_space_api.h"
#include "ED_screen.h"
#include "BIF_gl.h"
@@ -60,7 +55,6 @@
#include "RNA_access.h"
-#include "ED_markers.h"
#include "text_intern.h" // own include
@@ -124,15 +118,13 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn)
/* context changes */
switch(wmn->category) {
case NC_TEXT:
- if(!wmn->reference || wmn->reference == st->text) {
+ if(!wmn->reference || wmn->reference == st->text || wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) {
ED_area_tag_redraw(sa);
if(wmn->action == NA_EDITED)
if(st->text)
text_update_edited(st->text);
}
- else if(wmn->data == ND_DISPLAY)
- ED_area_tag_redraw(sa);
break;
case NC_SPACE:
@@ -223,19 +215,19 @@ static void text_keymap(struct wmKeyConfig *keyconf)
#endif
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0);
- RNA_string_set(kmi->ptr, "path", "space_data.font_size");
+ RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0);
- RNA_string_set(kmi->ptr, "path", "space_data.font_size");
+ RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", 1);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
- RNA_string_set(kmi->ptr, "path", "space_data.font_size");
+ RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", 0);
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0);
- RNA_string_set(kmi->ptr, "path", "space_data.font_size");
+ RNA_string_set(kmi->ptr, "data_path", "space_data.font_size");
RNA_boolean_set(kmi->ptr, "reverse", 1);
WM_keymap_add_item(keymap, "TEXT_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
@@ -313,6 +305,8 @@ static void text_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "TEXT_OT_line_break", RETKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "TEXT_OT_line_break", PADENTER, KM_PRESS, 0, 0);
+ WM_keymap_add_menu(keymap, "TEXT_MT_toolbox", RIGHTMOUSE, KM_PRESS, KM_ANY, 0);
+
WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
}
@@ -340,12 +334,18 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
static void text_main_area_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
+ ListBase *lb;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
/* own keymap */
keymap= WM_keymap_find(wm->defaultconf, "Text", SPACE_TEXT, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+
+ /* add drop boxes */
+ lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
+
+ WM_event_add_dropbox_handler(&ar->handlers, lb);
}
static void text_main_area_draw(const bContext *C, ARegion *ar)
@@ -353,11 +353,9 @@ static void text_main_area_draw(const bContext *C, ARegion *ar)
/* draw entirely, view changes should be handled here */
SpaceText *st= CTX_wm_space_text(C);
//View2D *v2d= &ar->v2d;
- float col[3];
/* clear and setup matrix */
- UI_GetThemeColor3fv(TH_BACK, col);
- glClearColor(col[0], col[1], col[2], 0.0);
+ UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
// UI_view2d_view_ortho(C, v2d);
@@ -376,6 +374,36 @@ static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
WM_cursor_set(win, BC_TEXTEDITCURSOR);
}
+
+
+/* ************* dropboxes ************* */
+
+static int text_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+{
+ if(drag->type==WM_DRAG_PATH)
+ if(ELEM(drag->icon, 0, ICON_FILE_BLANK)) /* rule might not work? */
+ return 1;
+ return 0;
+}
+
+static void text_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+ /* copy drag path to properties */
+ RNA_string_set(drop->ptr, "filepath", drag->path);
+}
+
+/* this region dropbox definition */
+static void text_dropboxes(void)
+{
+ ListBase *lb= WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
+
+ WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy);
+
+}
+
+/* ************* end drop *********** */
+
+
/****************** header region ******************/
/* add handlers, stuff you only do once or on area/region changes */
@@ -421,6 +449,7 @@ void ED_spacetype_text(void)
st->keymap= text_keymap;
st->listener= text_listener;
st->context= text_context;
+ st->dropboxes = text_dropboxes;
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype text region");
@@ -435,7 +464,7 @@ void ED_spacetype_text(void)
art= MEM_callocN(sizeof(ARegionType), "spacetype text region");
art->regionid = RGN_TYPE_UI;
art->prefsizex= UI_COMPACT_PANEL_WIDTH;
- art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
+ art->keymapflag= ED_KEYMAP_UI;
art->init= text_properties_area_init;
art->draw= text_properties_area_draw;