Skip to content

Commit 826d39f

Browse files
committed
Zoom which now functions
1 parent 00eb38f commit 826d39f

File tree

6 files changed

+37
-36
lines changed

6 files changed

+37
-36
lines changed

src/Objects/Zoomkind.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
if (delta > 0)
2323
{
24-
return ZOOM_IN;
24+
return ZOOM_OUT;
2525

2626
} else {
27-
return ZOOM_OUT;
27+
return ZOOM_IN;
2828
}
2929
}
3030
}

src/Services/ZoomController.vala

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ public class Jorts.ZoomController : Object {
1616
private Jorts.StickyNoteWindow window;
1717

1818
// We keep those values static as we dont need to track instance specific
19-
public static double current_scroll_delta = 0;
2019
public static bool is_control_key_pressed = false;
21-
public static uint8 sensitivity = 1;
2220

2321
// Avoid setting this unless it is to restore a specific value, do_set_zoom does not check input
2422
private uint16 _old_zoom;
@@ -31,18 +29,6 @@ public class Jorts.ZoomController : Object {
3129
this.window = window;
3230
}
3331

34-
construct {
35-
var keypress_controller = new Gtk.EventControllerKey ();
36-
keypress_controller.key_pressed.connect (on_key_press_event);
37-
keypress_controller.key_released.connect (on_key_release_event);
38-
((Gtk.Widget)window).add_controller ((Gtk.EventController)keypress_controller);
39-
40-
var scroll_controller = new Gtk.EventControllerScroll (VERTICAL);
41-
scroll_controller.scroll_end.connect (() => current_scroll_delta = 0);
42-
scroll_controller.scroll.connect (on_scroll);
43-
((Gtk.Widget)window).add_controller ((Gtk.EventController)scroll_controller);
44-
}
45-
4632
/**
4733
* Handler. Wraps a zoom enum into the correct function-
4834
*/
@@ -109,33 +95,37 @@ public class Jorts.ZoomController : Object {
10995
window.changed ();
11096
}
11197

112-
private bool on_key_press_event (uint keyval, uint keycode, Gdk.ModifierType state) {
98+
public bool on_key_press_event (uint keyval, uint keycode, Gdk.ModifierType state) {
11399
if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
100+
print ("Press!");
114101
is_control_key_pressed = true;
102+
103+
// disable scrolling for the stickies else it will prevent what we are trying to do
104+
window.view.scrolled.sensitive = false;
115105
}
116106

117107
return Gdk.EVENT_PROPAGATE;
118108
}
119109

120-
private void on_key_release_event (uint keyval, uint keycode, Gdk.ModifierType state) {
110+
public void on_key_release_event (uint keyval, uint keycode, Gdk.ModifierType state) {
121111
if (keyval == Gdk.Key.Control_L || keyval == Gdk.Key.Control_R) {
112+
debug ("Release!");
122113
is_control_key_pressed = false;
123-
}
124-
}
125114

126-
private bool on_scroll (double dx, double dy) {
127-
if (!is_control_key_pressed) { return false;}
128-
129-
if (current_scroll_delta == 0) {
130-
zoom_changed (Zoomkind.from_delta (dy));
115+
// Allow scrolling again
116+
window.view.scrolled.sensitive = true;
131117
}
118+
}
132119

133-
current_scroll_delta += dy;
120+
public bool on_scroll (double dx, double dy) {
121+
debug ("Scroll + Ctrl!");
134122

135-
if (current_scroll_delta.abs () > sensitivity) { // Balance between reactive and ignoring misinput
136-
current_scroll_delta = 0;
123+
if (!is_control_key_pressed) {
124+
return false;
137125
}
138126

139-
return true;
127+
zoom_changed (Zoomkind.from_delta (dy));
128+
debug ("Go! Zoooommmmm");
129+
return false;
140130
}
141131
}

src/Views/NoteView.vala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
public Gtk.EmojiChooser emojichooser_popover;
1616
public Gtk.MenuButton menu_button;
1717

18+
public Gtk.ScrolledWindow scrolled;
19+
1820
public bool monospace {
1921
get { return textview.monospace;}
2022
set { mono_set (value);}
@@ -45,7 +47,7 @@
4547
headerbar.set_title_widget (editablelabel);
4648

4749
textview = new Jorts.TextView ();
48-
var scrolled = new Gtk.ScrolledWindow () {
50+
scrolled = new Gtk.ScrolledWindow () {
4951
child = textview
5052
};
5153

src/Views/PopoverView.vala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ public class Jorts.PopoverView : Gtk.Popover {
7070
// Avoid deathloop where the handler calls itself
7171
color_button_box.theme_changed.disconnect (on_color_changed);
7272

73-
// Accent
74-
var stylesheet = "io.elementary.stylesheet." + new_theme.to_css_class ();
75-
parent_window.gtk_settings.gtk_theme_name = stylesheet;
76-
7773
// Add remove class
7874
if (_old_color.to_string () in parent_window.css_classes) {
7975
parent_window.remove_css_class (_old_color.to_string ());

src/Windows/PreferenceWindow.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ the innerbox has widgets for settings.
1616
the actionbar has a donate me and a set back to defaults just like elementaryOS
1717
1818
*/
19-
public class Jorts.PreferenceWindow : Gtk.ApplicationWindow {
19+
public class Jorts.PreferenceWindow : Gtk.Window {
2020

2121
public PreferenceWindow (Jorts.Application app) {
2222
debug ("[PREFWINDOW] Creating preference window");

src/Windows/StickyNoteWindow.vala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Can be packaged into a noteData file for convenient storage
1414
* Reports to the NoteManager for saving
1515
*/
16-
public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
16+
public class Jorts.StickyNoteWindow : Gtk.Window {
1717

1818
public Jorts.NoteView view;
1919
public PopoverView popover;
@@ -29,6 +29,9 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
2929

3030
public signal void changed ();
3131

32+
private Gtk.EventControllerKey keypress_controller;
33+
private Gtk.EventControllerScroll scroll_controller;
34+
3235
private const string ACTION_PREFIX = "app.";
3336
private const string ACTION_SHOW_EMOJI = "action_show_emoji";
3437
private const string ACTION_SHOW_MENU = "action_show_menu";
@@ -88,6 +91,16 @@ public class Jorts.StickyNoteWindow : Gtk.ApplicationWindow {
8891
zoomcontroller = new Jorts.ZoomController (this);
8992
scribblycontroller = new Jorts.ScribblyController (this);
9093

94+
keypress_controller = new Gtk.EventControllerKey ();
95+
keypress_controller.key_pressed.connect (zoomcontroller.on_key_press_event);
96+
keypress_controller.key_released.connect (zoomcontroller.on_key_release_event);
97+
((Gtk.Widget)this).add_controller (keypress_controller);
98+
99+
scroll_controller = new Gtk.EventControllerScroll (VERTICAL);
100+
scroll_controller.scroll.connect (zoomcontroller.on_scroll);
101+
((Gtk.Widget)this).add_controller (scroll_controller);
102+
103+
91104
/*****************************************/
92105
/* HEADERBAR */
93106
/*****************************************/

0 commit comments

Comments
 (0)