From d650b650067fd230344bcd7f810b8ab45bd04c7b Mon Sep 17 00:00:00 2001 From: sp1rit Date: Sun, 15 Nov 2020 17:10:44 +0100 Subject: [PATCH 1/4] inital support for user-selectable cursors --- mainwindow.cpp | 16 ++++++++++++---- mainwindow.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 604a926..0a40bb5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -85,10 +85,10 @@ CMainWindow::CMainWindow() : nav_model(), sview() nav.get_style_context()->add_provider(sview_css,GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); /* load cursor types for document */ - pen_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),"default"); - text_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),"text"); - eraser_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),"cell"); - selection_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),"cross"); + pen_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),GetToolCursor("pen", "default")); + text_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),GetToolCursor("text", "text")); + eraser_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),GetToolCursor("eraser", "cell")); + selection_cursor = Gdk::Cursor::create(Gdk::Display::get_default(),GetToolCursor("select", "cross")); /* install document view */ sbuffer = sview.get_source_buffer(); @@ -581,3 +581,11 @@ bool CMainWindow::on_motion_notify(GdkEventMotion *e) return false; } + +std::string CMainWindow::GetToolCursor(std::string tool, std::string fallback) { + if(!config["tool"][tool].isString() || config["tool"][tool].asString()=="") { + config["tool"][tool]=fallback; + return fallback; + } + return config["tool"][tool].asString(); +} \ No newline at end of file diff --git a/mainwindow.h b/mainwindow.h index d34d610..55edb00 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -91,6 +91,8 @@ class CMainWindow : public Gtk::Window Gtk::SeparatorMenuItem sep; Gtk::CheckMenuItem hide_sidebar; } am; + + std::string GetToolCursor(std::string tool, std::string fallback); }; #endif // MAINWINDOW_H \ No newline at end of file From 48120af5d553bcb8f0a0b5325d9485033d13a88d Mon Sep 17 00:00:00 2001 From: sp1rit Date: Sun, 15 Nov 2020 17:18:31 +0100 Subject: [PATCH 2/4] Improved the Preferences UI --- data/preferences.glade | 137 ++++++++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 30 deletions(-) diff --git a/data/preferences.glade b/data/preferences.glade index 47fdca2..348e143 100644 --- a/data/preferences.glade +++ b/data/preferences.glade @@ -1,16 +1,18 @@ - + + + True + False + gtk-delete + False False True True dialog - - - False @@ -120,10 +122,40 @@ True False + vertical - + True False + + + True + False + Pen Cursor + + + False + True + 0 + + + + + True + False + 16 + 0 + + Default + Cross + + + + False + True + 2 + + False @@ -131,6 +163,33 @@ 0 + + + True + False + start + 10 + <small><span foreground="grey">The cursor that the pen tool should have</span></small> + True + True + + + False + True + 1 + + + + + False + True + 2 + + + + + True + False Use headerbar @@ -139,6 +198,17 @@ False True + + False + True + 0 + + + + + True + False + False True @@ -149,7 +219,7 @@ False True - 2 + 3 @@ -165,7 +235,7 @@ False True - 3 + 4 @@ -173,9 +243,12 @@ True False - + + Enable syntax highlighting True - False + True + False + True False @@ -184,12 +257,9 @@ - - Enable syntax highlighting + True - True - False - True + False False @@ -201,7 +271,7 @@ False True - 4 + 5 @@ -217,21 +287,6 @@ This increases startup time and may result in markdown rendering failing if < True 70 - - False - True - 5 - - - - - True - False - end - end - True - Preference changes only take effect after restarting NoteKit. - False True @@ -251,6 +306,28 @@ This increases startup time and may result in markdown rendering failing if < button1 button2 + + + True + False + Preferences + Preference changes only take effect after restarting NoteKit. + True + + + True + True + True + reset_image + True + + + + + + button1 + button2 + From 87b85415f2f56e16e1f7b9e1499dd4e6be7491c5 Mon Sep 17 00:00:00 2001 From: sp1rit Date: Sun, 15 Nov 2020 21:48:21 +0100 Subject: [PATCH 3/4] changed tool key too tool_cursors --- data/default_config.json | 6 ++++++ mainwindow.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/data/default_config.json b/data/default_config.json index eb4b47d..0e38072 100644 --- a/data/default_config.json +++ b/data/default_config.json @@ -2,6 +2,12 @@ "active_document" : "", "use_headerbar" : true, "use_highlight_proxy" : false, + "tool_cursors": { + "pen": "default", + "text": "text", + "eraser": "cell", + "select": "cross" + }, "colors" : [ { diff --git a/mainwindow.cpp b/mainwindow.cpp index 0a40bb5..16e68bb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -583,9 +583,9 @@ bool CMainWindow::on_motion_notify(GdkEventMotion *e) } std::string CMainWindow::GetToolCursor(std::string tool, std::string fallback) { - if(!config["tool"][tool].isString() || config["tool"][tool].asString()=="") { - config["tool"][tool]=fallback; + if(!config["tool_cursors"][tool].isString() || config["tool_cursors"][tool].asString()=="") { + config["tool_cursors"][tool]=fallback; return fallback; } - return config["tool"][tool].asString(); -} \ No newline at end of file + return config["tool_cursors"][tool].asString(); +} From 6d02d6214a066c8fa32cd5957de4c7c90218d98c Mon Sep 17 00:00:00 2001 From: sp1rit Date: Sun, 15 Nov 2020 21:53:15 +0100 Subject: [PATCH 4/4] minor preferences improvement --- data/preferences.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/preferences.glade b/data/preferences.glade index 348e143..08ad01a 100644 --- a/data/preferences.glade +++ b/data/preferences.glade @@ -311,7 +311,7 @@ This increases startup time and may result in markdown rendering failing if < True False Preferences - Preference changes only take effect after restarting NoteKit. + Changes only take effect after restarting NoteKit. True