webview_ruby2 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/webview/webview.h +28 -1
- data/lib/webview_ruby/version.rb +1 -1
- data/lib/webview_ruby.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f6c1853c996c6411146688954116f2bd6325290ed6f71020e2df71bab7352c0
|
4
|
+
data.tar.gz: 68f16f8d2fb60a768a863d80ac8ddc3be0465687fb3e62dfdffda343a6d434e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490f3bed05d9875c39d45ee6073b7a564ea20c2bd7d5889bd2094054c1ff0a83049104e15b5054a35889dbe57985351d893bc052e6c76b7cc6803d07e3f3daa7
|
7
|
+
data.tar.gz: 206b3e1c83c61c6827d736f74514972253ff31aa674081a503c7fa0a9e922f70119e877bad1c879a18b2c2d4b90e97c091d856a537b2f5502504f7f0c871ccff
|
data/ext/webview/webview.h
CHANGED
@@ -69,6 +69,12 @@ WEBVIEW_API void webview_set_title(webview_t w, const char *title);
|
|
69
69
|
// Update the background color of the native window
|
70
70
|
WEBVIEW_API void webview_set_bg(webview_t w, double r, double g, double b, double a);
|
71
71
|
|
72
|
+
// Update the position of the native window
|
73
|
+
WEBVIEW_API void webview_set_pos(webview_t w, int x, int y);
|
74
|
+
|
75
|
+
// Get x positionof native window
|
76
|
+
WEBVIEW_API int webview_get_x(webview_t w);
|
77
|
+
|
72
78
|
// Window size hints
|
73
79
|
#define WEBVIEW_HINT_NONE 0 // Width and height are default size
|
74
80
|
#define WEBVIEW_HINT_MIN 1 // Width and height are minimum bounds
|
@@ -606,6 +612,8 @@ id operator"" _str(const char *s, std::size_t) {
|
|
606
612
|
|
607
613
|
class cocoa_wkwebview_engine {
|
608
614
|
public:
|
615
|
+
int pos_x = 0;
|
616
|
+
int pos_y = 0;
|
609
617
|
cocoa_wkwebview_engine(bool debug, void *window) {
|
610
618
|
// Application
|
611
619
|
id app = ((id(*)(id, SEL))objc_msgSend)("NSApplication"_cls,
|
@@ -739,6 +747,18 @@ public:
|
|
739
747
|
}));
|
740
748
|
}
|
741
749
|
|
750
|
+
void set_pos(int x, int y) {
|
751
|
+
((void (*)(id, SEL, CGPoint))objc_msgSend)(
|
752
|
+
m_window, "setFrameOrigin:"_sel,
|
753
|
+
CGPointMake(x, y)
|
754
|
+
);
|
755
|
+
this->pos_x = x;
|
756
|
+
}
|
757
|
+
|
758
|
+
int get_x() {
|
759
|
+
return this->pos_x;
|
760
|
+
}
|
761
|
+
|
742
762
|
void set_bg(double r, double g, double b, double a) {
|
743
763
|
((void (*)(id, SEL, id))objc_msgSend)(
|
744
764
|
m_window, "setBackgroundColor:"_sel,
|
@@ -758,7 +778,6 @@ public:
|
|
758
778
|
style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
759
779
|
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;
|
760
780
|
} else {
|
761
|
-
printf("not resizable!!!\n");
|
762
781
|
style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
763
782
|
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
|
764
783
|
}
|
@@ -1374,6 +1393,14 @@ WEBVIEW_API void webview_set_bg(webview_t w, double r, double g, double b, doubl
|
|
1374
1393
|
static_cast<webview::webview *>(w)->set_bg(r, g, b, a);
|
1375
1394
|
}
|
1376
1395
|
|
1396
|
+
WEBVIEW_API void webview_set_pos(webview_t w, int x, int y) {
|
1397
|
+
static_cast<webview::webview *>(w)->set_pos(x, y);
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
WEBVIEW_API int webview_get_x(webview_t w) {
|
1401
|
+
static_cast<webview::webview *>(w)->get_x();
|
1402
|
+
}
|
1403
|
+
|
1377
1404
|
WEBVIEW_API void webview_set_size(webview_t w, int width, int height,
|
1378
1405
|
int hints, int margin_top, bool resizable) {
|
1379
1406
|
static_cast<webview::webview *>(w)->set_size(width, height, hints, margin_top, resizable);
|
data/lib/webview_ruby/version.rb
CHANGED
data/lib/webview_ruby.rb
CHANGED
@@ -12,6 +12,7 @@ module WebviewRuby
|
|
12
12
|
attach_function :webview_run, [:pointer], :void
|
13
13
|
attach_function :webview_terminate, [:pointer], :void
|
14
14
|
attach_function :webview_set_title, [:pointer, :string], :void
|
15
|
+
attach_function :webview_set_pos, [:pointer, :int, :int], :void
|
15
16
|
attach_function :webview_set_bg, [:pointer, :double, :double, :double, :double], :void
|
16
17
|
attach_function :webview_set_size, [:pointer, :int, :int, :int, :int, :bool], :void
|
17
18
|
attach_function :webview_navigate, [:pointer, :string], :void
|
@@ -19,6 +20,7 @@ module WebviewRuby
|
|
19
20
|
attach_function :webview_bind, [:pointer, :string, :pointer, :pointer], :void
|
20
21
|
attach_function :webview_eval, [:pointer, :string], :void
|
21
22
|
attach_function :webview_init, [:pointer, :string], :void
|
23
|
+
attach_function :webview_get_x, [:pointer], :int
|
22
24
|
|
23
25
|
class Webview
|
24
26
|
attr_reader :is_running
|
@@ -29,6 +31,14 @@ module WebviewRuby
|
|
29
31
|
@window = WebviewRuby.webview_create(debug ? 1 : 0, nil)
|
30
32
|
end
|
31
33
|
|
34
|
+
def get_x()
|
35
|
+
WebviewRuby.webview_get_x(@window)
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_pos(x, y)
|
39
|
+
WebviewRuby.webview_set_pos(@window, x, y)
|
40
|
+
end
|
41
|
+
|
32
42
|
def set_bg(r, g, b, a)
|
33
43
|
WebviewRuby.webview_set_bg(@window, r, g, b, a)
|
34
44
|
end
|