views: Add groups and focus/blur callbacks (issue #2102)

- cefclient: Only make menus focusable when ALT is pressed.
- cefclient: Display sample top menu when passed the `--show-top-menu`
  command-line flag.
This commit is contained in:
Marshall Greenblatt
2017-02-17 21:08:51 -05:00
parent bd1b80198f
commit 6ed4fe96b8
58 changed files with 1284 additions and 39 deletions

View File

@@ -377,6 +377,8 @@ CEF_VIEW_IMPL_T class CefViewImpl : public CefViewAdapter,
CefRefPtr<CefWindow> GetWindow() override;
int GetID() override;
void SetID(int id) override;
int GetGroupID() override;
void SetGroupID(int group_id) override;
CefRefPtr<CefView> GetParentView() override;
CefRefPtr<CefView> GetViewForID(int id) override;
void SetBounds(const CefRect& bounds) override;
@@ -507,6 +509,19 @@ CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetID(int id) {
root_view()->set_id(id);
}
CEF_VIEW_IMPL_T int CEF_VIEW_IMPL_D::GetGroupID() {
CEF_REQUIRE_VALID_RETURN(0);
return root_view()->GetGroup();
}
CEF_VIEW_IMPL_T void CEF_VIEW_IMPL_D::SetGroupID(int group_id) {
CEF_REQUIRE_VALID_RETURN_VOID();
if (root_view()->GetGroup() != -1)
return;
root_view()->SetGroup(group_id);
}
CEF_VIEW_IMPL_T CefRefPtr<CefView> CEF_VIEW_IMPL_D::GetParentView() {
CEF_REQUIRE_VALID_RETURN(nullptr);
views::View* view = root_view()->parent();

View File

@@ -72,6 +72,8 @@ CEF_VIEW_VIEW_T class CefViewView : public ViewsViewClass {
void Layout() override;
void ViewHierarchyChanged(
const views::View::ViewHierarchyChangedDetails& details) override;
void OnFocus() override;
void OnBlur() override;
// Return true if this View is expected to have a minimum size (for example,
// a button where the minimum size is based on the label).
@@ -162,6 +164,18 @@ CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::ViewHierarchyChanged(
ParentClass::ViewHierarchyChanged(details);
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnFocus() {
if (cef_delegate())
cef_delegate()->OnFocus(GetCefView());
ParentClass::OnFocus();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::OnBlur() {
if (cef_delegate())
cef_delegate()->OnBlur(GetCefView());
ParentClass::OnBlur();
}
CEF_VIEW_VIEW_T void CEF_VIEW_VIEW_D::NotifyChildViewChanged(
const views::View::ViewHierarchyChangedDetails& details) {
if (!cef_delegate())