webview_ruby2 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eab6f29582a4a04bebb7dc1dd14db38e2d4d1041afc111c940129e7549f06480
4
- data.tar.gz: 8a423ecb26825ae46df65aaeb7d2b6763aeec91addf4d83e8087856cddcf774c
3
+ metadata.gz: 4ad654deb348a55143a6395212c24085e9700da0c594f0e5102230355cd73c65
4
+ data.tar.gz: 417619f51896ad0c838535dd75e23c18c5fde67986d4bf6bd97ba1bdfc6f8dc9
5
5
  SHA512:
6
- metadata.gz: 23ee929f420cb6e1ebdf72eaca0f5a0630f7d1ffb22279054da5020abeca3d89641a7bf9a7c891b0cf99f9dfe5ddb7f5e9ead22def4cde1a2d60468ebb542710
7
- data.tar.gz: b4d969cbc08b75206f8ff9483bf76acacb340b4744aa72424ec79a2604c4abb4589f0596fd00cb3c59a163316b5dd054c3bbb03b43e6c4147866346d8f85241c
6
+ metadata.gz: 6d341c94bd2cbcfe63b8ab5b80ea4d038c338af695e730210fab0ee6afc471820c00b2ca171919f6ca4eda8eb21a77f2b5031251dce1803385246d95696a6adc
7
+ data.tar.gz: a343abc4832cde04865e94d6661a866899e98570558aa9414e4af1cec95bc6663417df4ccbfddf6c7f128f3705998479ee3b1e6af99b8499298a22c91c88d534
@@ -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,
@@ -756,11 +776,10 @@ public:
756
776
  int style;
757
777
  if (resizable) {
758
778
  style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
759
- NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskFullSizeContentView;
779
+ NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable ; //| NSWindowStyleMaskFullSizeContentView;
760
780
  } else {
761
- printf("not resizable!!!\n");
762
781
  style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
763
- NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
782
+ NSWindowStyleMaskMiniaturizable ;//| NSWindowStyleMaskFullSizeContentView;
764
783
  }
765
784
 
766
785
  /*
@@ -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);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebviewRuby
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webview_ruby2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Concetto Rudilosso