Merge lp:~azzar1/unity/fix-767075 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 1240
Proposed branch: lp:~azzar1/unity/fix-767075
Merge into: lp:unity
Diff against target: 199 lines (+52/-71)
2 files modified
src/Launcher.cpp (+51/-70)
src/Launcher.h (+1/-1)
To merge this branch: bzr merge lp:~azzar1/unity/fix-767075
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Tim Penhey (community) Approve
Review via email: mp+63852@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Great work.

Even though you didn't change the geometry param, can I get you to fix it please?

  SetDndDelta (0, center.y, nux::Geometry (geo.x, geo.y, geo.width, geo.height), current);

should be simplified to

  SetDndDelta (0, center.y, geo, current);

We don't need to have yet another constructor.

For bonus points you can change the signature of the SetDndDelta from:

void Launcher::SetDndDelta (float x, float y, nux::Geometry geo, struct timespec const &current)

to

void Launcher::SetDndDelta(float x, float y, nux::Geometry const& geo, timespec const &current)

The const& nux::Geometry parameter means that we don't make an unnecessary copy, and the "struct timespec" can be simplified to just "timespec".

review: Needs Fixing
Revision history for this message
Tim Penhey (thumper) wrote :

On Thu, 09 Jun 2011 19:26:57 you wrote:
> You have been requested to review the proposed merge of
> lp:~andyrock/unity/fix-767075 into lp:unity.
>
> For more details, see:
> https://code.launchpad.net/~andyrock/unity/fix-767075/+merge/63852

  review approve
  reviewer njpatel

review: Approve
Revision history for this message
Jason Smith (jassmith) wrote :

Setting 0 is not entirely appropriate. This wont get top edge of a folded icon (which may be obscured anyway?) but is still incorrect. Instead of 0 it needs to track the horizontal offset of the launcher.

