diff options
author | Ton Roosendaal <ton@blender.org> | 2012-10-30 19:33:03 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2012-10-30 19:33:03 +0400 |
commit | 5753ede9a5cda9e23cc346ca57f6fb677e9fbb92 (patch) | |
tree | e7c3643f0f582f555a04ab34af5da511f84bfcd0 /source/blender | |
parent | a1856a38f68b5fbb51194fe5f2d09315961bc67a (diff) |
Usability: Logic editor
- View now restricts to the actual region you work on. Makes zoom and pan nicer.
- Added HOME for reset view to 1:1 zoom level.
Also: fixed nasty bug in view2d code that checked validity of 2d views, only
showed (afaik) in the logic eidtor though.
Effect was that zoom in/out would weirdly jump when going across zoomlevel 1.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_logic/logic_window.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_logic/space_logic.c | 30 |
3 files changed, 34 insertions, 23 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index fb7a2615583..f1a3f59bc22 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -599,7 +599,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) { /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */ temp = BLI_rctf_cent_x(tot); - diff = curheight * 0.5f; + diff = curwidth * 0.5f; cur->xmin = temp - diff; cur->xmax = temp + diff; diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index bffabe6d160..5a8a7cef119 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -56,6 +56,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_sca.h" +#include "BKE_screen.h" #include "ED_util.h" @@ -66,6 +67,7 @@ #include "BLF_translation.h" #include "UI_interface.h" +#include "UI_view2d.h" #include "RNA_access.h" @@ -2208,15 +2210,13 @@ void logic_buttons(bContext *C, ARegion *ar) SpaceLogic *slogic= CTX_wm_space_logic(C); Object *ob= CTX_data_active_object(C); ID **idar; - PointerRNA logic_ptr, settings_ptr, object_ptr; - uiLayout *layout, *row, *box; uiBlock *block; uiBut *but; char uiblockstr[32]; short a, count; - int xco, yco, width; + int xco, yco, width, height; if (ob==NULL) return; @@ -2270,7 +2270,7 @@ void logic_buttons(bContext *C, ARegion *ar) /* ****************** Controllers ****************** */ - xco= 420; yco= 170; width= 300; + xco= 420; yco= -10; width= 300; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2373,11 +2373,11 @@ void logic_buttons(bContext *C, ARegion *ar) } } uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ - + height = yco; /* ****************** Sensors ****************** */ - xco= 10; yco= 170; width= 340; + xco= 10; yco= -10; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2442,10 +2442,11 @@ void logic_buttons(bContext *C, ARegion *ar) } } uiBlockLayoutResolve(block, NULL, &yco); /* stores final height in yco */ + height = MIN2(height, yco); /* ****************** Actuators ****************** */ - xco= 800; yco= 170; width= 340; + xco= 800; yco= -10; width= 340; layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); @@ -2513,13 +2514,21 @@ 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, 1150, height); - + /* set the view */ + UI_view2d_view_ortho(&ar->v2d); + uiComposeLinks(block); uiEndBlock(C, block); uiDrawBlock(C, block); + /* restore view matrix */ + UI_view2d_view_restore(C); + if (idar) MEM_freeN(idar); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index f965969504c..4cd53215697 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -84,8 +84,9 @@ ARegion *logic_has_buttons_region(ScrArea *sa) /* ******************** default callbacks for image space ***************** */ -static SpaceLink *logic_new(const bContext *UNUSED(C)) +static SpaceLink *logic_new(const bContext *C) { + ScrArea *sa= CTX_wm_area(C); ARegion *ar; SpaceLogic *slogic; @@ -120,14 +121,11 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) ar->regiontype= RGN_TYPE_WINDOW; ar->v2d.tot.xmin = 0.0f; - ar->v2d.tot.ymin = 0.0f; - ar->v2d.tot.xmax = 1280; - ar->v2d.tot.ymax = 240.0f; + ar->v2d.tot.ymax = 0.0f; + ar->v2d.tot.xmax = 1150.0f; + ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy; - ar->v2d.cur.xmin = 0.0f; - ar->v2d.cur.ymin = 0.0f; - ar->v2d.cur.xmax = 1280.0f; - ar->v2d.cur.ymax = 240.0f; + ar->v2d.cur = ar->v2d.tot; ar->v2d.min[0] = 1.0f; ar->v2d.min[1] = 1.0f; @@ -136,12 +134,13 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) ar->v2d.max[1] = 32000.0f; ar->v2d.minzoom = 0.5f; - ar->v2d.maxzoom = 1.21f; + ar->v2d.maxzoom = 1.5f; ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; - ar->v2d.keeptot = 0; - + ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X; + ar->v2d.keepofs = V2D_KEEPOFS_Y; return (SpaceLink *)slogic; } @@ -183,6 +182,9 @@ static void logic_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); 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); + } static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa)) @@ -234,7 +236,7 @@ static void logic_main_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -259,7 +261,7 @@ static void logic_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); |