#include "atom/browser/native_window_efl.h"
-#include "base/logging.h"
+#include <Elementary.h>
+
+#include "atom/common/options_switches.h"
+#include "base/command_line.h"
+#include "content/public/browser/web_contents.h"
+#include "efl/window_factory.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/image/image.h"
namespace atom {
+namespace {
+
+const int kDefaultWindowWidthDip = 800;
+const int kDefaultWindowHeightDip = 600;
+
+}
+
NativeWindowEfl::NativeWindowEfl(
- brightray::InspectableWebContents* web_contents,
+ brightray::InspectableWebContents* inspectable_web_contents,
const mate::Dictionary& options,
NativeWindow* parent)
- : NativeWindow(web_contents, options, parent) {
-}
+ : NativeWindow(inspectable_web_contents, options, parent) {
+// options.Get(switches::kTitle, &title_);
+
+ // Create Host window via elf::WindowFactory
+ window_ = efl::WindowFactory::GetHostWindow(web_contents_);
+ DCHECK(window_);
+
+ gfx::Size size = gfx::Size(kDefaultWindowWidthDip, kDefaultWindowHeightDip);
-NativeWindowEfl::~NativeWindowEfl() {
+ evas_object_smart_callback_add(window_, "delete,request",
+ OnWindowDeleteRequest, this);
+
+ evas_object_resize(window_, size.width(), size.height());
+
+ // Add a new box to the parent.
+ Evas_Object* box = elm_box_add(window_);
+ evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(window_, box);
+ evas_object_show(box);
+
+ // Add view at the end of the pack list.
+ Evas_Object* view = static_cast<Evas_Object*>(web_contents_->GetNativeView());
+ evas_object_size_hint_align_set(view, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_box_pack_end(box, view);
+
+ web_contents_->Focus();
}
void NativeWindowEfl::Close() {
- NOTIMPLEMENTED();
+ if(window_)
+ evas_object_del(window_);
+ window_ = nullptr;
}
void NativeWindowEfl::CloseImmediately() {
}
void NativeWindowEfl::Show() {
- NOTIMPLEMENTED();
+ evas_object_show(window_);
}
void NativeWindowEfl::ShowInactive() {
}
void NativeWindowEfl::Hide() {
- NOTIMPLEMENTED();
+ evas_object_hide(window_);
}
bool NativeWindowEfl::IsVisible() {
}
void NativeWindowEfl::Maximize() {
- NOTIMPLEMENTED();
+ elm_win_maximized_set(window_, EINA_TRUE);
}
void NativeWindowEfl::Unmaximize() {
- NOTIMPLEMENTED();
+ elm_win_maximized_set(window_, EINA_FALSE);
}
bool NativeWindowEfl::IsMaximized() {
- NOTIMPLEMENTED();
- return true;
+ return elm_win_maximized_get(window_);
}
void NativeWindowEfl::Minimize() {
}
bool NativeWindowEfl::IsMinimized() {
- NOTIMPLEMENTED();
- return true;
+ return !elm_win_maximized_get(window_);
}
void NativeWindowEfl::SetFullScreen(bool fullscreen) {
- NOTIMPLEMENTED();
+ elm_win_fullscreen_set(window_, fullscreen);
}
bool NativeWindowEfl::IsFullscreen() const {
- NOTIMPLEMENTED();
- return true;
+ return elm_win_fullscreen_get(window_);
}
void NativeWindowEfl::SetBounds(const gfx::Rect& bounds, bool animate) {
- NOTIMPLEMENTED();
+ //evas_object_resize(window_, size.width(), size.height());
}
+
gfx::Rect NativeWindowEfl::GetBounds() {
- NOTIMPLEMENTED();
return gfx::Rect();
+// int width, height;
+// evas_object_geometry_get(window_, nullptr, nullptr, &width, &height);
+// return gfx::Size(width, height);
}
void NativeWindowEfl::SetResizable(bool resizable) {
}
void NativeWindowEfl::SetTitle(const std::string& title) {
- NOTIMPLEMENTED();
+ title_ = title;
+ elm_win_title_set(window_, title.c_str());
}
std::string NativeWindowEfl::GetTitle() {
- NOTIMPLEMENTED();
+ return title_;
}
void NativeWindowEfl::FlashFrame(bool flash) {
NOTIMPLEMENTED();
}
gfx::NativeWindow NativeWindowEfl::GetNativeWindow() {
- NOTIMPLEMENTED();
- return gfx::NativeWindow();
+ return window_;
}
gfx::AcceleratedWidget NativeWindowEfl::GetAcceleratedWidget() {
}
// static
+void NativeWindowEfl::OnWindowDeleteRequest(void* data, Evas_Object*, void*) {
+ NativeWindowEfl* thiz = static_cast<NativeWindowEfl*>(data);
+ if(!elm_win_autodel_get(thiz->window_))
+ thiz->Close();
+ thiz->window_ = nullptr;
+ thiz->web_contents_->Close();
+}
+
+// static
NativeWindow* NativeWindow::Create(
- brightray::InspectableWebContents* inspectable_web_contents,
+ brightray::InspectableWebContents* web_contents,
const mate::Dictionary& options,
NativeWindow* parent) {
- return new NativeWindowEfl(inspectable_web_contents, options, parent);
+ return new NativeWindowEfl(web_contents, options, parent);
}
}