Logic window usability:
- Added a bit of more margin in bottom (for view pans) - Made HOME option (view all) to show full width of editor, instead of zoom level 1:1.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user