Merge pull request #1106 from paulcbetts/set-overlay-icon
Set window overlay icon
This commit is contained in:
commit
6b37f30bd6
8 changed files with 54 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "atom/browser/native_window.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "native_mate/callback.h"
|
||||
|
@ -400,6 +401,11 @@ void Window::SetProgressBar(double progress) {
|
|||
window_->SetProgressBar(progress);
|
||||
}
|
||||
|
||||
void Window::SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) {
|
||||
window_->SetOverlayIcon(overlay, description);
|
||||
}
|
||||
|
||||
void Window::SetAutoHideMenuBar(bool auto_hide) {
|
||||
window_->SetAutoHideMenuBar(auto_hide);
|
||||
}
|
||||
|
@ -487,6 +493,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("capturePage", &Window::CapturePage)
|
||||
.SetMethod("print", &Window::Print)
|
||||
.SetMethod("setProgressBar", &Window::SetProgressBar)
|
||||
.SetMethod("setOverlayIcon", &Window::SetOverlayIcon)
|
||||
.SetMethod("setAutoHideMenuBar", &Window::SetAutoHideMenuBar)
|
||||
.SetMethod("isMenuBarAutoHide", &Window::IsMenuBarAutoHide)
|
||||
.SetMethod("setMenuBarVisibility", &Window::SetMenuBarVisibility)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "atom/browser/native_window_observer.h"
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "native_mate/handle.h"
|
||||
|
@ -118,6 +119,8 @@ class Window : public mate::EventEmitter,
|
|||
void CapturePage(mate::Arguments* args);
|
||||
void Print(mate::Arguments* args);
|
||||
void SetProgressBar(double progress);
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description);
|
||||
void SetAutoHideMenuBar(bool auto_hide);
|
||||
bool IsMenuBarAutoHide();
|
||||
void SetMenuBarVisibility(bool visible);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
namespace base {
|
||||
class CommandLine;
|
||||
|
@ -142,6 +142,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
virtual bool HasModalDialog();
|
||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||
virtual void SetProgressBar(double progress) = 0;
|
||||
virtual void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) = 0;
|
||||
|
||||
virtual bool IsClosed() const { return is_closed_; }
|
||||
virtual void OpenDevTools();
|
||||
|
|
|
@ -71,6 +71,8 @@ class NativeWindowMac : public NativeWindow {
|
|||
bool HasModalDialog() override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
void SetProgressBar(double progress) override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
void ShowDefinitionForSelection() override;
|
||||
|
||||
// Returns true if |point| in local Cocoa coordinate system falls within
|
||||
|
|
|
@ -678,6 +678,10 @@ void NativeWindowMac::SetProgressBar(double progress) {
|
|||
[dock_tile display];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) {
|
||||
}
|
||||
|
||||
void NativeWindowMac::ShowDefinitionForSelection() {
|
||||
content::WebContents* web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "ui/aura/window.h"
|
||||
#include "ui/aura/window_tree_host.h"
|
||||
#include "ui/base/hit_test.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "ui/views/background.h"
|
||||
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||
#include "ui/views/controls/webview/webview.h"
|
||||
|
@ -51,6 +52,7 @@
|
|||
#include "base/win/scoped_comptr.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#include "ui/gfx/icon_util.h"
|
||||
#include "ui/gfx/win/dpi.h"
|
||||
#include "ui/views/win/hwnd_util.h"
|
||||
#endif
|
||||
|
@ -613,6 +615,28 @@ void NativeWindowViews::SetProgressBar(double progress) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) {
|
||||
#if defined(OS_WIN)
|
||||
if (base::win::GetVersion() < base::win::VERSION_WIN7)
|
||||
return;
|
||||
|
||||
base::win::ScopedComPtr<ITaskbarList3> taskbar;
|
||||
if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList, NULL,
|
||||
CLSCTX_INPROC_SERVER) ||
|
||||
FAILED(taskbar->HrInit()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
HWND frame = views::HWNDForNativeWindow(GetNativeWindow());
|
||||
|
||||
std::wstring wstr = std::wstring(description.begin(), description.end());
|
||||
taskbar->SetOverlayIcon(frame,
|
||||
IconUtil::CreateHICONFromSkBitmap(overlay.AsBitmap()),
|
||||
wstr.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetAutoHideMenuBar(bool auto_hide) {
|
||||
menu_bar_autohide_ = auto_hide;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ class NativeWindowViews : public NativeWindow,
|
|||
bool IsKiosk() override;
|
||||
void SetMenu(ui::MenuModel* menu_model) override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
void SetProgressBar(double value) override;
|
||||
void SetAutoHideMenuBar(bool auto_hide) override;
|
||||
bool IsMenuBarAutoHide() override;
|
||||
|
|
|
@ -540,6 +540,15 @@ On Linux platform, only supports Unity desktop environment, you need to specify
|
|||
the `*.desktop` file name to `desktopName` field in `package.json`. By default,
|
||||
it will assume `app.getName().desktop`.
|
||||
|
||||
### BrowserWindow.setOverlayIcon(overlay, description)
|
||||
|
||||
* `overlay` [Image](image.md) - the icon to display on the bottom right corner of the Taskbar icon. If this parameter is `null`, the overlay is cleared.
|
||||
* `description` String - a description that will be provided to Accessibility screenreaders
|
||||
|
||||
Sets a 16px overlay onto the current Taskbar icon, usually used to convey some sort of application status or to passively notify the user.
|
||||
|
||||
__Note:__ This API is only available on Windows, Win7 or above
|
||||
|
||||
### BrowserWindow.showDefinitionForSelection()
|
||||
|
||||
Shows pop-up dictionary that searches the selected word on the page.
|
||||
|
|
Loading…
Reference in a new issue