Attempting new drag resize handles
This commit is contained in:
parent
7dc88f9032
commit
50a537f572
|
@ -11,11 +11,11 @@ from gi.repository import Gdk
|
||||||
|
|
||||||
|
|
||||||
class BodyGrid(Gtk.Grid):
|
class BodyGrid(Gtk.Grid):
|
||||||
def __init__(self):
|
def __init__(self, gdk_window):
|
||||||
super(BodyGrid, self).__init__()
|
super(BodyGrid, self).__init__()
|
||||||
|
|
||||||
self._drag_start_x = 0
|
self._gdk_window = gdk_window
|
||||||
self._drag_start_y = 0
|
self.is_dragging = False
|
||||||
|
|
||||||
self._setup_styling()
|
self._setup_styling()
|
||||||
self._setup_signals()
|
self._setup_signals()
|
||||||
|
@ -80,7 +80,6 @@ class BodyGrid(Gtk.Grid):
|
||||||
box3.set_vexpand(True)
|
box3.set_vexpand(True)
|
||||||
box3.set_hexpand(True)
|
box3.set_hexpand(True)
|
||||||
|
|
||||||
|
|
||||||
top_left.connect("button-press-event", self._press_event)
|
top_left.connect("button-press-event", self._press_event)
|
||||||
top_right.connect("button-press-event", self._press_event)
|
top_right.connect("button-press-event", self._press_event)
|
||||||
bottom_left.connect("button-press-event", self._press_event)
|
bottom_left.connect("button-press-event", self._press_event)
|
||||||
|
@ -96,60 +95,28 @@ class BodyGrid(Gtk.Grid):
|
||||||
bottom_left.connect("button-release-event", self._release_event)
|
bottom_left.connect("button-release-event", self._release_event)
|
||||||
bottom_right.connect("button-release-event", self._release_event)
|
bottom_right.connect("button-release-event", self._release_event)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _press_event(self, widget = None, eve = None):
|
def _press_event(self, widget = None, eve = None):
|
||||||
window = self.get_parent()
|
window = self.get_parent()
|
||||||
cursor = Gdk.Cursor(Gdk.CursorType.CROSSHAIR)
|
cursor = Gdk.Cursor(Gdk.CursorType.CROSSHAIR)
|
||||||
|
|
||||||
window.get_window().set_cursor(cursor)
|
window.get_window().set_cursor(cursor)
|
||||||
|
|
||||||
self.is_dragging = True
|
self.is_dragging = True
|
||||||
self._drag_start_x = eve.x
|
|
||||||
self._drag_start_y = eve.y
|
|
||||||
|
|
||||||
def _resize_motion_event_tl(self, widget = None, eve = None):
|
def _resize_motion_event_tl(self, widget = None, eve = None):
|
||||||
# if self.is_dragging:
|
if self.is_dragging:
|
||||||
# offset_x = eve.x - self._drag_start_x
|
self._gdk_window.begin_resize_drag(Gdk.WindowEdge.NORTH_WEST, 1, eve.x_root, eve.y_root, eve.time)
|
||||||
# self._current_w += offset_x
|
|
||||||
# if self._current_w < 0:
|
|
||||||
# self._current_w = -1
|
|
||||||
#
|
|
||||||
# self.set_size_request(self._current_w, self._current_h)
|
|
||||||
# self.get_parent().save_needed = True
|
|
||||||
...
|
|
||||||
|
|
||||||
def _resize_motion_event_tr(self, widget = None, eve = None):
|
def _resize_motion_event_tr(self, widget = None, eve = None):
|
||||||
# if self.is_dragging:
|
if self.is_dragging:
|
||||||
# offset_x = eve.x - self._drag_start_x
|
self._gdk_window.begin_resize_drag(Gdk.WindowEdge.NORTH_EAST, 1, eve.x_root, eve.y_root, eve.time)
|
||||||
# self._current_w += offset_x
|
|
||||||
# if self._current_w < 0:
|
|
||||||
# self._current_w = -1
|
|
||||||
#
|
|
||||||
# self.set_size_request(self._current_w, self._current_h)
|
|
||||||
# self.get_parent().save_needed = True
|
|
||||||
...
|
|
||||||
|
|
||||||
def _resize_motion_event_bl(self, widget = None, eve = None):
|
def _resize_motion_event_bl(self, widget = None, eve = None):
|
||||||
# if self.is_dragging:
|
if self.is_dragging:
|
||||||
# offset_x = eve.x - self._drag_start_x
|
self._gdk_window.begin_resize_drag(Gdk.WindowEdge.SOUTH_WEST, 1, eve.x_root, eve.y_root, eve.time)
|
||||||
# self._current_w += offset_x
|
|
||||||
# if self._current_w < 0:
|
|
||||||
# self._current_w = -1
|
|
||||||
#
|
|
||||||
# self.set_size_request(self._current_w, self._current_h)
|
|
||||||
# self.get_parent().save_needed = True
|
|
||||||
...
|
|
||||||
|
|
||||||
def _resize_motion_event_br(self, widget = None, eve = None):
|
def _resize_motion_event_br(self, widget = None, eve = None):
|
||||||
# if self.is_dragging:
|
if self.is_dragging:
|
||||||
# offset_x = eve.x - self._drag_start_x
|
self._gdk_window.begin_resize_drag(Gdk.WindowEdge.SOUTH_EAST, 1, eve.x_root, eve.y_root, eve.time)
|
||||||
# self._current_w += offset_x
|
|
||||||
# if self._current_w < 0:
|
|
||||||
# self._current_w = -1
|
|
||||||
#
|
|
||||||
# self.set_size_request(self._current_w, self._current_h)
|
|
||||||
# self.get_parent().save_needed = True
|
|
||||||
...
|
|
||||||
|
|
||||||
def _release_event(self, widget = None, eve = None):
|
def _release_event(self, widget = None, eve = None):
|
||||||
window = self.get_parent()
|
window = self.get_parent()
|
||||||
|
@ -157,5 +124,3 @@ class BodyGrid(Gtk.Grid):
|
||||||
window.get_window().set_cursor(watch_cursor)
|
window.get_window().set_cursor(watch_cursor)
|
||||||
|
|
||||||
self.is_dragging = False
|
self.is_dragging = False
|
||||||
self._drag_start_x = 0
|
|
||||||
self._drag_start_y = 0
|
|
||||||
|
|
|
@ -26,7 +26,11 @@ class RegionWindow(Gtk.Window):
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
self.set_default_size(600, 480)
|
self.set_default_size(600, 480)
|
||||||
|
self.set_deletable(False)
|
||||||
self.set_decorated(False)
|
self.set_decorated(False)
|
||||||
|
self.set_resizable(True)
|
||||||
|
self.set_skip_pager_hint(True)
|
||||||
|
self.set_skip_taskbar_hint(True)
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
...
|
...
|
||||||
|
@ -35,7 +39,8 @@ class RegionWindow(Gtk.Window):
|
||||||
event_system.subscribe("show_region_window", self._show_region_window)
|
event_system.subscribe("show_region_window", self._show_region_window)
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
self.add(BodyGrid())
|
gdk_window = self.get_screen().get_root_window()
|
||||||
|
self.add( BodyGrid(gdk_window) )
|
||||||
|
|
||||||
def _set_window_data(self) -> None:
|
def _set_window_data(self) -> None:
|
||||||
screen = self.get_screen()
|
screen = self.get_screen()
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
.regionWindow {
|
.region-window {
|
||||||
background-color: rgba(0, 0, 0, 0.0);
|
background-color: rgba(0, 0, 0, 0.0);
|
||||||
|
/* border: 2px solid rgba(136, 204, 39, 1); */
|
||||||
|
/* Dark Bergundy */
|
||||||
|
border: 2px solid rgba(116, 0, 0, 0.64);
|
||||||
|
}
|
||||||
|
|
||||||
|
.expand-button {
|
||||||
|
background-color: rgba(0, 0, 0, 0.0);
|
||||||
|
border: 2px solid rgba(56, 56, 56, 0.46);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue