Skip to content

Commit

Permalink
NOTE:Removed prefs to simplify interface. [optgon]
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Jones committed Dec 14, 2010
1 parent 2b9023b commit 759d952
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 425 deletions.
12 changes: 4 additions & 8 deletions plugins_src/autouv/auv_seg_ui.erl
Expand Up @@ -438,12 +438,8 @@ fake_selection(St) ->
end, St).

fake_sel_1(St0) ->
case wings_pref:get_value(use_temp_sel) of
false -> St0;
true ->
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end.
18 changes: 7 additions & 11 deletions plugins_src/autouv/wpc_autouv.erl
Expand Up @@ -618,15 +618,15 @@ handle_event_0(Ev=#mousebutton{state=?SDL_PRESSED,
mod=Mod},
#st{sel=Sel}=St0, FreeLmbMod)
when (Mod band 16#0FFF) == 0 -> %% No modifiers
case (Sel == []) and wings_pref:get_value(use_temp_sel) of
true ->
case Sel of
[] ->
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} ->
start_tweak(temp_selection, Ev, St);
_ ->
handle_event_1(Ev, St0, FreeLmbMod)
end;
false ->
_ ->
case wings_pick:do_pick(X,Y,St0) of
{delete,_,_} ->
start_tweak(selection, Ev, St0);
Expand Down Expand Up @@ -1059,14 +1059,10 @@ fake_selection(St) ->
end, St).

fake_sel_1(St0) ->
case wings_pref:get_value(use_temp_sel) of
false -> St0;
true ->
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end.

