Better behaviour of the resize cursor.

This commit is contained in:
2026-01-05 14:32:28 +01:00
parent 1a33db1bf5
commit b52d247977
3 changed files with 30 additions and 2 deletions

View File

@@ -674,6 +674,7 @@ DECL(const gchar*, gtk_window_get_title, (GtkWindow* window))
DECL(void, gtk_widget_destroy, (GtkWidget* widget))
DECL(void, gtk_container_add, (GtkContainer* container, GtkWidget* widget))
DECL(void, gtk_container_remove, (GtkContainer* container, GtkWidget* widget))
DECL(void, gtk_container_set_border_width, (GtkContainer *container, guint width));
DECL(gboolean, gtk_widget_is_visible, (GtkWidget* widget))
DECL(GtkWidget*, gtk_label_new, (const char* str))

View File

@@ -48,6 +48,14 @@ public:
std::string os_host;
};
typedef enum {
NONE,
BOTTOM_RIGHT,
BOTTOM,
RIGHT
} YellowNoteResize_t;
class YellowNote
{
@@ -110,6 +118,8 @@ private:
bool _resize_right;
bool _resize_bottom;
bool _resize_edge;
YellowNoteResize_t _resize_type;
int _x_orig;
int _y_orig;
@@ -1142,6 +1152,7 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
_resize_bottom = false;
_resize_edge = false;
_resize_right = false;
_resize_type = NONE;
_color = ColorType_t::YELLOW;
_color_changed = false;
@@ -1251,6 +1262,8 @@ YellowNote::YellowNote(YellowNotes *notes, const std::string &filename)
gtk_container_add(_evt_box, _frame);
gtk_container_add(_note_widget, _evt_box);
gtk_container_set_border_width(_evt_box, 0);
gtk_widget_show_all(_note_widget);
/*while (!gtk_widget_is_visible(_note_widget)) {
@@ -1745,6 +1758,7 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
int threshold = 8;
/*
if (AROUND(y, frame_bottom) && AROUND(x, frame_right)) {
_resize_edge = true;
} else if (AROUND(y, frame_bottom)) {
@@ -1752,6 +1766,14 @@ bool YellowNote::move_begin(GtkWidget *sender, GdkEventButton *evt)
} else if (AROUND(x, frame_right)) {
_resize_right = true;
}
*/
if (_resize_type == BOTTOM_RIGHT) {
_resize_edge = true;
} else if (_resize_type == BOTTOM) {
_resize_bottom = true;
} else if (_resize_type == RIGHT) {
_resize_right = true;
}
return false;
}
@@ -1832,18 +1854,23 @@ bool YellowNote::moving(GtkWidget *sender, GdkEventMotion *evt)
GdkWindow *window = gtk_widget_get_window(_frame);
GdkCursor *c;
int threshold = 8;
int threshold = 16;
if (y >= header_top && y <= header_bottom) {
c = gdk_cursor_new(GDK_LEFT_PTR);
_resize_type = NONE;
} else if (AROUND(x, frame_right) && AROUND(y, frame_bottom)) {
c = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
_resize_type = BOTTOM_RIGHT;
} else if (AROUND(x, frame_right)) {
c = gdk_cursor_new(GDK_RIGHT_SIDE);
_resize_type = RIGHT;
} else if (AROUND(y, frame_bottom)) {
c = gdk_cursor_new(GDK_BOTTOM_SIDE);
_resize_type = BOTTOM;
} else {
c = nullptr;
_resize_type = NONE;
}
gdk_window_set_cursor(window, c);

View File

@@ -14,7 +14,7 @@ class SettingContainer;
#define YELLOWNOTE_MAJOR "1"
#define YELLOWNOTE_MINOR "0"
#define YELLOWNOTE_PATCH "2"
#define YELLOWNOTE_PATCH "3"
#define YELLOWNOTE_VERSION YELLOWNOTE_MAJOR "." YELLOWNOTE_MINOR "." YELLOWNOTE_PATCH
#define YELLOWNOTE_FILE_VERSION 3