event_processor.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// found in the LICENSE file. 4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#ifndef UI_EVENTS_EVENT_PROCESSOR_H_ 6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define UI_EVENTS_EVENT_PROCESSOR_H_ 7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/events/event_dispatcher.h" 9a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/events/event_source.h" 10a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace ui { 12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// EventProcessor receives an event from an EventSource and dispatches it to a 14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// tree of EventTargets. 15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate { 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) public: 17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual ~EventProcessor() {} 18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 19a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Returns the root of the tree this event processor owns. 20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual EventTarget* GetRootTarget() = 0; 21a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Dispatches an event received from the EventSource to the tree of 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // EventTargets (whose root is returned by GetRootTarget()). The co-ordinate 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // space of the source must be the same as the root target, except that the 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // target may have a high-dpi scale applied. 26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual EventDispatchDetails OnEventFromSource(Event* event) 27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) WARN_UNUSED_RESULT; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Prepares the event so that it can be dispatched. This is invoked before 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // an EventTargeter is used to find the target of the event. So this can be 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // used to update the event so that the targeter can operate correctly (e.g. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // it can be used to updated the location of the event when disptaching from 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // an EventSource in high-DPI). 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void PrepareEventForDispatch(Event* event); 36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} // namespace ui 39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 40a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif // UI_EVENTS_EVENT_PROCESSOR_H_ 41