diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-08-01 18:39:48 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-08-01 18:56:44 +0300 |
commit | 47bc66fc8dfe2b89e2b5be029c63f9043c8c2174 (patch) | |
tree | d9756829bb6313f82f7ae99e467ec65580156a40 /source/blender/editors/transform/transform.c | |
parent | 31bf82c17d780660160ebf4e1a4be004b8933b9d (diff) |
Note Editor: Auto-offset nodes on insertion
Implements "Auto-offset" (called "insert offset" in code) feature for Node Editor, developed during and after LSOC :)
Idea and sponsoring by Sebastian König, blendFX, Mathias Eimann, Mikavaa, Knick Design
When you drop a node with at least one input and one output socket onto a an existing connection between two nodes, Auto-offset will, depending on the direction setting, automatically and animated move the left or right and all of its following nodes away to make room for the new node.
The direction for offsetting can be toggled while you are moving the node by pressing „T“.
The auto-offset is enabled by default but can be disabled in the header of the node-editor. The offset margin can be changed in the editing section of the User Preferences.
Thanks a lot to the sponsors, and especially to Sebastian who helped *a lot* with this. That's how users can help developing Blender!
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index adef32dd4ca..a889faba9a4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -799,6 +799,8 @@ enum { /* for analog input, like trackpad */ TFM_MODAL_PROPSIZE = 26, +/* node editor insert offset (aka auto-offset) direction toggle */ + TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, }; /* called in transform_ops.c, on each regeneration of keymaps */ @@ -831,6 +833,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_EDGESLIDE_UP, "EDGESLIDE_EDGE_NEXT", 0, "Select next Edge Slide Edge", ""}, {TFM_MODAL_EDGESLIDE_DOWN, "EDGESLIDE_PREV_NEXT", 0, "Select previous Edge Slide Edge", ""}, {TFM_MODAL_PROPSIZE, "PROPORTIONAL_SIZE", 0, "Adjust Proportional Influence", ""}, + {TFM_MODAL_INSERTOFS_TOGGLE_DIR, "INSERTOFS_TOGGLE_DIR", 0, "Toggle Direction for Node Auto-offset", ""}, {0, NULL, 0, NULL, NULL} }; @@ -879,7 +882,10 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_DEC); WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_INC); WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOIK_LEN_DEC); - + + /* node editor only */ + WM_modalkeymap_add_item(keymap, TKEY, KM_PRESS, 0, 0, TFM_MODAL_INSERTOFS_TOGGLE_DIR); + return keymap; } @@ -1240,6 +1246,25 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } break; + case TFM_MODAL_INSERTOFS_TOGGLE_DIR: + if (t->spacetype == SPACE_NODE) { + SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + + BLI_assert(t->sa->spacetype == t->spacetype); + + if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) { + snode->insert_ofs_dir = SNODE_INSERTOFS_DIR_LEFT; + } + else if (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_LEFT) { + snode->insert_ofs_dir = SNODE_INSERTOFS_DIR_RIGHT; + } + else { + BLI_assert(0); + } + + t->redraw |= TREDRAW_SOFT; + } + break; /* Those two are only handled in transform's own handler, see T44634! */ case TFM_MODAL_EDGESLIDE_UP: case TFM_MODAL_EDGESLIDE_DOWN: @@ -4246,6 +4271,23 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[MAX_INF if (t->flag & T_PROP_EDIT_ALL) { ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size); } + + if (t->spacetype == SPACE_NODE) { + SpaceNode *snode = (SpaceNode *)t->sa->spacedata.first; + + if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { + const char *str_old = BLI_strdup(str); + const char *str_dir = (snode->insert_ofs_dir == SNODE_INSERTOFS_DIR_RIGHT) ? "right" : "left"; + char str_km[MAX_INFO_LEN]; + + WM_modalkeymap_items_to_string(t->keymap, TFM_MODAL_INSERTOFS_TOGGLE_DIR, true, sizeof(str_km), str_km); + + ofs += BLI_snprintf(str, MAX_INFO_LEN, "Auto-offset set to %s - press %s to toggle direction | %s", + str_dir, str_km, str_old); + + MEM_freeN((void *)str_old); + } + } } static void applyTranslationValue(TransInfo *t, const float vec[3]) |