• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revisión01758d14194e223ed6d7d9c1ed89f0260fc5616a (tree)
Tiempo2015-03-16 23:50:32
AutorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

update pix.rb

Cambiar Resumen

Diferencia incremental

--- a/lib/ninix/balloon.rb
+++ b/lib/ninix/balloon.rb
@@ -1081,6 +1081,7 @@ module Balloon
10811081 if not @__shown
10821082 return true
10831083 end
1084+ cr.translate(*@window.get_draw_offset) # XXX
10841085 # assert @balloon_surface != nil
10851086 # scale = @scale
10861087 cr.scale(scale / 100.0, scale / 100.0)
--- a/lib/ninix/kinoko.rb
+++ b/lib/ninix/kinoko.rb
@@ -409,6 +409,7 @@ module Kinoko
409409 end
410410
411411 def redraw(widget, cr)
412+ cr.translate(*@window.get_draw_offset) # XXX
412413 scale = @__scale
413414 cr.scale(scale / 100.0, scale / 100.0)
414415 cr.set_source(@image_surface, 0, 0)
--- a/lib/ninix/nekodorif.rb
+++ b/lib/ninix/nekodorif.rb
@@ -373,6 +373,7 @@ module Nekodorif
373373 end
374374
375375 def redraw(widget, cr)
376+ cr.translate(*@window.get_draw_offset) # XXX
376377 scale = @__scale
377378 cr.scale(scale / 100.0, scale / 100.0)
378379 cr.set_source(@image_surface, 0, 0)
--- a/lib/ninix/pix.rb
+++ b/lib/ninix/pix.rb
@@ -15,11 +15,12 @@ require "gtk3"
1515 module Pix
1616
1717 class BaseTransparentWindow < Gtk::Window
18+ alias :base_move :move
1819
1920 def initialize(type=Gtk::Window::Type::TOPLEVEL)
2021 super(type)
2122 set_decorated(false)
22-# set_resizable(false)
23+ #set_resizable(false) # XXX
2324 screen_changed()
2425 end
2526
@@ -48,67 +49,43 @@ module Pix
4849 @__position = [0, 0]
4950 @__surface_position = [0, 0]
5051 @__redraw = nil
51-# connect_after('size_allocate', size_allocate)
52+ signal_connect_after('size_allocate') do |a|
53+ size_allocate(a)
54+ end
5255 # create drawing area
5356 @darea = Gtk::DrawingArea.new
5457 @darea.show()
55-# @darea.connect = wrap_connect
5658 add(@darea)
5759 override_background_color(Gtk::StateFlags::NORMAL,
5860 Gdk::RGBA.new(0, 0, 0, 0))
5961 end
6062
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-
8663 def update_size(w, h)
87-# self.get_child().set_size_request(w, h) # XXX
88-# self.queue_resize()
8964 @darea.set_size_request(w, h) # XXX
9065 queue_resize()
9166 end
9267
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
9672
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
10783
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
11289
11390 def winpos_to_surfacepos(x, y, scale)
11491 window_x, window_y = @__position
@@ -117,7 +94,6 @@ module Pix
11794 new_y = ((y - (surface_y - window_y)) * 100 / scale).to_i
11895 return new_x, new_y
11996 end
120-
12197 end
12298
12399
--- a/lib/ninix/surface.rb
+++ b/lib/ninix/surface.rb
@@ -1445,6 +1445,7 @@ module Surface
14451445 if @image_surface == nil # XXX
14461446 return
14471447 end
1448+ cr.translate(*@window.get_draw_offset) # XXX
14481449 cr.save()
14491450 scale = get_scale
14501451 cr.scale(scale / 100.0, scale / 100.0)
--- a/test/test-pix.rb
+++ b/test/test-pix.rb
@@ -19,6 +19,7 @@ module NinixTest
1919 end
2020
2121 def expose_cb(widget, cr)
22+ cr.translate(*@win.get_draw_offset)
2223 cr.set_source(@surface, 0, 0)
2324 cr.set_operator(Cairo::OPERATOR_SOURCE)
2425 cr.paint