1 // Copyright (c) 2021 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // The contents of this file must follow a specific format in order to 33 // support the CEF translator tool. See the translator.README.txt file in the 34 // tools directory for more information. 35 // 36 37 #ifndef CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ 38 #define CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ 39 #pragma once 40 41 #include "include/cef_base.h" 42 43 class CefView; 44 class CefWindow; 45 46 /// 47 // Controller for an overlay that contains a contents View added via 48 // CefWindow::AddOverlayView. Methods exposed by this controller should be 49 // called in preference to methods of the same name exposed by the contents View 50 // unless otherwise indicated. Methods must be called on the browser process UI 51 // thread unless otherwise indicated. 52 /// 53 /*--cef(source=library)--*/ 54 class CefOverlayController : public CefBaseRefCounted { 55 public: 56 /// 57 // Returns true if this object is valid. 58 /// 59 /*--cef()--*/ 60 virtual bool IsValid() = 0; 61 62 /// 63 // Returns true if this object is the same as |that| object. 64 /// 65 /*--cef()--*/ 66 virtual bool IsSame(CefRefPtr<CefOverlayController> that) = 0; 67 68 /// 69 // Returns the contents View for this overlay. 70 /// 71 /*--cef()--*/ 72 virtual CefRefPtr<CefView> GetContentsView() = 0; 73 74 /// 75 // Returns the top-level Window hosting this overlay. Use this method instead 76 // of calling GetWindow() on the contents View. 77 /// 78 /*--cef()--*/ 79 virtual CefRefPtr<CefWindow> GetWindow() = 0; 80 81 /// 82 // Returns the docking mode for this overlay. 83 /// 84 /*--cef(default_retval=CEF_DOCKING_MODE_TOP_LEFT)--*/ 85 virtual cef_docking_mode_t GetDockingMode() = 0; 86 87 /// 88 // Destroy this overlay. 89 /// 90 /*--cef()--*/ 91 virtual void Destroy() = 0; 92 93 /// 94 // Sets the bounds (size and position) of this overlay. This will set the 95 // bounds of the contents View to match and trigger a re-layout if necessary. 96 // |bounds| is in parent coordinates and any insets configured on this overlay 97 // will be ignored. Use this method only for overlays created with a docking 98 // mode value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the 99 // insets of this overlay and/or layout of the contents View and call 100 // SizeToPreferredSize() instead to calculate the new size and re-position the 101 // overlay if necessary. 102 /// 103 /*--cef()--*/ 104 virtual void SetBounds(const CefRect& bounds) = 0; 105 106 /// 107 // Returns the bounds (size and position) of this overlay in parent 108 // coordinates. 109 /// 110 /*--cef()--*/ 111 virtual CefRect GetBounds() = 0; 112 113 /// 114 // Returns the bounds (size and position) of this overlay in DIP screen 115 // coordinates. 116 /// 117 /*--cef()--*/ 118 virtual CefRect GetBoundsInScreen() = 0; 119 120 /// 121 // Sets the size of this overlay without changing the position. This will set 122 // the size of the contents View to match and trigger a re-layout if 123 // necessary. |size| is in parent coordinates and any insets configured on 124 // this overlay will be ignored. Use this method only for overlays created 125 // with a docking mode value of CEF_DOCKING_MODE_CUSTOM. With other docking 126 // modes modify the insets of this overlay and/or layout of the contents View 127 // and call SizeToPreferredSize() instead to calculate the new size and 128 // re-position the overlay if necessary. 129 /// 130 /*--cef()--*/ 131 virtual void SetSize(const CefSize& size) = 0; 132 133 /// 134 // Returns the size of this overlay in parent coordinates. 135 /// 136 /*--cef()--*/ 137 virtual CefSize GetSize() = 0; 138 139 /// 140 // Sets the position of this overlay without changing the size. |position| is 141 // in parent coordinates and any insets configured on this overlay will 142 // be ignored. Use this method only for overlays created with a docking mode 143 // value of CEF_DOCKING_MODE_CUSTOM. With other docking modes modify the 144 // insets of this overlay and/or layout of the contents View and call 145 // SizeToPreferredSize() instead to calculate the new size and re-position the 146 // overlay if necessary. 147 /// 148 /*--cef()--*/ 149 virtual void SetPosition(const CefPoint& position) = 0; 150 151 /// 152 // Returns the position of this overlay in parent coordinates. 153 /// 154 /*--cef()--*/ 155 virtual CefPoint GetPosition() = 0; 156 157 /// 158 // Sets the insets for this overlay. |insets| is in parent coordinates. Use 159 // this method only for overlays created with a docking mode value other than 160 // CEF_DOCKING_MODE_CUSTOM. 161 /// 162 /*--cef()--*/ 163 virtual void SetInsets(const CefInsets& insets) = 0; 164 165 /// 166 // Returns the insets for this overlay in parent coordinates. 167 /// 168 /*--cef()--*/ 169 virtual CefInsets GetInsets() = 0; 170 171 /// 172 // Size this overlay to its preferred size and trigger a re-layout if 173 // necessary. The position of overlays created with a docking mode value of 174 // CEF_DOCKING_MODE_CUSTOM will not be modified by calling this method. With 175 // other docking modes this method may re-position the overlay if necessary to 176 // accommodate the new size and any insets configured on the contents View. 177 /// 178 /*--cef()--*/ 179 virtual void SizeToPreferredSize() = 0; 180 181 /// 182 // Sets whether this overlay is visible. Overlays are hidden by default. If 183 // this overlay is hidden then it and any child Views will not be drawn and, 184 // if any of those Views currently have focus, then focus will also be 185 // cleared. Painting is scheduled as needed. 186 /// 187 /*--cef()--*/ 188 virtual void SetVisible(bool visible) = 0; 189 190 /// 191 // Returns whether this overlay is visible. A View may be visible but still 192 // not drawn in a Window if any parent Views are hidden. Call IsDrawn() to 193 // determine whether this overlay and all parent Views are visible and will be 194 // drawn. 195 /// 196 /*--cef()--*/ 197 virtual bool IsVisible() = 0; 198 199 /// 200 // Returns whether this overlay is visible and drawn in a Window. A View is 201 // drawn if it and all parent Views are visible. To determine if the 202 // containing Window is visible to the user on-screen call IsVisible() on the 203 // Window. 204 /// 205 /*--cef()--*/ 206 virtual bool IsDrawn() = 0; 207 }; 208 209 #endif // CEF_INCLUDE_VIEWS_CEF_OVERLAY_CONTROLLER_H_ 210