diff options
author | Siri Hansen <[email protected]> | 2018-11-29 10:13:23 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2018-11-29 10:19:45 +0100 |
commit | 1320354d2800e6f777fc5156c52b41d7f8321442 (patch) | |
tree | 836ee94437910f68d94f8388ef1e05acb4c92feb /lib | |
parent | e46d5adbc263b6bec01633217cf4bf39f04a53f2 (diff) | |
download | otp-1320354d2800e6f777fc5156c52b41d7f8321442.tar.gz otp-1320354d2800e6f777fc5156c52b41d7f8321442.tar.bz2 otp-1320354d2800e6f777fc5156c52b41d7f8321442.zip |
[et] Improve handling of scroll bar
Diffstat (limited to 'lib')
-rw-r--r-- | lib/et/src/et_wx_viewer.erl | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/et/src/et_wx_viewer.erl b/lib/et/src/et_wx_viewer.erl index 4dd44e7a4c..041527fec4 100644 --- a/lib/et/src/et_wx_viewer.erl +++ b/lib/et/src/et_wx_viewer.erl @@ -793,8 +793,8 @@ handle_info(#wx{event = #wxScroll{type = scroll_changed}} = Wx, S) -> N = round(S#state.n_events * Pos / Range), Diff = case N - event_pos(S) of - D when D < 0 -> D - 1; - D -> D + 1 + D when D < 0 -> D; + D -> D end, S2 = scroll_changed(S, Diff), noreply(S2); @@ -1002,7 +1002,7 @@ scroll_changed(S, Expected) -> scroll_first(S); last -> scroll_last(S) - end; + end; true -> %% Down OldPos = event_pos(S), @@ -1018,19 +1018,24 @@ scroll_changed(S, Expected) -> end. jump_up(S, OldKey, OldPos, NewPos) -> - Try = NewPos - OldPos, + Try = NewPos - OldPos -1, Order = S#state.event_order, - Fun = fun(Event, #e{pos = P}) when P >= NewPos -> - Key = et_collector:make_key(Order, Event), - #e{event = Event, key = Key, pos = P - 1}; - (_, Acc) -> - Acc - end, - PrevE = et_collector:iterate(S#state.collector_pid, - OldKey, - Try, - Fun, - #e{key = OldKey, pos = OldPos}), + PrevE = + if NewPos =:= 0 -> + first; + true -> + Fun = fun(Event, #e{pos = P}) when P >= NewPos -> + Key = et_collector:make_key(Order, Event), + #e{event = Event, key = Key, pos = P - 1}; + (_E, Acc) -> + Acc + end, + et_collector:iterate(S#state.collector_pid, + OldKey, + Try, + Fun, + #e{key = OldKey, pos = OldPos}) + end, case collect_more_events(S, PrevE, S#state.events_per_page) of {_, []} -> S; @@ -2013,7 +2018,7 @@ update_scroll_bar(#state{scroll_bar = ScrollBar, PixelsPerEvent = Range / EventsPerPage, Share = EventsPerPage / N, wxScrollBar:setScrollbar(ScrollBar, - trunc(EventPos * Share * PixelsPerEvent), + trunc(EventPos * Share * PixelsPerEvent), round(Share * Range), Range, round(Share * Range), |