-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because GTK 4 uses "surface".
- Loading branch information
Showing
8 changed files
with
98 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2006-2015 Kouhei Sutou <[email protected]> | ||
# Copyright (C) 2006-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -39,17 +39,17 @@ def keep(name) | |
@stocks[name].push(@current) | ||
end | ||
|
||
def restore(drawable, name) | ||
def restore(surface, name) | ||
if name.nil? | ||
type = @current | ||
else | ||
type = @stocks[name].pop | ||
end | ||
drawable.cursor = type_to_cursor(type) | ||
surface.cursor = type_to_cursor(type) | ||
end | ||
|
||
def update(drawable, type) | ||
drawable.cursor = type_to_cursor(type) | ||
def update(surface, type) | ||
surface.cursor = type_to_cursor(type) | ||
end | ||
|
||
private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2006-2019 Kouhei Sutou <[email protected]> | ||
# Copyright (C) 2006-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -25,7 +25,7 @@ module Base | |
include HookHandler | ||
|
||
def initialize(*args, &block) | ||
@drawable = nil | ||
@surface = nil | ||
@size = nil | ||
@size_dirty = true | ||
super | ||
|
@@ -154,9 +154,9 @@ def draw_slide(slide, simulation) | |
end | ||
|
||
private | ||
def set_drawable(drawable) | ||
@drawable = drawable | ||
set_default_size(@drawable.width, @drawable.height) | ||
def set_surface(surface) | ||
@surface = surface | ||
set_default_size(@surface.width, @surface.height) | ||
end | ||
|
||
def set_default_size(w, h) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
require "rabbit/cursor-manager" | ||
|
||
module Rabbit | ||
|
@@ -19,13 +35,13 @@ def keep_cursor(name) | |
end | ||
|
||
def restore_cursor(name) | ||
@cursor_manager.restore(@drawable, name) | ||
@cursor_manager.restore(@surface, name) | ||
end | ||
|
||
def update_cursor(cursor_type, update_current_cursor=false) | ||
@cursor_manager.current = cursor_type if update_current_cursor | ||
cursor_type = :pencil if @graffiti_mode | ||
@cursor_manager.update(@drawable, cursor_type) | ||
@cursor_manager.update(@surface, cursor_type) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Copyright (C) 2004-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
require "rabbit/renderer/display/drawing-area-primitive" | ||
require "rabbit/renderer/display/menu" | ||
require "rabbit/renderer/display/progress" | ||
|
@@ -289,7 +305,7 @@ def set_motion_notify_event | |
end | ||
|
||
def paint(color_name) | ||
context = @drawable.create_cairo_context | ||
context = @surface.create_cairo_context | ||
context.set_source_rgba(*Color.parse(color_name).to_a) | ||
context.paint | ||
end | ||
|
@@ -313,9 +329,9 @@ def draw_current_slide_pixbuf(pixbuf) | |
width, height = pixbuf.width, pixbuf.height | ||
x = @adjustment_x * width | ||
y = @adjustment_y * height | ||
@drawable.draw_pixbuf(@foreground, pixbuf, | ||
x, y, 0, 0, width, height, | ||
Gdk::RGB::DITHER_NORMAL, 0, 0) | ||
@surface.draw_pixbuf(@foreground, pixbuf, | ||
x, y, 0, 0, width, height, | ||
Gdk::RGB::DITHER_NORMAL, 0, 0) | ||
if @adjustment_x != 0 or @adjustment_y != 0 | ||
draw_next_slide | ||
end | ||
|
@@ -353,9 +369,9 @@ def draw_next_slide_pixbuf(pixbuf) | |
src_height = -adjustment_height | ||
end | ||
|
||
@drawable.draw_pixbuf(@foreground, pixbuf, src_x, src_y, | ||
dest_x, dest_y, src_width, src_height, | ||
Gdk::RGB::DITHER_NORMAL, 0, 0) | ||
@surface.draw_pixbuf(@foreground, pixbuf, src_x, src_y, | ||
dest_x, dest_y, src_width, src_height, | ||
Gdk::RGB::DITHER_NORMAL, 0, 0) | ||
end | ||
|
||
def configured_after(widget, event) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Copyright (C) 2006-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
require "rabbit/gesture/handler" | ||
|
||
module Rabbit | ||
|
@@ -49,7 +65,7 @@ def init_gesture | |
first_move = !@gesture.moved? | ||
handled = @gesture.button_motion(event.x, event.y, width, height) | ||
queue_draw if handled or first_move | ||
init_renderer(@drawable) | ||
init_renderer(@surface) | ||
@gesture.draw_last_locus(self) | ||
finish_renderer | ||
true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
# Copyright (C) 2005-2024 Sutou Kouhei <[email protected]> | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, write to the Free Software Foundation, Inc., | ||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
require "cairo" | ||
require "stringio" | ||
|
||
|
@@ -25,8 +41,8 @@ def background_image=(pixbuf) | |
pixbuf | ||
end | ||
|
||
def init_renderer(drawable) | ||
init_context(drawable.create_cairo_context) | ||
def init_renderer(surface) | ||
init_context(surface.create_cairo_context) | ||
end | ||
|
||
def finish_renderer | ||
|