Ruby GTK3移行後のメインリポジトリ
リビジョン | 9d98778b26e76ea7b91168b6c82c8500e70aa66f (tree) |
---|---|
日時 | 2015-03-18 22:56:55 |
作者 | Shyouzou Sugitani <shy@user...> |
コミッター | Shyouzou Sugitani |
update pix.rb
@@ -1166,6 +1166,7 @@ module Balloon | ||
1166 | 1166 | end |
1167 | 1167 | redraw_arrow0(widget, cr) |
1168 | 1168 | redraw_arrow1(widget, cr) |
1169 | + @window.set_shape(cr) | |
1169 | 1170 | return false |
1170 | 1171 | end |
1171 | 1172 |
@@ -416,6 +416,7 @@ module Kinoko | ||
416 | 416 | cr.set_operator(Cairo::OPERATOR_SOURCE) |
417 | 417 | cr.paint() |
418 | 418 | print("REDRAW: ", cr, "\n") |
419 | + @window.set_shape(cr) | |
419 | 420 | end |
420 | 421 | |
421 | 422 | def get_image_surface(surface_id) |
@@ -379,6 +379,7 @@ module Nekodorif | ||
379 | 379 | cr.set_source(@image_surface, 0, 0) |
380 | 380 | cr.set_operator(Cairo::OPERATOR_SOURCE) |
381 | 381 | cr.paint() |
382 | + @window.set_shape(cr) | |
382 | 383 | end |
383 | 384 | |
384 | 385 | def delete()#widget, event) |
@@ -94,6 +94,21 @@ module Pix | ||
94 | 94 | new_y = ((y - (surface_y - window_y)) * 100 / scale).to_i |
95 | 95 | return new_x, new_y |
96 | 96 | end |
97 | + | |
98 | + def set_shape(cr) | |
99 | + w, h = size | |
100 | + image_surface = cr.target.map_to_image | |
101 | + region = Cairo::Region.new() | |
102 | + data = image_surface.data | |
103 | + for i in 0..(data.size / 4 - 1) | |
104 | + if (data[i * 4 + 3].ord) != 0 | |
105 | + x = i % image_surface.width | |
106 | + y = i / image_surface.width | |
107 | + region.union!(x, y, 1, 1) | |
108 | + end | |
109 | + end | |
110 | + input_shape_combine_region(region) | |
111 | + end | |
97 | 112 | end |
98 | 113 | |
99 | 114 |
@@ -1321,12 +1321,12 @@ module Surface | ||
1321 | 1321 | end |
1322 | 1322 | |
1323 | 1323 | def get_image_surface(surface_id, is_asis=false) |
1324 | - if not @surfaces.include?(surface_id.to_s) | |
1324 | + if not @surfaces.include?(surface_id) | |
1325 | 1325 | # logging.debug('cannot load surface #{0}'.format(surface_id)) |
1326 | 1326 | print('cannot load surface #' + surface_id.to_s, "\n") |
1327 | 1327 | return Pix.create_blank_surface(100, 100) |
1328 | 1328 | end |
1329 | - return create_surface_from_file(surface_id.to_s, is_asis=is_asis) | |
1329 | + return create_surface_from_file(surface_id, is_asis=is_asis) | |
1330 | 1330 | end |
1331 | 1331 | |
1332 | 1332 | def draw_region(cr) |
@@ -1456,6 +1456,7 @@ module Surface | ||
1456 | 1456 | if @parent.handle_request('GET', 'get_preference', 'check_collision') |
1457 | 1457 | draw_region(cr) |
1458 | 1458 | end |
1459 | + @window.set_shape(cr) | |
1459 | 1460 | end |
1460 | 1461 | |
1461 | 1462 | def remove_overlay(actor) |
@@ -23,16 +23,7 @@ module NinixTest | ||
23 | 23 | cr.set_source(@surface, 0, 0) |
24 | 24 | cr.set_operator(Cairo::OPERATOR_SOURCE) |
25 | 25 | cr.paint |
26 | - region = Cairo::Region.new() | |
27 | - data = @surface.data | |
28 | - for i in 0..(data.size / 4 - 1) | |
29 | - if (data[i * 4 + 3].ord) != 0 | |
30 | - x = i % @surface.width | |
31 | - y = i / @surface.width | |
32 | - region.union!(x, y, 1, 1) | |
33 | - end | |
34 | - end | |
35 | - @win.input_shape_combine_region(region) | |
26 | + @win.set_shape(cr) | |
36 | 27 | end |
37 | 28 | end |
38 | 29 | end |