@@ -24,6 +24,24 @@ A cross-platform C++17 library that allows you to create a simple webview.
2424- Linux
2525 - (Runtime & Build) webkit2gtk
2626
27+ ## Example
28+ ```cpp
29+ #include <webview.hpp>
30+
31+ int main()
32+ {
33+ Webview::Window webview("webview", 800, 900);
34+ webview.expose(Webview::Function("addTen", [](int num) {
35+ return num + 10;
36+ }));
37+
38+ webview.run();
39+ return 0;
40+ }
41+ ```
42+
43+ For more examples see [ ` examples ` ] ( https://github.com/Soundux/webviewpp/tree/master/examples )
44+
2745## Embedding
2846webviewpp supports embedding of all required files.
2947To embed your files you have to use the [ embed-helper] ( https://github.com/Soundux/webviewpp/tree/master/embed-helper ) .
@@ -38,14 +56,234 @@ Usage:
3856 ./embed_helper < path to folder containing all the required files>
3957 ` ` `
4058 - Add the parent folder of the ` embedded` folder to your include directories
41- - Change `navigate ` calls to
59+ - Change ` setUrl ` calls to
4260 - ` embedded://< filepath> ` on Linux
4361 - ` file:///embedded/< filepath> ` on Windows
4462
4563> For an example see [examples/embedded](https://github.com/Soundux/webviewpp/tree/master/examples/embedded)
4664
4765# # Documentation
48- The documentation was moved to the [main header file](https://github.com/Soundux/webviewpp/blob/master/src/webview/webview.hpp#L200)
66+ # ## Window::hide
67+
68+ ` ` ` cpp
69+ void hide ();
70+ ` ` `
71+
72+ > Hides the window
73+
74+ -----
75+
76+ # ## Window::show
77+
78+ ` ` ` cpp
79+ void show ();
80+ ` ` `
81+
82+ > Shows the window
83+
84+ -----
85+
86+ # ## Window::isHidden
87+
88+ ` ` ` cpp
89+ bool isHidden ();
90+ ` ` `
91+
92+ ** Returns:**
93+ > Whether or the window is hidden
94+
95+ -----
96+
97+ # ## Window::setSize
98+
99+ ` ` ` cpp
100+ void setSize(std::size_t, std::size_t);
101+ ` ` `
102+
103+ > Sets the window size
104+
105+ -----
106+
107+ # ## Window::getSize
108+
109+ ` ` ` cpp
110+ std::pair< std::size_t, std::size_t> getSize ();
111+ ` ` `
112+
113+ ** Returns:**
114+ > The width and height in form of an ` std::pair`
115+
116+ -----
117+
118+ # ## Window::getTitle
119+
120+ ` ` ` cpp
121+ std::string getTitle ();
122+ ` ` `
123+
124+ ** Returns:**
125+ > The title of the window
126+
127+ -----
128+
129+ # ## Window::setTitle
130+
131+ ` ` ` cpp
132+ void setTitle(std::string);
133+ ` ` `
134+
135+ > Sets the window title
136+
137+ -----
138+
139+ # ## Window::run
140+
141+ ` ` ` cpp
142+ void run ();
143+ ` ` `
144+
145+ > Runs the mainloop
146+
147+ ** Remarks:**
148+ > Is blocking
149+
150+ -----
151+
152+ # ## Window::exit
153+
154+ ` ` ` cpp
155+ void exit ();
156+ ` ` `
157+
158+ > Closes the webview
159+
160+ -----
161+
162+ # ## Window::getUrl
163+
164+ ` ` ` cpp
165+ std::string getUrl ();
166+ ` ` `
167+
168+ ** Returns:**
169+ > The current url
170+
171+ -----
172+
173+ # ## Window::setUrl
174+
175+ ` ` ` cpp
176+ void setUrl(std::string);
177+ ` ` `
178+
179+ > Navigates to the given url
180+
181+ -----
182+
183+ # ## Window::enableContextMenu
184+
185+ ` ` ` cpp
186+ void enableContextMenu(bool);
187+ ` ` `
188+
189+ > Enables the context menu
190+
191+ -----
192+
193+ # ## Window::enableDevTools
194+
195+ ` ` ` cpp
196+ void enableDevTools(bool);
197+ ` ` `
198+
199+ > Enables the developer tools
200+
201+ -----
202+
203+ # ## Window::expose
204+
205+ ` ` ` cpp
206+ void expose(Webview::Function const& );
207+ ` ` `
208+
209+ > Exposes the given function
210+
211+ ** Remarks:**
212+ > If the given Function is an ` AsyncFunction` it will be run in a new thread
213+
214+ -----
215+
216+ # ## Window::callFunction
217+
218+ ` ` ` cpp
219+ template < typename T>
220+ std::future< T> callFunction(Webview::JavaScriptFunction&& function);
221+ ` ` `
222+
223+ > Calls the given javascript function
224+
225+ ** Returns:**
226+ > The result of the javascript function call as ` T`
227+
228+ ** Preconditions**
229+ > ` T` must be serializable by nlohmann::json
230+
231+ ** Remarks:**
232+ > You should never call `.get ()` on the returned future in a ** non async** context as it will freeze the webview
233+
234+ -----
235+
236+ # ## Window::runCode
237+
238+ ` ` ` cpp
239+ void runCode(std::string const& );
240+ ```
241+
242+ > Runs the given javascript code
243+
244+ -----
245+
246+ ### Window::injectCode
247+
248+ ``` cpp
249+ void injectCode (std::string const&);
250+ ```
251+
252+ > Makes the given javascript code run on document load
253+
254+ -----
255+
256+ ### Window::setCloseCallback
257+
258+ ``` cpp
259+ void setCloseCallback(std::function<bool ()>);
260+ ```
261+
262+ > Sets the close-callback to the given callback
263+
264+ ** Remarks:**
265+ > If the callback returns ` true ` the webview will not close
266+
267+ -----
268+
269+ ### Window::setNavigateCallback
270+
271+ ``` cpp
272+ void setNavigateCallback (std::function<void (const std::string &)>);
273+ ```
274+
275+ > Sets the navigate-callback to the given callback
276+
277+ -----
278+
279+ ### Window::setResizeCallback
280+
281+ ``` cpp
282+ void setResizeCallback(std::function<void (std::size_t, std::size_t)>);
283+ ```
284+
285+ > Sets the resize-callback to the given callback
49286
287+ -----
50288
51- > Note: This work was originally based on the work of [MichaelKim](https://github.com/MichaelKim/webview)
289+ > This work was originally based on the work of [ MichaelKim] ( https://github.com/MichaelKim/webview )
0 commit comments