• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be found
3 // in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_VIEWS_LABEL_BUTTON_VIEW_H_
6 #define CEF_LIBCEF_BROWSER_VIEWS_LABEL_BUTTON_VIEW_H_
7 #pragma once
8 
9 #include "include/views/cef_label_button.h"
10 #include "libcef/browser/views/button_view.h"
11 
12 #include "base/logging.h"
13 #include "ui/gfx/font_list.h"
14 
15 // Helpers for template boiler-plate.
16 #define CEF_LABEL_BUTTON_VIEW_T CEF_BUTTON_VIEW_T
17 #define CEF_LABEL_BUTTON_VIEW_A CEF_BUTTON_VIEW_A
18 #define CEF_LABEL_BUTTON_VIEW_D CefLabelButtonView<CEF_LABEL_BUTTON_VIEW_A>
19 
20 // Template for implementing views::View-derived classes that support adding and
21 // removing children (called a Panel in CEF terminology). See comments in
22 // view_impl.h for a usage overview.
23 CEF_LABEL_BUTTON_VIEW_T class CefLabelButtonView : public CEF_BUTTON_VIEW_D {
24  public:
25   using ParentClass = CEF_BUTTON_VIEW_D;
26 
27   // |cef_delegate| may be nullptr.
28   template <typename... Args>
CefLabelButtonView(CefViewDelegateClass * cef_delegate,Args...args)29   explicit CefLabelButtonView(CefViewDelegateClass* cef_delegate, Args... args)
30       : ParentClass(cef_delegate, args...) {}
31 
Initialize()32   void Initialize() override {
33     ParentClass::Initialize();
34 
35     // Use our defaults instead of the Views framework defaults.
36     ParentClass::SetFontList(gfx::FontList(view_util::kDefaultFontList));
37   }
38 
39   // Returns the CefLabelButton associated with this view. See comments on
40   // CefViewView::GetCefView.
GetCefLabelButton()41   CefRefPtr<CefLabelButton> GetCefLabelButton() const {
42     CefRefPtr<CefLabelButton> label_button =
43         ParentClass::GetCefButton()->AsLabelButton();
44     DCHECK(label_button);
45     return label_button;
46   }
47 
48   // CefViewView methods:
HasMinimumSize()49   bool HasMinimumSize() const override { return true; }
50 };
51 
52 #endif  // CEF_LIBCEF_BROWSER_VIEWS_LABEL_BUTTON_VIEW_H_
53