Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6419)

Unified Diff: chrome/browser/ui/views/ash/screenshot_taker.cc

Issue 9545014: Make the visual feedback for taking screenshot, with fix. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix code around opacity Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/ash/screenshot_taker.cc
diff --git a/chrome/browser/ui/views/ash/screenshot_taker.cc b/chrome/browser/ui/views/ash/screenshot_taker.cc
index 3bbb3b995f5269adad7169aad43867b6eaad855d..08137bf114e0dcb206277277771c586efed1781c 100644
--- a/chrome/browser/ui/views/ash/screenshot_taker.cc
+++ b/chrome/browser/ui/views/ash/screenshot_taker.cc
@@ -6,6 +6,8 @@
#include <string>
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -64,11 +66,21 @@ void SaveScreenshot(bool is_logged_in,
}
}
+// How opaque should the layer that we flash onscreen to provide visual
+// feedback after the screenshot is taken be?
+const float kVisualFeedbackLayerOpacity = 0.25f;
+
+// How long should the visual feedback layer be displayed?
+const int64 kVisualFeedbackLayerDisplayTimeMs = 100;
+
} // namespace
ScreenshotTaker::ScreenshotTaker() {
}
+ScreenshotTaker::~ScreenshotTaker() {
+}
+
void ScreenshotTaker::HandleTakePartialScreenshot(
aura::Window* window, const gfx::Rect& rect) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -81,6 +93,7 @@ void ScreenshotTaker::HandleTakePartialScreenshot(
#endif
if (browser::GrabWindowSnapshot(window, &png_data->data(), rect)) {
+ DisplayVisualFeedback(rect);
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,
base::Bind(&SaveScreenshot, is_logged_in, png_data));
@@ -92,3 +105,25 @@ void ScreenshotTaker::HandleTakePartialScreenshot(
void ScreenshotTaker::HandleTakeScreenshot(aura::Window* window) {
HandleTakePartialScreenshot(window, window->bounds());
}
+
+void ScreenshotTaker::CloseVisualFeedbackLayer() {
+ visual_feedback_layer_.reset();
+}
+
+void ScreenshotTaker::DisplayVisualFeedback(const gfx::Rect& rect) {
+ visual_feedback_layer_.reset(new ui::Layer(ui::Layer::LAYER_SOLID_COLOR));
+ visual_feedback_layer_->SetColor(SK_ColorWHITE);
+ visual_feedback_layer_->SetOpacity(kVisualFeedbackLayerOpacity);
+ visual_feedback_layer_->SetBounds(rect);
+
+ ui::Layer* parent = ash::Shell::GetInstance()->GetContainer(
+ ash::internal::kShellWindowId_OverlayContainer)->layer();
+ parent->Add(visual_feedback_layer_.get());
+ visual_feedback_layer_->SetVisible(true);
+
+ MessageLoopForUI::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ScreenshotTaker::CloseVisualFeedbackLayer,
+ base::Unretained(this)),
+ base::TimeDelta::FromMilliseconds(kVisualFeedbackLayerDisplayTimeMs));
+}
« no previous file with comments | « chrome/browser/ui/views/ash/screenshot_taker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698