add_faces(NewFs,St0=#st{bb=ASt=#uvstate{id=Id,mode=Mode,st=GeomSt=#st{shapes=Shs0}}}) ->
Expand Down
22 changes: 6 additions & 16 deletions plugins_src/commands/wpc_connect_tool.erl
Expand Up @@ -197,14 +197,8 @@ handle_connect_event1({action,Action}, #cs{st=St0}=C) ->
update_connect_handler(C);
{view,highlight_aim} ->
St = fake_selection(St0),
case wings_pref:get_value(highlight_aim_at_unselected) of
false ->
wings_view:command(aim, St0),
update_connect_handler(C);
true ->
wings_view:command(aim, St),
update_connect_handler(C)
end;
wings_view:command(aim, St),
update_connect_handler(C);
{view,Cmd} ->
case wings_view:command(Cmd, St0) of
keep ->
Expand Down Expand Up @@ -572,14 +566,10 @@ fake_selection(St) ->
end, St).

fake_sel_1(St0) ->
case wings_pref:get_value(use_temp_sel) of
false -> St0;
true ->
{_,X,Y} = wings_wm:local_mouse_state(),
case wpa:pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end
{_,X,Y} = wings_wm:local_mouse_state(),
case wpa:pick(X, Y, St0) of
{add,_,St} -> St;
_ -> St0
end.

update_hook(#cs{v=[]}) ->
Expand Down
106 changes: 44 additions & 62 deletions src/wings.erl
Expand Up @@ -342,18 +342,18 @@ handle_event_2(#mousebutton{x=X,y=Y}=Ev0, #st{sel=Sel}=St0) ->
true ->
wings_tweak:menu(Xglobal,Yglobal);
false ->
case Sel =:= [] andalso wings_pref:get_value(use_temp_sel) of
false ->
popup_menu(Xglobal, Yglobal, St0);
true ->
case Sel of
[] ->
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} ->
Ev = wings_wm:local2global(Ev0),
wings_io:putback_event(Ev),
wings_wm:later({temporary_selection,St});
_ ->
popup_menu(Xglobal, Yglobal, St0)
end
end;
_ ->
popup_menu(Xglobal, Yglobal, St0)
end
end
end;
Expand Down Expand Up @@ -472,46 +472,35 @@ info_line() ->
end.

do_hotkey(Ev, #st{sel=[]}=St0) ->
case wings_pref:get_value(use_temp_sel) of
false ->
do_hotkey_1(Ev, St0);
true ->
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} ->
case wings_hotkey:event(Ev, St) of
next -> next;
{view,highlight_aim} -> highlight_aim_setup(St0);
Cmd ->
case highlight_sel_style(Cmd) of
none -> {Cmd,St0};
temporary -> {Cmd,set_temp_sel(St0, St)};
permanent -> {Cmd,St}
end
end;
_Other -> do_hotkey_1(Ev, St0)
end
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,_,St} ->
case wings_hotkey:event(Ev, St) of
next -> next;
{view,highlight_aim} -> highlight_aim_setup(St0);
Cmd ->
case highlight_sel_style(Cmd) of
none -> {Cmd,St0};
temporary -> {Cmd,set_temp_sel(St0, St)};
permanent -> {Cmd,St}
end
end;
_Other -> do_hotkey_1(Ev, St0)
end;

%%%% Hack to get a basic form of Highlight Aim (see wings_view:highlight_aim/2)
do_hotkey(Ev, St0) ->
case wings_pref:get_value(use_temp_sel) of
false ->
do_hotkey_1(Ev, St0);
true ->
Hs = wings_pref:get_value(hilite_select),
case wings_hotkey:event(Ev, St0) of
next -> next;
{view,highlight_aim} -> highlight_aim_setup(St0);
{select,{edge_loop,edge_loop}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{edge_loop,edge_ring}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{oriented_faces,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{similar_material,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{similar_area,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,similar}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,all}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
Cmd -> {Cmd,St0}
end
Hs = wings_pref:get_value(hilite_select),
case wings_hotkey:event(Ev, St0) of
next -> next;
{view,highlight_aim} -> highlight_aim_setup(St0);
{select,{edge_loop,edge_loop}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{edge_loop,edge_ring}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{oriented_faces,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{similar_material,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,{similar_area,_}}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,similar}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
{select,all}=Cmd when Hs -> hotkey_select_setup(Cmd,St0);
Cmd -> {Cmd,St0}
end.

do_hotkey_1(Ev, St) ->
Expand Down Expand Up @@ -1473,22 +1462,17 @@ geom_title({geom,N}) ->
?__(2,"Geometry #") ++ integer_to_list(N).

do_use_command(#mousebutton{x=X,y=Y}, Cmd0, #st{sel=[]}=St0) ->
case wings_pref:get_value(use_temp_sel) of
false ->
keep;
true ->
case wings_pick:do_pick(X, Y, St0) of
{add,_,#st{selmode=Mode}=St} ->
%% The selection mode may have changed.
%% Must check (and possibly convert) the command again.
case repeatable(Mode, Cmd0) of
no -> keep;
Cmd ->
wings_wm:later({action,Cmd}),
main_loop_noredraw(set_temp_sel(St0, St))
end;
_Other -> keep
end
case wings_pick:do_pick(X, Y, St0) of
{add,_,#st{selmode=Mode}=St} ->
%% The selection mode may have changed.
%% Must check (and possibly convert) the command again.
case repeatable(Mode, Cmd0) of
no -> keep;
Cmd ->
wings_wm:later({action,Cmd}),
main_loop_noredraw(set_temp_sel(St0, St))
end;
_Other -> keep
end;
do_use_command(_, Cmd, _) -> wings_wm:later({action,Cmd}).

Expand Down Expand Up @@ -1832,13 +1816,11 @@ area_volume(Face, We) ->
{Area, Volume}.

highlight_aim_setup(St0) ->
HL0 = wings_pref:get_value(highlight_aim_at_unselected),
HL1 = wings_pref:get_value(highlight_aim_at_selected),
{_,X,Y} = wings_wm:local_mouse_state(),
case wings_pick:do_pick(X, Y, St0) of
{add,MM,#st{selmode=Selmode,sel=Sel}} when HL0 =:= true ->
{add,MM,#st{selmode=Selmode,sel=Sel}} ->
{{view,{highlight_aim,{add,{Selmode,Sel,MM}}}},St0};
{delete,MM,#st{selmode=Selmode,sel=Sel}} when HL1 =:= true ->
{delete,MM,#st{selmode=Selmode,sel=Sel}} ->
{{view,{highlight_aim,{delete,{Selmode,Sel,MM}}}},St0};
_Other ->
{{view,aim},St0}
Expand Down
60 changes: 12 additions & 48 deletions src/wings_camera.erl
Expand Up @@ -39,9 +39,7 @@ init() ->
wings_pref:set_default(num_buttons, 3),
wings_pref:set_default(cam_rotation_speed, 25),
wings_pref:set_default(pan_speed, 25),
wings_pref:set_default(pan_using_arrow_keys, true),
wings_pref:set_default(pan_speed_arrow_keys, 50),
wings_pref:set_default(inverted_wheel_zoom, false),
wings_pref:set_default(wheel_adds, false),
wings_pref:set_default(wh_scroll_info,true),
wings_pref:set_default(wh_pan_spd, 50),
Expand All @@ -61,10 +59,8 @@ prefs() ->
CamRotSpeed = wings_pref:get_value(cam_rotation_speed, 25),
PanSpeed0 = wings_pref:get_value(pan_speed, 25),
ArrowPanSpeed = wings_pref:get_value(pan_speed_arrow_keys, 50),
InvertZW = wings_pref:get_value(inverted_wheel_zoom, false),
WheelAdds = wings_pref:get_value(wheel_adds,false),
WhScrollInfo = wings_pref:get_value(wh_scroll_info,true),
ArrowKeysPan = wings_pref:get_value(pan_using_arrow_keys,true),
WhPanSpd = wings_pref:get_value(wh_pan_spd, 50),
WhRotate = wings_pref:get_value(wh_rot_spd, 7.5),
ZoomAim = wings_pref:get_value(highlight_zoom_aim),
Expand All @@ -77,10 +73,6 @@ prefs() ->
not ((gb_trees:get(wheel_adds, Sto)) andalso (gb_trees:get(wheel_zooms, Sto)));
(_, _) -> void
end,
ArrowKeyHook = fun (is_disabled, {_Var,_I,Sto}) ->
not gb_trees:get(pan_using_arrow_keys, Sto);
(_, _) -> void
end,
{hframe,
[{vframe,
[{vframe,[mouse_buttons()],[{title,?__(1,"Mouse Buttons")}]},
Expand All @@ -92,18 +84,12 @@ prefs() ->
[{hframe,[{slider,{text,PanSpeed0,[{key,pan_speed},{range,{1,100}}]}}]}],
[{title,?__(3,"Pan Speed")}]},
{vframe,
[{?__(18,"Arrow Keys Pan"),ArrowKeysPan,[{key,pan_using_arrow_keys}]},
{hframe,[{slider,{text,ArrowPanSpeed,[{key,pan_speed_arrow_keys},{range,{1,100}},
{hook,ArrowKeyHook}]}}]}],
[{hframe,[{slider,{text,ArrowPanSpeed,[{key,pan_speed_arrow_keys},{range,{1,100}}]}}]}],
[{title,?__(16,"Arrow Key Pan Speed")}]}]},
{vframe,
[{vframe,
[{hframe,[{?__(4,"Wheel Zooms"),ZoomFlag0,[{key,wheel_zooms}]},
{?__(20,"Zooming in aims Camera"),ZoomAim,[{key,highlight_zoom_aim}]}]},
{vradio,[{?__(5,"Forwards Zooms In"),false},
{?__(6,"Forwards Zooms Out"),true}],
InvertZW,
[{key,inverted_wheel_zoom},{hook,Hook}]},
{hframe,
[{label,?__(7,"Zoom Factor"),[{hook,Hook}]},
{text,ZoomFactor0,
Expand Down Expand Up @@ -755,28 +741,20 @@ generic_event(#mousebutton{button=5,mod=Mod,state=?SDL_RELEASED}, _Camera, _Redr

generic_event(#mousebutton{button=4,mod=Mod,state=?SDL_RELEASED}, _Camera, _Redraw)
when Mod band ?ALT_BITS =/= 0 ->
zoom_step_alt(-1);
zoom_step_alt(-1);
generic_event(#mousebutton{button=4,state=?SDL_RELEASED}, #st{}=St, none) ->
%% Matching 'none' stops zoom aim from being activated during a drag sequence.
%% Zoom aim warps the mouse to the screen's centre, and this can cause a crash
%% in since drag events also depend on cursor position.
case wings_pref:get_value(inverted_wheel_zoom) of
true -> zoom_step(-1);
false ->
aim_zoom(-1, St)
end;
aim_zoom(-1, St);
generic_event(#mousebutton{button=4,state=?SDL_RELEASED}, _Camera, _Redraw) ->
zoom_step(-1);
generic_event(#mousebutton{button=5,mod=Mod,state=?SDL_RELEASED}, _Camera, _Redraw)
when Mod band ?ALT_BITS =/= 0 ->
zoom_step_alt(1);
generic_event(#mousebutton{button=5,state=?SDL_RELEASED}, #st{}=St, none) ->
zoom_step_alt(1);
generic_event(#mousebutton{button=5,state=?SDL_RELEASED}, _, none) ->
%% Matching 'none' stops zoom aim from being activated during a drag sequence
case wings_pref:get_value(inverted_wheel_zoom) of
false -> zoom_step(1);
true ->
aim_zoom(1, St)
end;
zoom_step(1);
generic_event(#mousebutton{button=5,state=?SDL_RELEASED}, _Camera, _Redraw) ->
zoom_step(1);

Expand Down Expand Up @@ -855,14 +833,10 @@ zoom_step(Dir) ->
wheel_zoom(ZoomFactor,Dir)
end.

wheel_zoom(Factor,Dir) ->
wheel_zoom(Factor, Dir) ->
wings_wm:dirty(),
#view{distance=Dist} = View = wings_view:current(),
ZoomPercent0 = Factor/100,
ZoomPercent = case wings_pref:get_value(inverted_wheel_zoom) of
false -> ZoomPercent0;
true -> -ZoomPercent0
end,
ZoomPercent = Factor/100,
Delta = dist_factor(Dist)*Dir*ZoomPercent,
wings_view:set_current(View#view{distance=Dist+Delta}),
keep.
Expand All @@ -881,22 +855,12 @@ pan(Dx0, Dy0) ->
PanY = PanY0 - Dy,
wings_view:set_current(View#view{pan_x=PanX,pan_y=PanY}).

arrow_key_pan(Key) when Key=:=?SDLK_LEFT; Key=:=?SDLK_RIGHT; Key=:=?SDLK_UP; Key=:=?SDLK_DOWN ->
case wings_pref:get_value(pan_using_arrow_keys) of
true -> arrow_key_pan_1(Key);
_other -> next
end;
arrow_key_pan(?SDLK_LEFT) -> arrow_key_pan(0.05, 0.0);
arrow_key_pan(?SDLK_RIGHT) -> arrow_key_pan(-0.05, 0.0);
arrow_key_pan(?SDLK_UP) -> arrow_key_pan(0.0, 0.05);
arrow_key_pan(?SDLK_DOWN) -> arrow_key_pan(0.0, -0.05);
arrow_key_pan(_) -> next.

arrow_key_pan_1(?SDLK_LEFT) ->
arrow_key_pan(0.05, 0.0);
arrow_key_pan_1(?SDLK_RIGHT) ->
arrow_key_pan(-0.05, 0.0);
arrow_key_pan_1(?SDLK_UP) ->
arrow_key_pan(0.0, 0.05);
arrow_key_pan_1(?SDLK_DOWN) ->
arrow_key_pan(0.0, -0.05).

arrow_key_pan(Dx, Dy) ->
key_pan(Dx, Dy),
wings_wm:dirty(),
Expand Down
18 changes: 4 additions & 14 deletions src/wings_drag.erl
Expand Up @@ -137,23 +137,13 @@ custom_drag(Units) ->

custom_absolute_drag() ->
Speed = wings_pref:get_value(drag_speed_abs),
case wings_pref:get_value(drag_cam_dist_abs) of
true ->
#view{fov=Fov, distance=D} = wings_view:current(),
(D/((11-Speed)*((11-Speed)*300)))*Fov/60;
false ->
1/((11-Speed)*80)
end.
#view{fov=Fov, distance=D} = wings_view:current(),
(D/((11-Speed)*((11-Speed)*300)))*Fov/60.

custom_relative_drag() ->
Speed = wings_pref:get_value(drag_speed_relative),
case wings_pref:get_value(drag_cam_dist_relative) of
true ->
#view{distance=D} = wings_view:current(),
(D/((11-Speed)*((11-Speed)*900)));
false ->
1/((11-Speed)*100)
end.
#view{distance=D} = wings_view:current(),
(D/((11-Speed)*((11-Speed)*900))).

custom_rotations_drag() ->
Speed = wings_pref:get_value(drag_speed_rotate),
Expand Down

0 comments on commit 759d952

Please sign in to comment.