diff options
-rw-r--r-- | source/blender/editors/space_logic/logic_ops.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_logic/logic_window.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_logic/space_logic.c | 2 |
3 files changed, 39 insertions, 2 deletions
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 74be7c46d26..e9139271f18 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -54,6 +54,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "UI_view2d.h" + #include "logic_intern.h" // temporary new includes for texface functions @@ -723,6 +725,39 @@ static void LOGIC_OT_texface_convert(wmOperatorType *ot) } +/* ************************ view ********************* */ + +static int logic_view_all_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ARegion *ar = CTX_wm_region(C); + rctf cur_new = ar->v2d.tot; + float aspect = BLI_rctf_size_y(&ar->v2d.cur) / BLI_rctf_size_x(&ar->v2d.cur); + + /* force the view2d code to zoom to width, not height */ + cur_new.ymin = cur_new.ymax - BLI_rctf_size_x(&cur_new) * aspect; + + UI_view2d_smooth_view(C, ar, &cur_new); + + return OPERATOR_FINISHED; +} + +static void LOGIC_OT_view_all(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "View All"; + ot->idname = "LOGIC_OT_view_all"; + ot->description = "Resize view so you can see all logic bricks"; + + /* api callbacks */ + ot->exec = logic_view_all_exec; + ot->poll = ED_operator_logic_active; + + /* flags */ + ot->flag = 0; +} + +/* ************************* */ + void ED_operatortypes_logic(void) { WM_operatortype_append(LOGIC_OT_sensor_remove); @@ -735,4 +770,5 @@ void ED_operatortypes_logic(void) WM_operatortype_append(LOGIC_OT_actuator_add); WM_operatortype_append(LOGIC_OT_actuator_move); WM_operatortype_append(LOGIC_OT_texface_convert); + WM_operatortype_append(LOGIC_OT_view_all); } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index a7599f21ad5..f46151fd33a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -2226,6 +2226,7 @@ void logic_buttons(bContext *C, ARegion *ar) BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS); uiBlockSetHandleFunc(block, do_logic_buts, NULL); + uiBoundsBlock(block, U.widget_unit/2); /* loop over all objects and set visible/linked flags for the logic bricks */ for (a=0; a<count; a++) { @@ -2516,7 +2517,7 @@ void logic_buttons(bContext *C, ARegion *ar) uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ height = MIN2(height, yco); - UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height); + UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height - U.widget_unit); /* set the view */ UI_view2d_view_ortho(&ar->v2d); diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 8795d655e77..3f3c81f2bfa 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -183,7 +183,7 @@ static void logic_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "VIEW2D_OT_reset", HOMEKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); } |