From 69d66f98a8a3d9b40d9bcb1c6bbfb641b6b1b9b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Oct 2013 23:42:44 +0000 Subject: patch [#37114] copypaste for NORMAL buttons (BUT_NORMAL) from Philipp Oeser (lichtwerk) --- .../blender/editors/interface/interface_handlers.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 296db88dce8..ad36958f6f8 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1376,6 +1376,32 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } + /* NORMAL button */ + else if (but->type == BUT_NORMAL) { + float xyz[3]; + + if (but->poin == NULL && but->rnapoin.data == NULL) { + /* pass */ + } + else if (mode == 'c') { + ui_get_but_vectorf(but, xyz); + BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", xyz[0], xyz[1], xyz[2]); + WM_clipboard_text_set(buf, 0); + } + else { + if (sscanf(buf, "[%f, %f, %f]", &xyz[0], &xyz[1], &xyz[2]) == 3) { + if (normalize_v3(xyz) == 0.0f) { + /* better set Z up then have a zero vector */ + xyz[2] = 1.0; + } + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); + ui_set_but_vectorf(but, xyz); + button_activate_state(C, but, BUTTON_STATE_EXIT); + } + } + } + + /* RGB triple */ else if (but->type == COLOR) { float rgba[4]; -- cgit v1.2.3