Modify Window API to be more consistent.
* '_' becomes '-' * removes 'position' field * adds 'center' method.
This commit is contained in:
parent
e6a9add691
commit
34e9132b68
8 changed files with 30 additions and 24 deletions
|
@ -296,6 +296,15 @@ v8::Handle<v8::Value> Window::IsAlwaysOnTop(const v8::Arguments &args) {
|
||||||
return v8::Boolean::New(self->window_->IsAlwaysOnTop());
|
return v8::Boolean::New(self->window_->IsAlwaysOnTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
v8::Handle<v8::Value> Window::Center(const v8::Arguments &args) {
|
||||||
|
UNWRAP_WINDOW_AND_CHECK;
|
||||||
|
|
||||||
|
self->window_->Center();
|
||||||
|
|
||||||
|
return v8::Undefined();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
|
v8::Handle<v8::Value> Window::SetPosition(const v8::Arguments &args) {
|
||||||
UNWRAP_WINDOW_AND_CHECK;
|
UNWRAP_WINDOW_AND_CHECK;
|
||||||
|
@ -369,10 +378,10 @@ v8::Handle<v8::Value> Window::IsKiosk(const v8::Arguments &args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
v8::Handle<v8::Value> Window::ShowDevTools(const v8::Arguments &args) {
|
v8::Handle<v8::Value> Window::OpenDevTools(const v8::Arguments &args) {
|
||||||
UNWRAP_WINDOW_AND_CHECK;
|
UNWRAP_WINDOW_AND_CHECK;
|
||||||
|
|
||||||
self->window_->ShowDevTools();
|
self->window_->OpenDevTools();
|
||||||
|
|
||||||
return v8::Undefined();
|
return v8::Undefined();
|
||||||
}
|
}
|
||||||
|
@ -600,6 +609,7 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "isResizable", IsResizable);
|
NODE_SET_PROTOTYPE_METHOD(t, "isResizable", IsResizable);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setAlwaysOnTop", SetAlwaysOnTop);
|
NODE_SET_PROTOTYPE_METHOD(t, "setAlwaysOnTop", SetAlwaysOnTop);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "isAlwaysOnTop", IsAlwaysOnTop);
|
NODE_SET_PROTOTYPE_METHOD(t, "isAlwaysOnTop", IsAlwaysOnTop);
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(t, "center", Center);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setPosition", SetPosition);
|
NODE_SET_PROTOTYPE_METHOD(t, "setPosition", SetPosition);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "getPosition", GetPosition);
|
NODE_SET_PROTOTYPE_METHOD(t, "getPosition", GetPosition);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setTitle", SetTitle);
|
NODE_SET_PROTOTYPE_METHOD(t, "setTitle", SetTitle);
|
||||||
|
@ -607,7 +617,7 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "flashFrame", FlashFrame);
|
NODE_SET_PROTOTYPE_METHOD(t, "flashFrame", FlashFrame);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setKiosk", SetKiosk);
|
NODE_SET_PROTOTYPE_METHOD(t, "setKiosk", SetKiosk);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "isKiosk", IsKiosk);
|
NODE_SET_PROTOTYPE_METHOD(t, "isKiosk", IsKiosk);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "showDevTools", ShowDevTools);
|
NODE_SET_PROTOTYPE_METHOD(t, "openDevTools", OpenDevTools);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
|
NODE_SET_PROTOTYPE_METHOD(t, "closeDevTools", CloseDevTools);
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
|
NODE_SET_PROTOTYPE_METHOD(t, "getPageTitle", GetPageTitle);
|
||||||
|
|
|
@ -63,6 +63,7 @@ class Window : public EventEmitter,
|
||||||
static v8::Handle<v8::Value> IsResizable(const v8::Arguments &args);
|
static v8::Handle<v8::Value> IsResizable(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> SetAlwaysOnTop(const v8::Arguments &args);
|
static v8::Handle<v8::Value> SetAlwaysOnTop(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> IsAlwaysOnTop(const v8::Arguments &args);
|
static v8::Handle<v8::Value> IsAlwaysOnTop(const v8::Arguments &args);
|
||||||
|
static v8::Handle<v8::Value> Center(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> SetPosition(const v8::Arguments &args);
|
static v8::Handle<v8::Value> SetPosition(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> GetPosition(const v8::Arguments &args);
|
static v8::Handle<v8::Value> GetPosition(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> SetTitle(const v8::Arguments &args);
|
static v8::Handle<v8::Value> SetTitle(const v8::Arguments &args);
|
||||||
|
@ -70,7 +71,7 @@ class Window : public EventEmitter,
|
||||||
static v8::Handle<v8::Value> FlashFrame(const v8::Arguments &args);
|
static v8::Handle<v8::Value> FlashFrame(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> SetKiosk(const v8::Arguments &args);
|
static v8::Handle<v8::Value> SetKiosk(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> IsKiosk(const v8::Arguments &args);
|
static v8::Handle<v8::Value> IsKiosk(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> ShowDevTools(const v8::Arguments &args);
|
static v8::Handle<v8::Value> OpenDevTools(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> CloseDevTools(const v8::Arguments &args);
|
static v8::Handle<v8::Value> CloseDevTools(const v8::Arguments &args);
|
||||||
|
|
||||||
// APIs for WebContents.
|
// APIs for WebContents.
|
||||||
|
|
|
@ -77,15 +77,15 @@ NativeWindow* NativeWindow::FromRenderView(int process_id, int routing_id) {
|
||||||
void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
|
void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
|
||||||
// Setup window from options.
|
// Setup window from options.
|
||||||
int x, y;
|
int x, y;
|
||||||
std::string position;
|
bool center;
|
||||||
if (options->GetInteger(switches::kX, &x) &&
|
if (options->GetInteger(switches::kX, &x) &&
|
||||||
options->GetInteger(switches::kY, &y)) {
|
options->GetInteger(switches::kY, &y)) {
|
||||||
int width, height;
|
int width, height;
|
||||||
options->GetInteger(switches::kWidth, &width);
|
options->GetInteger(switches::kWidth, &width);
|
||||||
options->GetInteger(switches::kHeight, &height);
|
options->GetInteger(switches::kHeight, &height);
|
||||||
Move(gfx::Rect(x, y, width, height));
|
Move(gfx::Rect(x, y, width, height));
|
||||||
} else if (options->GetString(switches::kPosition, &position)) {
|
} else if (options->GetBoolean(switches::kCenter, ¢er) && center) {
|
||||||
SetPosition(position);
|
Center();
|
||||||
}
|
}
|
||||||
int min_height, min_width;
|
int min_height, min_width;
|
||||||
if (options->GetInteger(switches::kMinHeight, &min_height) &&
|
if (options->GetInteger(switches::kMinHeight, &min_height) &&
|
||||||
|
@ -124,7 +124,7 @@ void NativeWindow::InitFromOptions(base::DictionaryValue* options) {
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::ShowDevTools() {
|
void NativeWindow::OpenDevTools() {
|
||||||
inspectable_web_contents()->ShowDevTools();
|
inspectable_web_contents()->ShowDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ class NativeWindow : public content::WebContentsDelegate,
|
||||||
virtual bool IsResizable() = 0;
|
virtual bool IsResizable() = 0;
|
||||||
virtual void SetAlwaysOnTop(bool top) = 0;
|
virtual void SetAlwaysOnTop(bool top) = 0;
|
||||||
virtual bool IsAlwaysOnTop() = 0;
|
virtual bool IsAlwaysOnTop() = 0;
|
||||||
virtual void SetPosition(const std::string& position) = 0;
|
virtual void Center() = 0;
|
||||||
virtual void SetPosition(const gfx::Point& position) = 0;
|
virtual void SetPosition(const gfx::Point& position) = 0;
|
||||||
virtual gfx::Point GetPosition() = 0;
|
virtual gfx::Point GetPosition() = 0;
|
||||||
virtual void SetTitle(const std::string& title) = 0;
|
virtual void SetTitle(const std::string& title) = 0;
|
||||||
|
@ -92,7 +92,7 @@ class NativeWindow : public content::WebContentsDelegate,
|
||||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||||
|
|
||||||
virtual bool IsClosed() const { return is_closed_; }
|
virtual bool IsClosed() const { return is_closed_; }
|
||||||
virtual void ShowDevTools();
|
virtual void OpenDevTools();
|
||||||
virtual void CloseDevTools();
|
virtual void CloseDevTools();
|
||||||
|
|
||||||
// The same with closing a tab in a real browser.
|
// The same with closing a tab in a real browser.
|
||||||
|
|
|
@ -41,7 +41,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
virtual bool IsResizable() OVERRIDE;
|
virtual bool IsResizable() OVERRIDE;
|
||||||
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
|
virtual void SetAlwaysOnTop(bool top) OVERRIDE;
|
||||||
virtual bool IsAlwaysOnTop() OVERRIDE;
|
virtual bool IsAlwaysOnTop() OVERRIDE;
|
||||||
virtual void SetPosition(const std::string& position) OVERRIDE;
|
virtual void Center() OVERRIDE;
|
||||||
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
|
virtual void SetPosition(const gfx::Point& position) OVERRIDE;
|
||||||
virtual gfx::Point GetPosition() OVERRIDE;
|
virtual gfx::Point GetPosition() OVERRIDE;
|
||||||
virtual void SetTitle(const std::string& title) OVERRIDE;
|
virtual void SetTitle(const std::string& title) OVERRIDE;
|
||||||
|
|
|
@ -302,8 +302,7 @@ bool NativeWindowMac::IsAlwaysOnTop() {
|
||||||
return [window() level] == NSFloatingWindowLevel;
|
return [window() level] == NSFloatingWindowLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetPosition(const std::string& position) {
|
void NativeWindowMac::Center() {
|
||||||
if (position == "center")
|
|
||||||
[window() center];
|
[window() center];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,21 +9,19 @@ namespace atom {
|
||||||
namespace switches {
|
namespace switches {
|
||||||
|
|
||||||
const char kTitle[] = "title";
|
const char kTitle[] = "title";
|
||||||
const char kToolbar[] = "toolbar";
|
|
||||||
const char kIcon[] = "icon";
|
const char kIcon[] = "icon";
|
||||||
const char kFrame[] = "frame";
|
const char kFrame[] = "frame";
|
||||||
const char kShow[] = "show";
|
const char kShow[] = "show";
|
||||||
const char kPosition[] = "position";
|
const char kCenter[] = "center";
|
||||||
const char kX[] = "x";
|
const char kX[] = "x";
|
||||||
const char kY[] = "y";
|
const char kY[] = "y";
|
||||||
const char kWidth[] = "width";
|
const char kWidth[] = "width";
|
||||||
const char kHeight[] = "height";
|
const char kHeight[] = "height";
|
||||||
const char kMinWidth[] = "min_width";
|
const char kMinWidth[] = "min-width";
|
||||||
const char kMinHeight[] = "min_height";
|
const char kMinHeight[] = "min-height";
|
||||||
const char kMaxWidth[] = "max_width";
|
const char kMaxWidth[] = "max-width";
|
||||||
const char kMaxHeight[] = "max_height";
|
const char kMaxHeight[] = "max-height";
|
||||||
const char kResizable[] = "resizable";
|
const char kResizable[] = "resizable";
|
||||||
const char kAsDesktop[] = "as_desktop";
|
|
||||||
const char kFullscreen[] = "fullscreen";
|
const char kFullscreen[] = "fullscreen";
|
||||||
|
|
||||||
// Start with the kiosk mode, see Opera's page for description:
|
// Start with the kiosk mode, see Opera's page for description:
|
||||||
|
|
|
@ -10,11 +10,10 @@ namespace atom {
|
||||||
namespace switches {
|
namespace switches {
|
||||||
|
|
||||||
extern const char kTitle[];
|
extern const char kTitle[];
|
||||||
extern const char kToolbar[];
|
|
||||||
extern const char kIcon[];
|
extern const char kIcon[];
|
||||||
extern const char kFrame[];
|
extern const char kFrame[];
|
||||||
extern const char kShow[];
|
extern const char kShow[];
|
||||||
extern const char kPosition[];
|
extern const char kCenter[];
|
||||||
extern const char kX[];
|
extern const char kX[];
|
||||||
extern const char kY[];
|
extern const char kY[];
|
||||||
extern const char kWidth[];
|
extern const char kWidth[];
|
||||||
|
@ -24,7 +23,6 @@ extern const char kMinHeight[];
|
||||||
extern const char kMaxWidth[];
|
extern const char kMaxWidth[];
|
||||||
extern const char kMaxHeight[];
|
extern const char kMaxHeight[];
|
||||||
extern const char kResizable[];
|
extern const char kResizable[];
|
||||||
extern const char kAsDesktop[];
|
|
||||||
extern const char kFullscreen[];
|
extern const char kFullscreen[];
|
||||||
extern const char kKiosk[];
|
extern const char kKiosk[];
|
||||||
extern const char kAlwaysOnTop[];
|
extern const char kAlwaysOnTop[];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue