Ruby GTK3移行後のメインリポジトリ
修訂 | 05b11d14fe8fc3c2849149b7455e21ccef41e052 (tree) |
---|---|
時間 | 2018-07-07 18:07:49 |
作者 | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
misc fixes
@@ -1,5 +1,7 @@ | ||
1 | 1 | Sat July 7 2018 Shyouzou Sugitani <shy@users.osdn.me> |
2 | 2 | * できるだけ広範囲のバージョンのRuby/Gtk3で動作するように調整した. |
3 | + * easyballoon互換モジュールが旧描画方法のままになっていたのを修正した. | |
4 | + * CommunicateWindowが旧描画方法のままになっていたのを修正した. | |
3 | 5 | |
4 | 6 | Sun April 29 2018 Shyouzou Sugitani <shy@users.osdn.me> |
5 | 7 | * MCIAudio(R)互換モジュールのメッセージ処理を修正した. |
@@ -1505,6 +1505,7 @@ module Balloon | ||
1505 | 1505 | def new_(desc, balloon) |
1506 | 1506 | @window.destroy unless @window.nil? |
1507 | 1507 | @window = Pix::BaseTransparentWindow.new() |
1508 | + @__surface_position = [0, 0] | |
1508 | 1509 | @window.set_title('communicate') |
1509 | 1510 | @window.signal_connect('delete_event') do |w ,e| |
1510 | 1511 | next delete(w, e) |
@@ -1526,10 +1527,14 @@ module Balloon | ||
1526 | 1527 | @window.drag_dest_add_text_targets() |
1527 | 1528 | @window.set_events(Gdk::EventMask::BUTTON_PRESS_MASK) |
1528 | 1529 | @window.set_modal(true) |
1529 | - @window.set_window_position(Gtk::WindowPosition::CENTER) | |
1530 | + #@window.set_window_position(Gtk::WindowPosition::CENTER) | |
1530 | 1531 | @window.realize() |
1532 | + @window.override_background_color( | |
1533 | + Gtk::StateFlags::NORMAL, Gdk::RGBA.new(0, 0, 0, 0)) | |
1531 | 1534 | w = desc.get('communicatebox.width', :default => 250).to_i |
1532 | 1535 | h = desc.get('communicatebox.height', :default => -1).to_i |
1536 | + left, top, scrn_w, scrn_h = @window.workarea | |
1537 | + @__surface_position = [(scrn_w - w) / 2, (scrn_h - h) / 2] # XXX | |
1533 | 1538 | @entry = Gtk::Entry.new |
1534 | 1539 | @entry.signal_connect('activate') do |w| |
1535 | 1540 | next activate(w) |
@@ -1562,17 +1567,15 @@ module Balloon | ||
1562 | 1567 | x = desc.get('communicatebox.x', :default => 10).to_i |
1563 | 1568 | y = desc.get('communicatebox.y', :default => 20).to_i |
1564 | 1569 | overlay = Gtk::Overlay.new() |
1565 | - @entry.set_margin_left(x) | |
1566 | - @entry.set_margin_top(y) | |
1570 | + @entry.set_margin_left(x + get_draw_offset()[0]) | |
1571 | + @entry.set_margin_top(y + get_draw_offset()[1]) | |
1567 | 1572 | @entry.set_halign(Gtk::Align::START) |
1568 | 1573 | @entry.set_valign(Gtk::Align::START) |
1569 | 1574 | overlay.add_overlay(@entry) |
1570 | 1575 | overlay.add(darea) |
1571 | 1576 | overlay.show() |
1572 | 1577 | @window.add(overlay) |
1573 | - w = surface.width | |
1574 | - h = surface.height | |
1575 | - darea.set_size_request(w, h) | |
1578 | + darea.set_size_request(*@window.size) # XXX | |
1576 | 1579 | else |
1577 | 1580 | box = Gtk::Box.new(orientation=Gtk::Orientation::HORIZONTAL, spacing=10) |
1578 | 1581 | box.set_border_width(10) |
@@ -1591,11 +1594,25 @@ module Balloon | ||
1591 | 1594 | @entry.set_text(data.text) |
1592 | 1595 | end |
1593 | 1596 | |
1597 | + def get_draw_offset | |
1598 | + return @__surface_position | |
1599 | + end | |
1600 | + | |
1594 | 1601 | def redraw(widget, cr, surface) |
1602 | + cr.save() | |
1603 | + # clear | |
1604 | + cr.set_operator(Cairo::OPERATOR_SOURCE) | |
1605 | + cr.set_source_rgba(0, 0, 0, 0) | |
1606 | + cr.paint | |
1607 | + # translate the user-space origin | |
1608 | + cr.translate(*get_draw_offset) # XXX | |
1595 | 1609 | cr.set_source(surface, 0, 0) |
1596 | 1610 | cr.set_operator(Cairo::OPERATOR_SOURCE) |
1597 | - cr.paint() | |
1598 | - w, h = @window.size | |
1611 | + # copy rectangle on the destination | |
1612 | + cr.rectangle(0, 0, surface.width, surface.height) | |
1613 | + cr.fill() | |
1614 | + cr.restore() | |
1615 | + return if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ | |
1599 | 1616 | region = Pix.surface_to_region(cr.target.map_to_image) |
1600 | 1617 | # XXX: to avoid losing focus in the text input region |
1601 | 1618 | x = @entry.margin_left |
@@ -1603,7 +1620,13 @@ module Balloon | ||
1603 | 1620 | w = @entry.allocated_width |
1604 | 1621 | h = @entry.allocated_height |
1605 | 1622 | region.union!(x, y, w, h) |
1606 | - @window.input_shape_combine_region(region) | |
1623 | + if @window.supports_alpha | |
1624 | + @window.input_shape_combine_region(nil) | |
1625 | + @window.input_shape_combine_region(region) | |
1626 | + else | |
1627 | + @window.shape_combine_region(nil) | |
1628 | + @window.shape_combine_region(region) | |
1629 | + end | |
1607 | 1630 | end |
1608 | 1631 | |
1609 | 1632 | def destroy |
@@ -346,7 +346,7 @@ module Bln | ||
346 | 346 | @font_desc = Pango::FontDescription.new |
347 | 347 | @font_desc.set_family('Sans') |
348 | 348 | if data.include?('font.bold') and data['font.bold'] == 'on' |
349 | - @font_desc.set_weight(Pango::Weight::BOLD) | |
349 | + @font_desc.set_weight(:bold) | |
350 | 350 | end |
351 | 351 | @layout.set_wrap(:char) |
352 | 352 | set_layout() |
@@ -755,17 +755,15 @@ module Bln | ||
755 | 755 | end |
756 | 756 | |
757 | 757 | def redraw(widget, cr) |
758 | - scale = @scale | |
759 | - cr.scale(scale / 100.0, scale / 100.0) | |
760 | - cr.set_source(@balloon_surface, 0, 0) | |
761 | - cr.set_operator(Cairo::OPERATOR_SOURCE) | |
762 | - cr.paint() | |
758 | + @window.set_surface(cr, @balloon_surface, @scale) | |
763 | 759 | cr.set_operator(Cairo::OPERATOR_OVER) # restore default |
760 | + cr.translate(*@window.get_draw_offset) # XXX | |
764 | 761 | unless @layout.nil? |
765 | 762 | cr.set_source_rgb(*@fontcolor) |
766 | 763 | cr.move_to(@left.to_i, @top.to_i) |
767 | 764 | cr.show_pango_layout(@layout) |
768 | 765 | end |
766 | + @window.set_shape(cr) | |
769 | 767 | end |
770 | 768 | |
771 | 769 | def get_state |
@@ -49,7 +49,7 @@ module Pix | ||
49 | 49 | |
50 | 50 | class BaseTransparentWindow < Gtk::Window |
51 | 51 | alias :base_move :move |
52 | - attr_reader :workarea | |
52 | + attr_reader :workarea, :supports_alpha | |
53 | 53 | |
54 | 54 | def initialize(type: Gtk::WindowType::TOPLEVEL) |
55 | 55 | super(type) |