Roll src/third_party/WebKit 2dc4bc6:34469ea (svn 182261:182277)
[chromium-blink-merge.git] / pdf / progress_control.h
blob96d5da1ce9b8238c8e81776e860c41f9cf19a488
1 // Copyright (c) 2012 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_PROGRESS_CONTROL_H_
6 #define PDF_PROGRESS_CONTROL_H_
8 #include <string>
9 #include <vector>
11 #include "pdf/control.h"
12 #include "pdf/fading_control.h"
13 #include "ppapi/cpp/image_data.h"
15 namespace chrome_pdf {
17 class ProgressControl : public FadingControl {
18 public:
19 static const double kCompleted;
21 enum ProgressEventIds {
22 EVENT_ID_PROGRESS_COMPLETED,
25 ProgressControl();
26 virtual ~ProgressControl();
27 virtual bool CreateProgressControl(uint32 id,
28 bool visible,
29 Control::Owner* delegate,
30 double progress,
31 float device_scale,
32 const std::vector<pp::ImageData>& images,
33 const pp::ImageData& background,
34 const std::string& text);
35 void Reconfigure(const pp::ImageData& background,
36 const std::vector<pp::ImageData>& images,
37 float device_scale);
39 static void CalculateLayout(pp::Instance* instance,
40 const std::vector<pp::ImageData>& images,
41 const pp::ImageData& background,
42 const std::string& text,
43 float device_scale,
44 pp::Size* ctrl_size,
45 pp::Rect* image_rc,
46 pp::Rect* text_rc);
48 // Control interface.
49 virtual void Paint(pp::ImageData* image_data, const pp::Rect& rc);
51 // ProgressControl interface
52 // Set progress indicator in percents from 0% to 100%.
53 virtual void SetProgress(double progress);
55 private:
56 void PrepareBackground();
57 void AdjustBackground();
58 size_t GetImageIngex() const;
60 double progress_;
61 float device_scale_;
62 std::vector<pp::ImageData> images_;
63 pp::ImageData background_;
64 pp::ImageData ctrl_background_;
65 std::string text_;
66 pp::Rect image_rc_;
67 pp::Rect text_rc_;
70 } // namespace chrome_pdf
72 #endif // PDF_PROGRESS_CONTROL_H_