review: Needs Fixing
Revision history for this message
Jason Smith (jassmith) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Launcher.cpp'
--- src/Launcher.cpp 2011-06-09 17:07:15 +0000
+++ src/Launcher.cpp 2011-06-10 14:39:15 +0000
@@ -1109,7 +1109,7 @@
1109 }1109 }
1110}1110}
11111111
1112void Launcher::SetDndDelta (float x, float y, nux::Geometry geo, struct timespec const &current)1112void Launcher::SetDndDelta (float x, float y, nux::Geometry const &geo, timespec const &current)
1113{1113{
1114 LauncherIcon *anchor = 0;1114 LauncherIcon *anchor = 0;
1115 LauncherModel::iterator it;1115 LauncherModel::iterator it;
@@ -1508,10 +1508,55 @@
1508 if (sum - _space_between_icons <= launcher_height)1508 if (sum - _space_between_icons <= launcher_height)
1509 folding_threshold = launcher_height;1509 folding_threshold = launcher_height;
15101510
1511 float autohide_offset = 0.0f;
1512 *launcher_alpha = 1.0f;
1513 if (_hidemode != LAUNCHER_HIDE_NEVER)
1514 {
1515
1516 float autohide_progress = AutohideProgress (current) * (1.0f - DragOutProgress (current));
1517 if (_autohide_animation == FADE_ONLY
1518 || (_autohide_animation == FADE_OR_SLIDE && _hide_machine->GetQuirk (LauncherHideMachine::MOUSE_OVER_BFB)))
1519 *launcher_alpha = 1.0f - autohide_progress;
1520 else
1521 {
1522 if (autohide_progress > 0.0f)
1523 {
1524 autohide_offset -= geo.width * autohide_progress;
1525 if (_autohide_animation == FADE_AND_SLIDE)
1526 *launcher_alpha = 1.0f - 0.5f * autohide_progress;
1527 }
1528 }
1529 }
1530
1531 float drag_hide_progress = DragHideProgress (current);
1532 if (_hidemode != LAUNCHER_HIDE_NEVER && drag_hide_progress > 0.0f)
1533 {
1534 autohide_offset -= geo.width * 0.25f * drag_hide_progress;
1535
1536 if (drag_hide_progress >= 1.0f)
1537 _hide_machine->SetQuirk (LauncherHideMachine::DND_PUSHED_OFF, true);
1538 }
1539
1540 // Inform the painter where to paint the box
1541 box_geo = geo;
1542
1543 if (_hidemode != LAUNCHER_HIDE_NEVER)
1544 box_geo.x += autohide_offset;
1545
1546 /* Why we need last_geo? It stores the last box_geo (note: as it is a static variable,
1547 * it is initialized only first time). Infact we call SetDndDelta that calls MouseIconIntersection
1548 * that uses values (HitArea) that are computed in UpdateIconXForm.
1549 * The problem is that in DrawContent we calls first RenderArgs, then UpdateIconXForm. Just
1550 * use last_geo to hack this problem.
1551 */
1552 static nux::Geometry last_geo = box_geo;
1553
1511 // this happens on hover, basically its a flag and a value in one, we translate this into a dnd offset1554 // this happens on hover, basically its a flag and a value in one, we translate this into a dnd offset
1512 if (_enter_y != 0 && _enter_y + _icon_size / 2 > folding_threshold)1555 if (_enter_y != 0 && _enter_y + _icon_size / 2 > folding_threshold)
1513 SetDndDelta (center.x, center.y, nux::Geometry (geo.x, geo.y, geo.width, geo.height), current);1556 SetDndDelta (last_geo.x + last_geo.width / 2, center.y, geo, current);
15141557
1558 // Update the last_geo value.
1559 last_geo = box_geo;
1515 _enter_y = 0;1560 _enter_y = 0;
15161561
1517 if (hover_progress > 0.0f && _launcher_drag_delta != 0)1562 if (hover_progress > 0.0f && _launcher_drag_delta != 0)
@@ -1550,41 +1595,6 @@
1550 _launcher_drag_delta = 0;1595 _launcher_drag_delta = 0;
1551 }1596 }
15521597
1553 float autohide_offset = 0.0f;
1554 *launcher_alpha = 1.0f;
1555 if (_hidemode != LAUNCHER_HIDE_NEVER)
1556 {
1557
1558 float autohide_progress = AutohideProgress (current) * (1.0f - DragOutProgress (current));
1559 if (_autohide_animation == FADE_ONLY
1560 || (_autohide_animation == FADE_OR_SLIDE && _hide_machine->GetQuirk (LauncherHideMachine::MOUSE_OVER_BFB)))
1561 *launcher_alpha = 1.0f - autohide_progress;
1562 else
1563 {
1564 if (autohide_progress > 0.0f)
1565 {
1566 autohide_offset -= geo.width * autohide_progress;
1567 if (_autohide_animation == FADE_AND_SLIDE)
1568 *launcher_alpha = 1.0f - 0.5f * autohide_progress;
1569 }
1570 }
1571 }
1572
1573 float drag_hide_progress = DragHideProgress (current);
1574 if (_hidemode != LAUNCHER_HIDE_NEVER && drag_hide_progress > 0.0f)
1575 {
1576 autohide_offset -= geo.width * 0.25f * drag_hide_progress;
1577
1578 if (drag_hide_progress >= 1.0f)
1579 _hide_machine->SetQuirk (LauncherHideMachine::DND_PUSHED_OFF, true);
1580 }
1581
1582 // Inform the painter where to paint the box
1583 box_geo = geo;
1584
1585 if (_hidemode != LAUNCHER_HIDE_NEVER)
1586 box_geo.x += autohide_offset;
1587
1588 // The functional position we wish to represent for these icons is not smooth. Rather than introducing1598 // The functional position we wish to represent for these icons is not smooth. Rather than introducing
1589 // special casing to represent this, we use MIN/MAX functions. This helps ensure that even though our1599 // special casing to represent this, we use MIN/MAX functions. This helps ensure that even though our
1590 // function is not smooth it is continuous, which is more important for our visual representation (icons1600 // function is not smooth it is continuous, which is more important for our visual representation (icons
@@ -2786,7 +2796,6 @@
2786 nux::Geometry bkg_box;2796 nux::Geometry bkg_box;
2787 std::list<Launcher::RenderArg> args;2797 std::list<Launcher::RenderArg> args;
2788 std::list<Launcher::RenderArg>::reverse_iterator rev_it;2798 std::list<Launcher::RenderArg>::reverse_iterator rev_it;
2789 std::list<Launcher::RenderArg>::iterator it;
2790 float launcher_alpha = 1.0f;2799 float launcher_alpha = 1.0f;
27912800
2792 // rely on the compiz event loop to come back to us in a nice throttling2801 // rely on the compiz event loop to come back to us in a nice throttling
@@ -2829,23 +2838,11 @@
2829 nux::Geometry (bkg_box.x, (*rev_it).render_center.y - 3, bkg_box.width, 2), 2838 nux::Geometry (bkg_box.x, (*rev_it).render_center.y - 3, bkg_box.width, 2),
2830 nux::Color(0xAAAAAAAA));2839 nux::Color(0xAAAAAAAA));
2831 2840
2832 if ((*rev_it).x_rotation >= 0.0f || (*rev_it).skip)2841 if ((*rev_it).skip)
2833 continue;2842 continue;
28342843
2835 DrawRenderArg (GfxContext, *rev_it, bkg_box);2844 DrawRenderArg (GfxContext, *rev_it, bkg_box);
2836 }2845 }
2837
2838 for (it = args.begin(); it != args.end(); it++)
2839 {
2840 if ((*it).stick_thingy)
2841 gPainter.Paint2DQuadColor (GfxContext,
2842 nux::Geometry (bkg_box.x, (*it).render_center.y - 3, bkg_box.width, 2),
2843 nux::Color(0xAAAAAAAA));
2844 if ((*it).x_rotation < 0.0f || (*it).skip)
2845 continue;
2846
2847 DrawRenderArg (GfxContext, *it, bkg_box);
2848 }
28492846
2850 gPainter.Paint2DQuadColor(GfxContext,2847 gPainter.Paint2DQuadColor(GfxContext,
2851 nux::Geometry(bkg_box.x + bkg_box.width - 1,2848 nux::Geometry(bkg_box.x + bkg_box.width - 1,
@@ -3256,6 +3253,8 @@
3256void 3253void
3257Launcher::EdgeRevealTriggered ()3254Launcher::EdgeRevealTriggered ()
3258{3255{
3256 SetMousePosition (pointerX, pointerY - GetAbsoluteGeometry ().y);
3257
3259 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_ACTIVE_EDGE, true);3258 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_OVER_ACTIVE_EDGE, true);
3260 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);3259 _hide_machine->SetQuirk (LauncherHideMachine::MOUSE_MOVE_POST_REVEAL, true);
3261}3260}
@@ -3475,31 +3474,13 @@
3475LauncherIcon* Launcher::MouseIconIntersection (int x, int y)3474LauncherIcon* Launcher::MouseIconIntersection (int x, int y)
3476{3475{
3477 LauncherModel::iterator it;3476 LauncherModel::iterator it;
3478 LauncherModel::reverse_iterator rev_it;
3479 // We are looking for the icon at screen coordinates x, y;3477 // We are looking for the icon at screen coordinates x, y;
3480 nux::Point2 mouse_position(x, y);3478 nux::Point2 mouse_position(x, y);
3481 int inside = 0;3479 int inside = 0;
34823480
3483 // Because of the way icons fold and stack on one another, we must proceed in 2 steps.
3484 for (rev_it = _model->rbegin (); rev_it != _model->rend (); rev_it++)
3485 {
3486 if ((*rev_it)->_folding_angle < 0.0f || !(*rev_it)->GetQuirk (LauncherIcon::QUIRK_VISIBLE))
3487 continue;
3488
3489 nux::Point2 screen_coord [4];
3490 for (int i = 0; i < 4; i++)
3491 {
3492 screen_coord [i].x = (*rev_it)->_xform_coords["HitArea"] [i].x;
3493 screen_coord [i].y = (*rev_it)->_xform_coords["HitArea"] [i].y;
3494 }
3495 inside = PointInside2DPolygon (screen_coord, 4, mouse_position, 1);
3496 if (inside)
3497 return (*rev_it);
3498 }
3499
3500 for (it = _model->begin(); it != _model->end (); it++)3481 for (it = _model->begin(); it != _model->end (); it++)
3501 {3482 {
3502 if ((*it)->_folding_angle >= 0.0f || !(*it)->GetQuirk (LauncherIcon::QUIRK_VISIBLE))3483 if (!(*it)->GetQuirk (LauncherIcon::QUIRK_VISIBLE))
3503 continue;3484 continue;
35043485
3505 nux::Point2 screen_coord [4];3486 nux::Point2 screen_coord [4];
35063487
=== modified file 'src/Launcher.h'
--- src/Launcher.h 2011-04-20 03:59:36 +0000
+++ src/Launcher.h 2011-06-10 14:39:15 +0000
@@ -308,7 +308,7 @@
308 void SetHover (bool hovered);308 void SetHover (bool hovered);
309 void SetHidden (bool hidden);309 void SetHidden (bool hidden);
310310
311 void SetDndDelta (float x, float y, nux::Geometry geo, struct timespec const &current);311 void SetDndDelta (float x, float y, nux::Geometry const &geo, timespec const &current);
312 float DragLimiter (float x);312 float DragLimiter (float x);
313313
314 void SetupRenderArg (LauncherIcon *icon, struct timespec const &current, RenderArg &arg);314 void SetupRenderArg (LauncherIcon *icon, struct timespec const &current, RenderArg &arg);