diff --git a/data/com.github.naz013.tasks.appdata.xml.in b/data/com.github.naz013.tasks.appdata.xml.in index b4200f2..9bf12da 100755 --- a/data/com.github.naz013.tasks.appdata.xml.in +++ b/data/com.github.naz013.tasks.appdata.xml.in @@ -29,11 +29,21 @@ - - - Simple reminder application - - + + + Update list design + + + + + Update create panel design + + + + + Simple reminder application + + #E6AB6A diff --git a/data/com.github.naz013.tasks.gschema.xml b/data/com.github.naz013.tasks.gschema.xml index 16acdfa..8f401c6 100755 --- a/data/com.github.naz013.tasks.gschema.xml +++ b/data/com.github.naz013.tasks.gschema.xml @@ -41,5 +41,10 @@ Screen fullscreen Save if was screen fullscreen + + false + Multicolumn View + Save if Multicolumn View enabled + diff --git a/src/TasksWindow.vala b/src/TasksWindow.vala index c613f8f..dc27565 100755 --- a/src/TasksWindow.vala +++ b/src/TasksWindow.vala @@ -425,6 +425,12 @@ namespace Tasks { init_theme(theme); update_theme(); }); + settings_view.multi_changed.connect((is_multi) => { + AppSettings.get_default().is_multi = is_multi; + if (main_view != null) { + main_view.refresh_list(tasks); + } + }); settings_view.show_all(); popover = new Gtk.Popover (null); diff --git a/src/config/AppSettings.vala b/src/config/AppSettings.vala index cfd6ef7..45b108e 100755 --- a/src/config/AppSettings.vala +++ b/src/config/AppSettings.vala @@ -10,6 +10,7 @@ namespace Tasks { public uint last_id { get; set; } public bool is_maximized { get; set; } public bool is_fullscreen { get; set; } + public bool is_multi { get; set; } public static unowned AppSettings get_default () { if (instance == null) { diff --git a/src/ui/CssData.vala b/src/ui/CssData.vala index ed8007d..78a086b 100644 --- a/src/ui/CssData.vala +++ b/src/ui/CssData.vala @@ -581,11 +581,6 @@ namespace Tasks { background: transparent; } - .material_fab horizontal { - background: transparent; - background-blend-mode: multiply; - } - .material_fab { border-radius: 25px; color: #fff; @@ -593,6 +588,7 @@ namespace Tasks { padding-top: 8px; padding-bottom: 8px; background-color: @accentColor; + background-blend-mode: screen; box-shadow: 0 1px 2px @shadowColor, 0 1px 2px @shadowOutColor; transition: all 0.1s ease-in-out; } @@ -604,6 +600,7 @@ namespace Tasks { padding-top: 8px; padding-bottom: 8px; background-color: @accentColor; + background-blend-mode: screen; box-shadow: 0 1px 3px @shadowColor, 0 1px 3px @shadowOutColor; } @@ -614,6 +611,7 @@ namespace Tasks { padding-top: 8px; padding-bottom: 8px; background-color: @accentColor; + background-blend-mode: screen; box-shadow: 0 1px 4px @shadowColor, 0 1px 4px @shadowOutColor; } @@ -622,6 +620,7 @@ namespace Tasks { color: @textColorDisabled; border: 0px; background-color: @buttonDisabledColor; + background-blend-mode: screen; box-shadow: none; } @@ -836,21 +835,18 @@ namespace Tasks { } .mainwindow { - background: linear-gradient(@bgTopColor, @bgBottomColor); - background-blend-mode: multiply; + background: @bgColor; box-shadow: @shadowColor; } .popover { - background: linear-gradient(@bgColor, @bgColor); + background: @bgColor; box-shadow: @shadowColor; - background-blend-mode: multiply; } .window textview.view text, .window headerbar { - background: @bgTopColor; - background-blend-mode: multiply; + background: @bgColor; box-shadow: none; } """); diff --git a/src/ui/ListView.vala b/src/ui/ListView.vala index e1151c6..cd25356 100644 --- a/src/ui/ListView.vala +++ b/src/ui/ListView.vala @@ -11,6 +11,9 @@ namespace Tasks { public signal void on_copy(Event task); private Gtk.ListBox list_box; + private Gtk.Popover? popover; + private int state = 1; + private Gee.ArrayList m_tasks; public ListView(Gee.ArrayList tasks) { Gtk.ScrolledWindow scrolled = new Gtk.ScrolledWindow (null, null); @@ -25,18 +28,97 @@ namespace Tasks { refresh_list(tasks); scrolled.show_all(); + size_allocate.connect((allocation) => { + if (is_multi()) { + update_state(allocation.width); + } + }); add(scrolled); } + private bool is_multi() { + return AppSettings.get_default().is_multi; + } + + public void refresh_view() { + if (m_tasks != null) { + refresh_list(m_tasks); + } + } + + public void update_state(int width) { + int _state = new_state(width); + if (_state != state) { + state = _state; + refresh_view(); + } + } + public void refresh_list(Gee.ArrayList tasks) { - list_box.forall ((element) => list_box.remove (element)); + m_tasks = tasks; + list_box.foreach ((element) => list_box.remove (element)); tasks.sort(comparator); - Event? prev_task = null; - for (int i = 0; i < tasks.size; i++) { - Event task = tasks.get(i); - list_box.add(get_row(task, prev_task, i == tasks.size - 1)); - prev_task = new Event.full_copy(task); + if (!is_multi() || state == 1) { + Event? prev_task = null; + for (int i = 0; i < tasks.size; i++) { + Event task = tasks.get(i); + list_box.add(get_row(task, prev_task, i == tasks.size - 1, true)); + prev_task = new Event.full_copy(task); + } + } else { + Event? prev_task = null; + int count = 0; + Gtk.Grid grid = new_grid(); + for (int i = 0; i < tasks.size; i++) { + Event task = tasks.get(i); + var row = get_row(task, prev_task, i == tasks.size - 1, false); + count++; + if (is_same(task, prev_task)) { + grid.add(row); + Logger.log(@"refresh_list: same"); + if (count == state) { + Logger.log(@"refresh_list: 1"); + list_box.add(pack_grid(add_empty(grid, count))); + grid = new_grid(); + count = 0; + } + } else { + Logger.log(@"refresh_list: not same"); + if (i != 0) { + Logger.log(@"refresh_list: 2"); + list_box.add(pack_grid(add_empty(grid, count - 1))); + count = 0; + } + list_box.add(pack_grid(get_header(task))); + grid = new_grid(); + grid.add(row); + if (i == tasks.size - 1) { + Logger.log(@"refresh_list: 3"); + list_box.add(pack_grid(add_empty(grid, 1))); + count = 0; + } + } + + prev_task = new Event.full_copy(task); + } + } + } + + private Gtk.Grid add_empty(Gtk.Grid grid, int count) { + if (count == state) return grid; + Logger.log(@"add_empty: $count, $state"); + for (int i = count; i < state; i++) { + grid.add(new_grid()); } + return grid; + } + + private Gtk.Grid new_grid() { + Gtk.Grid grid = new Gtk.Grid(); + grid.hexpand = true; + grid.set_column_homogeneous(true); + grid.orientation = Gtk.Orientation.HORIZONTAL; + return grid; } public int comparator (Event a, Event b) { @@ -65,6 +147,20 @@ namespace Tasks { } } + private int new_state(int width) { + if (width < 650) return 1; + else if (width < 1300) return 2; + else if (width < 1950) return 3; + else if (width < 2600) return 4; + else if (width < 3250) return 5; + else return 6; + } + + private bool is_same(Event task, Event? prev) { + if (prev == null) return false; + else return task.is_active == prev.is_active; + } + private Gtk.Widget? get_header_view(Event task, Event? prev) { if (prev != null) { if (task.is_active == prev.is_active) { @@ -105,8 +201,6 @@ namespace Tasks { return view; } - private Gtk.Popover? popover; - private void hide_popover() { if (popover != null) { popover.popdown(); @@ -165,7 +259,17 @@ namespace Tasks { return button; } - private Gtk.ListBoxRow get_row(Event task, Event? prev, bool is_last) { + private Gtk.ListBoxRow pack_grid(Gtk.Widget grid) { + var row = new Gtk.ListBoxRow(); + row.hexpand = true; + row.vexpand = false; + row.set_selectable(false); + row.add(grid); + row.show_all(); + return row; + } + + private Gtk.ListBoxRow get_row(Event task, Event? prev, bool is_last, bool add_header) { var row = new Gtk.ListBoxRow(); row.hexpand = true; row.vexpand = false; @@ -176,7 +280,7 @@ namespace Tasks { grid.hexpand = true; var header_view = get_header_view(task, prev); - if (header_view != null) { + if (add_header && header_view != null) { grid.add(header_view); } diff --git a/src/ui/SettingsView.vala b/src/ui/SettingsView.vala index 0eca0d2..b34ae3e 100644 --- a/src/ui/SettingsView.vala +++ b/src/ui/SettingsView.vala @@ -3,6 +3,7 @@ namespace Tasks { public class SettingsView : Gtk.EventBox { public signal void theme_selected(int theme); + public signal void multi_changed(bool is_multi); public SettingsView() { var color_button_light = new Gtk.RadioButton (null); @@ -107,7 +108,48 @@ namespace Tasks { theme_button_click(color_button_green_gradient, 5); theme_button_click(color_button_sunset, 6); - add(menu_grid); + var multi_switch = new Gtk.Switch(); + multi_switch.vexpand = false; + multi_switch.active = AppSettings.get_default().is_multi; + multi_switch.notify["active"].connect (() => { + multi_changed(multi_switch.active); + }); + multi_switch.get_style_context().add_class(CssData.MATERIAL_SWITCH); + + var multi_label = new Gtk.Button.with_label (_("Multicolumn View")); + multi_label.clicked.connect (() => { + multi_switch.active = !multi_switch.active; + }); + multi_label.get_style_context().add_class(CssData.MATERIAL_BUTTON_FLAT); + + var box = new Gtk.Fixed(); + box.hexpand = true; + box.vexpand = false; + + var box1 = new Gtk.Fixed(); + box1.hexpand = true; + box1.vexpand = false; + + var multi_grid = new Gtk.Grid (); + multi_grid.column_spacing = 8; + multi_grid.hexpand = true; + multi_grid.orientation = Gtk.Orientation.HORIZONTAL; + multi_grid.add(box); + multi_grid.add(multi_label); + multi_grid.add(multi_switch); + multi_grid.add(box1); + + var grid = new Gtk.Grid (); + grid.margin_bottom = 3; + grid.column_spacing = 12; + grid.margin = 12; + grid.orientation = Gtk.Orientation.VERTICAL; + + grid.add(multi_grid); + grid.add(menu_grid); + grid.show_all(); + + add(grid); } private void theme_button_click(Gtk.RadioButton button, int theme) {
Simple reminder application
Update list design
Update create panel design