@@ -4706,26 +4706,6 @@ namespace netxs::ui
47064706 : twod{ width, -1 };
47074707 base::limits (lims, lims);
47084708 }
4709- void giveup (hids& gear)
4710- {
4711- if (on_pager)
4712- {
4713- gear.dismiss ();
4714- }
4715- else
4716- {
4717- if (gear.captured (bell::id))
4718- {
4719- if (gear.cause == input::key::RightDragCancel)
4720- {
4721- send<e2 ::form::upon::scroll::cancel::_<Axis>>();
4722- }
4723- base::deface ();
4724- gear.setfree ();
4725- gear.dismiss ();
4726- }
4727- }
4728- }
47294709 void pager (si32 dir)
47304710 {
47314711 calc.setdir (dir);
@@ -4767,23 +4747,44 @@ namespace netxs::ui
47674747 });
47684748 base::on (tier::mouserelease, input::key::MouseMove, [&](hids& gear)
47694749 {
4770- calc.cursor_pos = twod{ gear.coord }[Axis];
4750+ if (gear.captured (bell::id))
4751+ {
4752+ if (on_pager)
4753+ {
4754+ calc.cursor_pos = twod{ gear.coord }[Axis];
4755+ }
4756+ else
4757+ {
4758+ if (auto delta = (gear.coord - drag_origin)[Axis])
4759+ {
4760+ calc.stepby (delta);
4761+ send<e2 ::form::upon::scroll::bycoor::_<Axis>>();
4762+ }
4763+ }
4764+ gear.dismiss ();
4765+ }
47714766 });
47724767 base::on (tier::mouserelease, input::key::LeftDoubleClick, [&](hids& gear)
47734768 {
47744769 gear.dismiss (); // Do not pass double clicks outside.
47754770 });
47764771 base::on (tier::mouserelease, input::key::MouseDown, [&](hids& gear)
47774772 {
4778- if (!on_pager)
4779- if (gear.cause == input::key::LeftDown || gear.cause == input::key::RightDown)
4780- if (auto dir = calc.inside (twod{ gear.coord }[Axis]))
4773+ if (!gear.captured (bell::id) && gear.capture (bell::id))
47814774 {
4782- if (gear.capture (bell::id))
4775+ auto dir = calc.inside (twod{ gear.coord }[Axis]);
4776+ if (dir == 0 ) // Inside the grip.
4777+ {
4778+ calc.captured = true ;
4779+ drag_origin = gear.coord ;
4780+ calc.m_to_s ();
4781+ calc.grip_origin = calc.scroll_air ;
4782+ }
4783+ else // Outside the grip.
47834784 {
47844785 on_pager = true ;
4786+ calc.cursor_pos = twod{ gear.coord }[Axis];
47854787 pager_repeat ();
4786- gear.dismiss ();
47874788 timer.actify (activity::pager_first, skin::globals ().repeat_delay , [&](auto )
47884789 {
47894790 if (pager_repeat ())
@@ -4797,93 +4798,35 @@ namespace netxs::ui
47974798 });
47984799 }
47994800 }
4801+ gear.dismiss ();
48004802 });
48014803 base::on (tier::mouserelease, input::key::MouseUp, [&](hids& gear)
48024804 {
4803- if (on_pager && gear.captured (bell::id))
4805+ if (gear.captured (bell::id) && gear. pressed_count == 0 )
48044806 {
4805- if (gear. cause == input::key::LeftUp || gear. cause == input::key::RightUp )
4807+ if (on_pager )
48064808 {
4807- gear.setfree ();
4808- gear.dismiss ();
48094809 on_pager = faux;
48104810 timer.pacify (activity::pager_first);
48114811 timer.pacify (activity::pager_next);
48124812 }
4813- }
4814- });
4815- base::on (tier::mouserelease, input::key::RightUp, [&](hids& gear)
4816- {
4817- // if (!gear.captured(bell::id)) //todo why?
4818- {
4819- send<e2 ::form::upon::scroll::cancel::_<Axis>>();
4820- gear.dismiss ();
4821- }
4822- });
4823- base::on (tier::mouserelease, input::key::MouseDragStart, [&](hids& gear)
4824- {
4825- if (on_pager)
4826- {
4827- gear.dismiss ();
4828- }
4829- else
4830- {
4831- if (gear.capture (bell::id))
4832- {
4833- calc.captured = true ;
4834- drag_origin = gear.coord ;
4835- calc.m_to_s ();
4836- calc.grip_origin = calc.scroll_air ;
4837- gear.dismiss ();
4838- }
4839- }
4840- });
4841- base::on (tier::mouserelease, input::key::MouseDragPull, [&](hids& gear)
4842- {
4843- if (on_pager)
4844- {
4813+ calc.captured = faux;
4814+ gear.setfree ();
48454815 gear.dismiss ();
4816+ base::deface ();
48464817 }
4847- else
4848- {
4849- if (gear.captured (bell::id))
4850- {
4851- if (auto delta = (gear.coord - drag_origin)[Axis])
4852- {
4853- calc.stepby (delta);
4854- send<e2 ::form::upon::scroll::bycoor::_<Axis>>();
4855- gear.dismiss ();
4856- }
4857- }
4858- }
4859- });
4860- base::on (tier::mouserelease, input::key::MouseDragCancel, [&](hids& gear)
4861- {
4862- calc.captured = faux;
4863- giveup (gear);
48644818 });
4865- bell::dup_handler (tier::general, input::events::halt.id );
4866- base::on (tier::mouserelease, input::key::MouseDragStop, [&](hids& gear)
4819+ LISTEN (tier::general, input::events::halt, gear)
48674820 {
4868- calc.captured = faux;
4869- if (on_pager)
4821+ if (gear.captured (bell::id))
48704822 {
4823+ calc.captured = faux;
4824+ on_pager = faux;
4825+ base::deface ();
4826+ gear.setfree ();
48714827 gear.dismiss ();
48724828 }
4873- else
4874- {
4875- if (gear.captured (bell::id))
4876- {
4877- if (gear.cause == input::key::RightDragStop)
4878- {
4879- send<e2 ::form::upon::scroll::cancel::_<Axis>>();
4880- }
4881- base::deface ();
4882- gear.setfree ();
4883- gear.dismiss ();
4884- }
4885- }
4886- });
4829+ };
48874830 LISTEN (tier::release, e2 ::form::state::mouse, hovered)
48884831 {
48894832 auto apply = [&](auto active)
0 commit comments