PageRenderTime 65ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llviewinject.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 49 lines | 18 code | 3 blank | 28 comment | 4 complexity | 4c7a721c6feba80ae00d76910a398b9a MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewinject.cpp
  3. * @author Nat Goodspeed
  4. * @date 2011-08-16
  5. * @brief Implementation for llviewinject.
  6. *
  7. * $LicenseInfo:firstyear=2011&license=viewerlgpl$
  8. * Copyright (c) 2011, Linden Research, Inc.
  9. * $/LicenseInfo$
  10. */
  11. // Precompiled header
  12. #include "linden_common.h"
  13. // associated header
  14. #include "llviewinject.h"
  15. // STL headers
  16. // std headers
  17. // external library headers
  18. // other Linden headers
  19. llview::TargetEvent::TargetEvent(LLView* view)
  20. {
  21. // Walk up the view tree from target LLView to the root (NULL). If
  22. // passed NULL, iterate 0 times.
  23. for (; view; view = view->getParent())
  24. {
  25. // At each level, operator() is going to ask: for a particular parent
  26. // LLView*, which of its children should I select? So for this view's
  27. // parent, select this view.
  28. mChildMap[view->getParent()] = view;
  29. }
  30. }
  31. bool llview::TargetEvent::operator()(const LLView* view, S32 /*x*/, S32 /*y*/) const
  32. {
  33. // We are being called to decide whether to direct an incoming mouse event
  34. // to this child view. (Normal LLView processing is to check whether the
  35. // incoming (x, y) is within the view.) Look up the parent to decide
  36. // whether, for that parent, this is the previously-selected child.
  37. ChildMap::const_iterator found(mChildMap.find(view->getParent()));
  38. // If we're looking at a child whose parent isn't even in the map, never
  39. // mind.
  40. if (found == mChildMap.end())
  41. {
  42. return false;
  43. }
  44. // So, is this the predestined child for this parent?
  45. return (view == found->second);
  46. }