Ruby GTK3移行後のメインリポジトリ
Revision | 01758d14194e223ed6d7d9c1ed89f0260fc5616a (tree) |
---|---|
Time | 2015-03-16 23:50:32 |
Author | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
update pix.rb
@@ -1081,6 +1081,7 @@ module Balloon | ||
1081 | 1081 | if not @__shown |
1082 | 1082 | return true |
1083 | 1083 | end |
1084 | + cr.translate(*@window.get_draw_offset) # XXX | |
1084 | 1085 | # assert @balloon_surface != nil |
1085 | 1086 | # scale = @scale |
1086 | 1087 | cr.scale(scale / 100.0, scale / 100.0) |
@@ -409,6 +409,7 @@ module Kinoko | ||
409 | 409 | end |
410 | 410 | |
411 | 411 | def redraw(widget, cr) |
412 | + cr.translate(*@window.get_draw_offset) # XXX | |
412 | 413 | scale = @__scale |
413 | 414 | cr.scale(scale / 100.0, scale / 100.0) |
414 | 415 | cr.set_source(@image_surface, 0, 0) |
@@ -373,6 +373,7 @@ module Nekodorif | ||
373 | 373 | end |
374 | 374 | |
375 | 375 | def redraw(widget, cr) |
376 | + cr.translate(*@window.get_draw_offset) # XXX | |
376 | 377 | scale = @__scale |
377 | 378 | cr.scale(scale / 100.0, scale / 100.0) |
378 | 379 | cr.set_source(@image_surface, 0, 0) |
@@ -15,11 +15,12 @@ require "gtk3" | ||
15 | 15 | module Pix |
16 | 16 | |
17 | 17 | class BaseTransparentWindow < Gtk::Window |
18 | + alias :base_move :move | |
18 | 19 | |
19 | 20 | def initialize(type=Gtk::Window::Type::TOPLEVEL) |
20 | 21 | super(type) |
21 | 22 | set_decorated(false) |
22 | -# set_resizable(false) | |
23 | + #set_resizable(false) # XXX | |
23 | 24 | screen_changed() |
24 | 25 | end |
25 | 26 |
@@ -48,67 +49,43 @@ module Pix | ||
48 | 49 | @__position = [0, 0] |
49 | 50 | @__surface_position = [0, 0] |
50 | 51 | @__redraw = nil |
51 | -# connect_after('size_allocate', size_allocate) | |
52 | + signal_connect_after('size_allocate') do |a| | |
53 | + size_allocate(a) | |
54 | + end | |
52 | 55 | # create drawing area |
53 | 56 | @darea = Gtk::DrawingArea.new |
54 | 57 | @darea.show() |
55 | -# @darea.connect = wrap_connect | |
56 | 58 | add(@darea) |
57 | 59 | override_background_color(Gtk::StateFlags::NORMAL, |
58 | 60 | Gdk::RGBA.new(0, 0, 0, 0)) |
59 | 61 | end |
60 | 62 | |
61 | -# def wrap_connect(self, signal, user_function, user_data=None): | |
62 | -# if signal == 'draw': | |
63 | -# self.__redraw = (user_function, user_data) | |
64 | -# Gtk.DrawingArea.connect(self.darea, signal, self.wrap_draw) | |
65 | -# else: | |
66 | -# if user_data is not None: | |
67 | -# Gtk.DrawingArea.connect( | |
68 | -# self.darea, signal, user_function, user_data) | |
69 | -# else: | |
70 | -# Gtk.DrawingArea.connect( | |
71 | -# self.darea, signal, user_function) | |
72 | - | |
73 | -# def wrap_draw(self, darea, cr): | |
74 | -# if self.__redraw is None: | |
75 | -# return | |
76 | -# cr.translate(*self.get_draw_offset()) | |
77 | -# user_function, user_data = self.__redraw | |
78 | -# if user_data is not None: | |
79 | -# user_function(darea, cr, user_data) | |
80 | -# else: | |
81 | -# user_function(darea, cr) | |
82 | -# ##region = Gdk.cairo_region_create_from_surface(cr.get_target()) | |
83 | -# ##self.input_shape_combine_region(region) | |
84 | -# _gtkhack.gtkwindow_set_input_shape(self, cr.get_target()) | |
85 | - | |
86 | 63 | def update_size(w, h) |
87 | -# self.get_child().set_size_request(w, h) # XXX | |
88 | -# self.queue_resize() | |
89 | 64 | @darea.set_size_request(w, h) # XXX |
90 | 65 | queue_resize() |
91 | 66 | end |
92 | 67 | |
93 | -# def size_allocate(self, widget, event): | |
94 | -# new_x, new_y = self.__position | |
95 | -# Gtk.Window.move(self, new_x, new_y) | |
68 | + def size_allocate(allocation) | |
69 | + new_x, new_y = @__position | |
70 | + base_move(new_x, new_y) | |
71 | + end | |
96 | 72 | |
97 | -# def move(x, y) | |
98 | -# left, top, scrn_w, scrn_h = get_workarea() | |
99 | -# w, h = self.get_child().get_size_request() # XXX | |
100 | -# new_x = min(max(left, x), scrn_w - w) | |
101 | -# new_y = min(max(top, y), scrn_h - h) | |
102 | -# Gtk.Window.move(self, new_x, new_y) | |
103 | -# self.__position = (new_x, new_y) | |
104 | -# self.__surface_position = (x, y) | |
105 | -# self.darea.queue_draw() | |
106 | -# end | |
73 | + def move(x, y) | |
74 | + left, top, scrn_w, scrn_h = Pix.get_workarea() | |
75 | + w, h = @darea.get_size_request() # XXX | |
76 | + new_x = [[left, x].max, scrn_w - w].min | |
77 | + new_y = [[top, y].max, scrn_h - h].min | |
78 | + base_move(new_x, new_y) | |
79 | + @__position = [new_x, new_y] | |
80 | + @__surface_position = [x, y] | |
81 | + @darea.queue_draw() | |
82 | + end | |
107 | 83 | |
108 | -# def get_draw_offset(self): | |
109 | -# window_x, window_y = self.__position | |
110 | -# surface_x, surface_y = self.__surface_position | |
111 | -# return surface_x - window_x, surface_y - window_y | |
84 | + def get_draw_offset | |
85 | + window_x, window_y = @__position | |
86 | + surface_x, surface_y = @__surface_position | |
87 | + return surface_x - window_x, surface_y - window_y | |
88 | + end | |
112 | 89 | |
113 | 90 | def winpos_to_surfacepos(x, y, scale) |
114 | 91 | window_x, window_y = @__position |
@@ -117,7 +94,6 @@ module Pix | ||
117 | 94 | new_y = ((y - (surface_y - window_y)) * 100 / scale).to_i |
118 | 95 | return new_x, new_y |
119 | 96 | end |
120 | - | |
121 | 97 | end |
122 | 98 | |
123 | 99 |
@@ -1445,6 +1445,7 @@ module Surface | ||
1445 | 1445 | if @image_surface == nil # XXX |
1446 | 1446 | return |
1447 | 1447 | end |
1448 | + cr.translate(*@window.get_draw_offset) # XXX | |
1448 | 1449 | cr.save() |
1449 | 1450 | scale = get_scale |
1450 | 1451 | cr.scale(scale / 100.0, scale / 100.0) |
@@ -19,6 +19,7 @@ module NinixTest | ||
19 | 19 | end |
20 | 20 | |
21 | 21 | def expose_cb(widget, cr) |
22 | + cr.translate(*@win.get_draw_offset) | |
22 | 23 | cr.set_source(@surface, 0, 0) |
23 | 24 | cr.set_operator(Cairo::OPERATOR_SOURCE) |
24 | 25 | cr.paint |