cc: Refactor RecordingSource
[chromium-blink-merge.git] / pdf / fading_controls.h
blob532464b473c51aa21c0265910274df3590ca2a15
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PDF_FADING_CONTROLS_H_
6 #define PDF_FADING_CONTROLS_H_
8 #include <list>
10 #include "pdf/control.h"
12 namespace chrome_pdf {
14 class FadingControls : public Control,
15 public ControlOwner {
16 public:
17 enum FadingState {
18 NONE,
19 FADING_IN,
20 FADING_OUT
23 FadingControls();
24 virtual ~FadingControls();
25 virtual bool CreateFadingControls(
26 uint32 id, const pp::Rect& rc, bool visible,
27 Control::Owner* delegate, uint8 transparency);
29 // Control interface.
30 virtual void Paint(pp::ImageData* image_data, const pp::Rect& rc);
31 virtual bool HandleEvent(const pp::InputEvent& event);
32 virtual void OnTimerFired(uint32 timer_id);
33 virtual void EventCaptureReleased();
34 virtual void MoveBy(const pp::Point& offset, bool invalidate);
36 // ControlOwner interface.
37 virtual void OnEvent(uint32 control_id, uint32 event_id, void* data);
38 virtual void Invalidate(uint32 control_id, const pp::Rect& rc);
39 virtual uint32 ScheduleTimer(uint32 control_id, uint32 timeout_ms);
40 virtual void SetEventCapture(uint32 control_id, bool set_capture);
41 virtual void SetCursor(uint32 control_id, PP_CursorType_Dev cursor_type);
42 virtual pp::Instance* GetInstance();
44 // FadingControls interface
45 // This function takes ownership of the control, and will destoy it
46 // when control is destroyed.
47 // Input control MUST be located inside FadingControls boundaries, and has
48 // this instance of FadingControls as a delegate.
49 virtual bool AddControl(Control* control);
50 virtual void RemoveControl(uint32 control_id);
51 virtual Control* GetControl(uint32 id);
52 virtual pp::Rect GetControlsRect();
54 // Expand/Shrink area which triggers inner control appearance to the left.
55 virtual bool ExpandLeft(int offset);
57 // Fade-in, then show controls for time_ms, and then fade-out. Any mouse
58 // event in this control area will interrupt splash mode.
59 virtual void Splash(uint32 time_ms);
61 uint8 current_transparency() const { return current_transparency_; }
63 private:
64 bool NotifyControls(const pp::InputEvent& event);
65 void FadeIn();
66 void FadeOut();
67 void OnFadingComplete();
68 void CancelSplashMode();
70 std::list<Control*> controls_;
71 FadingState state_;
72 uint8 current_transparency_;
73 uint32 fading_timer_id_;
74 uint32 current_capture_control_;
75 uint32 fading_timeout_;
76 uint32 alpha_shift_;
77 bool splash_;
78 uint32 splash_timeout_;
81 } // namespace chrome_pdf
83 #endif // PDF_FADING_CONTROLS_H_