Added h resize event, added cursor change

This commit is contained in:
itdominator 2023-04-06 21:48:14 -05:00
parent e37e2e548f
commit 749a862885
2 changed files with 30 additions and 3 deletions

View File

@ -18,6 +18,10 @@ class DynamicHeaderWidget(Gtk.Box):
self._move_callback = move_callback self._move_callback = move_callback
self._current_x = x self._current_x = x
self._current_y = y self._current_y = y
self._current_w, \
self._current_h = self.get_size_request()
self.ctx = None
self._drag_start_x = 0 self._drag_start_x = 0
self._drag_start_y = 0 self._drag_start_y = 0
self._prior_time = 0 self._prior_time = 0
@ -33,8 +37,8 @@ class DynamicHeaderWidget(Gtk.Box):
def _setup_styling(self): def _setup_styling(self):
self.set_orientation(0) self.set_orientation(0)
ctx = self.get_style_context() self.ctx = self.get_style_context()
ctx.add_class("dynamic-header-widget") self.ctx.add_class("dynamic-header-widget")
def _setup_signals(self): def _setup_signals(self):
... ...
@ -44,10 +48,14 @@ class DynamicHeaderWidget(Gtk.Box):
def _load_widgets(self): def _load_widgets(self):
self.is_dragging = False self.is_dragging = False
drag_eve = Gtk.Button(label = "....") drag_eve = Gtk.Button(label = "...")
hresize_eve = Gtk.Button(label = "< >") hresize_eve = Gtk.Button(label = "< >")
drag_eve.set_hexpand(True) drag_eve.set_hexpand(True)
hresize_eve.connect("button-press-event", self._press_event)
hresize_eve.connect("motion-notify-event", self._resize_motion_event)
hresize_eve.connect("button-release-event", self._release_event)
drag_eve.connect("button-press-event", self._press_event) drag_eve.connect("button-press-event", self._press_event)
drag_eve.connect("motion-notify-event", self._motion_event) drag_eve.connect("motion-notify-event", self._motion_event)
drag_eve.connect("button-release-event", self._release_event) drag_eve.connect("button-release-event", self._release_event)
@ -56,10 +64,24 @@ class DynamicHeaderWidget(Gtk.Box):
self.add(hresize_eve) self.add(hresize_eve)
def _press_event(self, widget = None, eve = None): def _press_event(self, widget = None, eve = None):
window = settings.get_main_window()
cursor = None
cursor = Gdk.Cursor(Gdk.CursorType.CROSSHAIR) if widget.get_label() == "..." else Gdk.Cursor(Gdk.CursorType.SB_H_DOUBLE_ARROW)
window.get_window().set_cursor(cursor)
self.is_dragging = True self.is_dragging = True
self._drag_start_x = eve.x self._drag_start_x = eve.x
self._drag_start_y = eve.y self._drag_start_y = eve.y
def _resize_motion_event(self, widget = None, eve = None):
if self.is_dragging:
offset_x = eve.x - self._drag_start_x
self._current_w += offset_x
if self._current_w < 0:
self._current_w = -1
self.set_size_request(self._current_w, self._current_h)
def _motion_event(self, widget = None, eve = None): def _motion_event(self, widget = None, eve = None):
if self._update_block: if self._update_block:
self._drag_start_x = eve.x self._drag_start_x = eve.x
@ -78,6 +100,10 @@ class DynamicHeaderWidget(Gtk.Box):
self._update_block = False self._update_block = False
def _release_event(self, widget = None, eve = None): def _release_event(self, widget = None, eve = None):
window = settings.get_main_window()
watch_cursor = Gdk.Cursor(Gdk.CursorType.ARROW)
window.get_window().set_cursor(watch_cursor)
self.is_dragging = False self.is_dragging = False
self._drag_start_x = 0 self._drag_start_x = 0
self._drag_start_y = 0 self._drag_start_y = 0

View File

@ -61,6 +61,7 @@ notebook > header > tabs > tab:checked {
.dynamic-header-widget { .dynamic-header-widget {
margin-bottom: 5px; margin-bottom: 5px;
} }