Merge pull request #62 from brightray/window-frame
Some tweaks on making application looks better
This commit is contained in:
commit
8ad833b333
7 changed files with 57 additions and 13 deletions
|
@ -24,8 +24,29 @@
|
||||||
#include "browser/views/views_delegate.h"
|
#include "browser/views/views_delegate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
#include "ui/base/l10n/l10n_util_win.h"
|
||||||
|
#include "ui/gfx/platform_font_win.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// gfx::Font callbacks
|
||||||
|
void AdjustUIFont(LOGFONT* logfont) {
|
||||||
|
l10n_util::AdjustUIFont(logfont);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetMinimumFontSize() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
#endif
|
||||||
|
|
||||||
BrowserMainParts::BrowserMainParts() {
|
BrowserMainParts::BrowserMainParts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +72,11 @@ void BrowserMainParts::ToolkitInitialized() {
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
views_delegate_.reset(new ViewsDelegate);
|
views_delegate_.reset(new ViewsDelegate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont;
|
||||||
|
gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserMainParts::PreMainMessageLoopStart() {
|
void BrowserMainParts::PreMainMessageLoopStart() {
|
||||||
|
|
|
@ -176,7 +176,7 @@ void InspectableWebContentsImpl::ActivateWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::CloseWindow() {
|
void InspectableWebContentsImpl::CloseWindow() {
|
||||||
CloseDevTools();
|
devtools_web_contents()->GetMainFrame()->DispatchBeforeUnload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetContentsResizingStrategy(
|
void InspectableWebContentsImpl::SetContentsResizingStrategy(
|
||||||
|
@ -305,4 +305,8 @@ void InspectableWebContentsImpl::HandleKeyboardEvent(
|
||||||
delegate->HandleKeyboardEvent(source, event);
|
delegate->HandleKeyboardEvent(source, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
||||||
|
CloseDevTools();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -109,6 +109,7 @@ class InspectableWebContentsImpl :
|
||||||
|
|
||||||
virtual void HandleKeyboardEvent(
|
virtual void HandleKeyboardEvent(
|
||||||
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||||
|
virtual void CloseContents(content::WebContents* source) OVERRIDE;
|
||||||
|
|
||||||
scoped_ptr<content::WebContents> web_contents_;
|
scoped_ptr<content::WebContents> web_contents_;
|
||||||
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
||||||
|
|
|
@ -140,7 +140,11 @@ void InspectableWebContentsViewViews::SetIsDocked(bool docked) {
|
||||||
devtools_window_web_view_,
|
devtools_window_web_view_,
|
||||||
devtools_window_.get());
|
devtools_window_.get());
|
||||||
params.top_level = true;
|
params.top_level = true;
|
||||||
|
params.bounds = inspectable_web_contents()->GetDevToolsBounds();
|
||||||
|
#if defined(USE_X11)
|
||||||
|
// In X11 the window frame is drawn by the application.
|
||||||
params.remove_standard_frame = true;
|
params.remove_standard_frame = true;
|
||||||
|
#endif
|
||||||
devtools_window_->Init(params);
|
devtools_window_->Init(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
|
||||||
|
|
||||||
|
#if defined(OS_LINUX)
|
||||||
|
#include "ui/views/linux_ui/linux_ui.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
ViewsDelegate::ViewsDelegate() {
|
ViewsDelegate::ViewsDelegate() {
|
||||||
|
@ -85,7 +89,8 @@ void ViewsDelegate::OnBeforeWidgetInit(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The native_widget is required when using aura.
|
// The native_widget is required when using aura.
|
||||||
if (params->parent == NULL && params->context == NULL && !params->child)
|
if (params->type == views::Widget::InitParams::TYPE_MENU ||
|
||||||
|
(params->parent == NULL && params->context == NULL && !params->child))
|
||||||
params->native_widget = new views::DesktopNativeWidgetAura(delegate);
|
params->native_widget = new views::DesktopNativeWidgetAura(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +100,14 @@ base::TimeDelta ViewsDelegate::GetDefaultTextfieldObscuredRevealDuration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) {
|
bool ViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) {
|
||||||
return maximized;
|
#if defined(OS_LINUX)
|
||||||
|
// On Ubuntu Unity, the system always provides a title bar for maximized
|
||||||
|
// windows.
|
||||||
|
views::LinuxUI* ui = views::LinuxUI::instance();
|
||||||
|
return maximized && ui && ui->UnityIsRunning();
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -49,13 +49,7 @@ void MainDelegate::InitializeResourceBundle() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui::ResourceBundle::InitSharedInstanceWithPakPath(path);
|
ui::ResourceBundle::InitSharedInstanceWithPakPath(path);
|
||||||
|
AddDataPackFromPath(&ui::ResourceBundle::GetSharedInstance(), path.DirName());
|
||||||
std::vector<base::FilePath> pak_paths;
|
|
||||||
AddPakPaths(&pak_paths);
|
|
||||||
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) {
|
|
||||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
|
||||||
*it, ui::SCALE_FACTOR_NONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content::ContentBrowserClient* MainDelegate::CreateContentBrowserClient() {
|
content::ContentBrowserClient* MainDelegate::CreateContentBrowserClient() {
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||||
#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "content/public/app/content_main_delegate.h"
|
#include "content/public/app/content_main_delegate.h"
|
||||||
|
@ -15,6 +13,10 @@ namespace base {
|
||||||
class FilePath;
|
class FilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ui {
|
||||||
|
class ResourceBundle;
|
||||||
|
}
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class BrowserClient;
|
class BrowserClient;
|
||||||
|
@ -36,7 +38,8 @@ class MainDelegate : public content::ContentMainDelegate {
|
||||||
|
|
||||||
// Subclasses can override this to provide additional .pak files to be
|
// Subclasses can override this to provide additional .pak files to be
|
||||||
// included in the ui::ResourceBundle.
|
// included in the ui::ResourceBundle.
|
||||||
virtual void AddPakPaths(std::vector<base::FilePath>* pak_paths) {}
|
virtual void AddDataPackFromPath(
|
||||||
|
ui::ResourceBundle* bundle, const base::FilePath& pak_dir) {}
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// Subclasses can override this to custom the paths of child process and
|
// Subclasses can override this to custom the paths of child process and
|
||||||
|
|
Loading…
Add table
Reference in a new issue