Compare commits

...

4 Commits

Author SHA1 Message Date
b52d247977 Better behaviour of the resize cursor. 2026-01-05 14:32:28 +01:00
1a33db1bf5 readint integer validation made better 2025-11-28 11:24:02 +01:00
4c6f260bb9 window title 2025-11-27 22:50:12 +01:00
b91d093b1f small fixes 2025-11-27 09:53:46 +01:00
5 changed files with 45 additions and 9 deletions

View File

@@ -5,12 +5,14 @@ all: release
install: release
mkdir -p /opt/yellownotes
cp build/release/yellownotes *.svg *.png /opt/yellownotes
cp build/release/yellownotes /opt/yellownotes
mkdir -p /opt/yellownotes/images
cp *.svg *.png /opt/yellownotes/images
release: build/release/yellownotes
build/release/yellownotes: exe_path.cpp gtk-imports.c gtkloader.cpp main.cpp tr.cpp yellownotes.cpp utils/whereami.c \
exe_path.h gtk-imports.h gtkloader.h tr.h yellownotes.h utils/whereami.h
build/release/yellownotes: info_over_me.cpp gtk-imports.c gtkloader.cpp main.cpp tr.cpp yellownotes.cpp utils/whereami.c \
info_over_me.h gtk-imports.h gtkloader.h tr.h yellownotes.h utils/whereami.h
cmake -S . -B build/release
cmake --build build/release --target all

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

@@ -37,7 +37,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
#else
int main(int argc, char **argv)
{
return runMain(argv, argv);
return runMain(argc, argv);
}
#endif

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)) {
@@ -1372,6 +1385,7 @@ void YellowNote::deleteMe()
void YellowNote::updateTitle()
{
gtk_label_set_label(_title_label, _title.c_str());
gtk_window_set_title(_note_widget, _title.c_str());
}
void YellowNote::updateTitleOnly()
@@ -1744,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)) {
@@ -1751,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;
}
@@ -1831,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);
@@ -1856,11 +1884,16 @@ void YellowNote::load()
auto readInt = [](FILE *f, int default_value) {
char buffer[100];
fgets(buffer, 100, f);
int v = atoi(buffer);
if (default_value >= 0 && v == 0) {
std::string s = buffer;
trim(s);
std::string::iterator sit = s.begin();
while(sit != s.end() && (*sit >= '0' && *sit <= '9')) { sit++; }
if (sit != s.end()) {
return default_value;
} else {
int v = atoi(buffer);
return v;
}
return v;
};
_in_transaction = true;

View File

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