Commit 4524b06d authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Address inital design review

parent f49627c6
...@@ -7,5 +7,6 @@ ...@@ -7,5 +7,6 @@
<file compressed="true" alias="search.svg">resources/assets/search.svg</file> <file compressed="true" alias="search.svg">resources/assets/search.svg</file>
<file compressed="true" alias="software.svg">resources/assets/software.svg</file> <file compressed="true" alias="software.svg">resources/assets/software.svg</file>
<file compressed="true" alias="status-menu.svg">resources/assets/status-menu.svg</file> <file compressed="true" alias="status-menu.svg">resources/assets/status-menu.svg</file>
<file compressed="true" alias="help.svg">resources/assets/help.svg</file>
</gresource> </gresource>
</gresources> </gresources>
.large-title { .large-title {
font-weight: 300; font-weight: 300;
font-size: 24pt; font-size: 24pt;
letter-spacing: 0.2rem; letter-spacing: 0.2rem;
} }
.page-head { .page-title {
font-weight: 300; font-weight: 600;
font-size: 20pt;
}
.title-1 {
font-weight: 800;
font-size: 20pt; font-size: 20pt;
} }
.title-2 { .page-body {
font-weight: 800;
font-size: 15pt;
}
.title-3 {
font-weight: 700;
font-size: 15pt;
}
.title-4 {
font-weight: 700;
font-size: 13pt;
}
.heading {
font-weight: 700;
font-size: 11pt;
}
.body {
font-weight: 400;
font-size: 11pt;
}
.caption-heading {
font-weight: 700;
font-size: 9pt;
}
.caption {
font-weight: 400; font-weight: 400;
font-size: 9pt; font-size: 12pt;
} }
use gtk::prelude::*; use gtk::prelude::*;
pub struct HeaderBar { pub struct HeaderBar {
pub widget: gtk::HeaderBar, pub widget: gtk::Stack,
container: gtk::Stack, headerbar: gtk::HeaderBar,
next_btn: gtk::Button, next_btn: gtk::Button,
} }
impl HeaderBar { impl HeaderBar {
pub fn new() -> Self { pub fn new() -> Self {
let widget = gtk::HeaderBar::new(); let widget = gtk::Stack::new();
let container = gtk::Stack::new(); let headerbar = gtk::HeaderBar::new();
let next_btn = gtk::Button::new(); let next_btn = gtk::Button::new();
widget.set_show_title_buttons(true); let headerbar = Self { widget, headerbar, next_btn };
let headerbar = Self { widget, container, next_btn };
headerbar.init(); headerbar.init();
headerbar headerbar
} }
pub fn start_tour(&self) { pub fn start_tour(&self) {
self.container.set_visible_child_name("pages"); self.widget.set_visible_child_name("pages");
self.widget.set_show_title_buttons(false); self.headerbar.set_show_title_buttons(false);
} }
pub fn set_page_nr(&self, page_nr: i32, total_pages: i32) { pub fn set_page_nr(&self, page_nr: i32, total_pages: i32) {
...@@ -32,18 +30,26 @@ impl HeaderBar { ...@@ -32,18 +30,26 @@ impl HeaderBar {
} }
} }
pub fn set_page_title(&self, title: &str) {
self.headerbar.set_title(Some(title));
}
pub fn end_tour(&self) { pub fn end_tour(&self) {
self.container.set_visible_child_name("welcome"); self.widget.set_visible_child_name("welcome");
self.widget.set_show_title_buttons(true); self.headerbar.set_show_title_buttons(true);
} }
fn init(&self) { fn init(&self) {
self.container.set_hexpand(true); self.headerbar.set_show_title_buttons(true);
self.container.set_transition_type(gtk::StackTransitionType::SlideLeftRight); self.widget.set_hexpand(true);
self.container.set_transition_duration(300); self.widget.set_transition_type(gtk::StackTransitionType::SlideLeftRight);
self.container.add_named(&gtk::Label::new(None), "welcome"); self.widget.set_transition_duration(300);
self.widget.get_style_context().add_class("titlebar");
let pages_container = gtk::Box::new(gtk::Orientation::Horizontal, 0); let container = gtk::HeaderBar::new();
container.set_show_title_buttons(true);
container.set_title(Some("Welcome Tour"));
self.widget.add_named(&container, "welcome");
let previous_btn = gtk::Button::new(); let previous_btn = gtk::Button::new();
previous_btn.add(&gtk::Label::new(Some("Previous"))); previous_btn.add(&gtk::Label::new(Some("Previous")));
...@@ -59,10 +65,8 @@ impl HeaderBar { ...@@ -59,10 +65,8 @@ impl HeaderBar {
self.next_btn.set_hexpand(true); self.next_btn.set_hexpand(true);
self.next_btn.set_property_width_request(60); self.next_btn.set_property_width_request(60);
pages_container.add(&previous_btn); self.headerbar.pack_start(&previous_btn);
pages_container.add(&self.next_btn); self.headerbar.pack_end(&self.next_btn);
self.container.add_named(&pages_container, "pages"); self.widget.add_named(&self.headerbar, "pages");
self.widget.set_custom_title(Some(&self.container));
} }
} }
use super::page::Pageable;
use gtk::prelude::*; use gtk::prelude::*;
pub struct ImagePageWidget { pub struct ImagePageWidget {
pub widget: gtk::Box, pub widget: gtk::Box,
resource_uri: String,
pub title: String,
pub head: String,
pub body: String,
}
impl Pageable for ImagePageWidget {
fn get_widget(&self) -> gtk::Widget {
self.widget.clone().upcast::<gtk::Widget>()
}
fn get_title(&self) -> String {
self.title.clone()
}
fn get_head(&self) -> String {
self.head.clone()
}
fn get_body(&self) -> String {
self.body.clone()
}
} }
impl ImagePageWidget { impl ImagePageWidget {
pub fn new(resource_uri: &str, text: &str) -> Self { pub fn new(resource_uri: &str, title: &str, head: &str, body: &str) -> Self {
let widget = gtk::Box::new(gtk::Orientation::Vertical, 48); let widget = gtk::Box::new(gtk::Orientation::Vertical, 12);
let image_page = Self { widget }; let image_page = Self {
widget,
resource_uri: resource_uri.to_string(),
title: title.to_string(),
head: head.to_string(),
body: body.to_string(),
};
image_page.init(resource_uri, text); image_page.init();
image_page image_page
} }
fn init(&self, resource_uri: &str, text: &str) { fn init(&self) {
self.widget.set_halign(gtk::Align::Center); self.widget.set_halign(gtk::Align::Center);
self.widget.set_valign(gtk::Align::Center); self.widget.set_valign(gtk::Align::Center);
self.widget.set_property_margin(48); self.widget.set_property_margin(48);
let image = gtk::Picture::new_for_resource(Some(resource_uri)); let image = gtk::Picture::new_for_resource(Some(&self.resource_uri));
image.set_valign(gtk::Align::Start); image.set_valign(gtk::Align::Start);
self.widget.add(&image); self.widget.add(&image);
let label = gtk::Label::new(Some(text)); let head_label = gtk::Label::new(Some(&self.get_head()));
label.set_lines(2); head_label.set_justify(gtk::Justification::Center);
label.set_property_wrap(true); head_label.set_valign(gtk::Align::Center);
label.set_justify(gtk::Justification::Center); head_label.set_margin_top(36);
label.set_valign(gtk::Align::Center); head_label.get_style_context().add_class("page-title");
label.get_style_context().add_class("page-head");
self.widget.add(&label); self.widget.add(&head_label);
let body_label = gtk::Label::new(Some(&self.get_body()));
body_label.set_lines(2);
body_label.set_property_wrap(true);
body_label.set_justify(gtk::Justification::Center);
body_label.set_valign(gtk::Align::Center);
body_label.get_style_context().add_class("page-body");
body_label.set_margin_top(12);
self.widget.add(&body_label);
} }
} }
mod image; mod image;
mod page;
mod welcome; mod welcome;
pub use image::ImagePageWidget; pub use image::ImagePageWidget;
pub use page::Pageable;
pub use welcome::WelcomePageWidget; pub use welcome::WelcomePageWidget;
pub trait Pageable {
fn get_widget(&self) -> gtk::Widget;
fn get_title(&self) -> String;
fn get_head(&self) -> String;
fn get_body(&self) -> String;
}
...@@ -2,11 +2,11 @@ use gtk::prelude::*; ...@@ -2,11 +2,11 @@ use gtk::prelude::*;
use std::cell::RefCell; use std::cell::RefCell;
use std::convert::TryInto; use std::convert::TryInto;
use super::pages::ImagePageWidget; use super::pages::Pageable;
pub struct PaginatorWidget { pub struct PaginatorWidget {
pub widget: gtk::Stack, pub widget: gtk::Stack,
pages: Vec<ImagePageWidget>, pages: Vec<Box<dyn Pageable>>,
current_page: RefCell<i32>, current_page: RefCell<i32>,
} }
...@@ -27,10 +27,15 @@ impl PaginatorWidget { ...@@ -27,10 +27,15 @@ impl PaginatorWidget {
self.pages.len().try_into().unwrap_or(1) self.pages.len().try_into().unwrap_or(1)
} }
pub fn get_current_page(&self) -> i32 { pub fn get_current_page_nr(&self) -> i32 {
self.current_page.borrow().clone() self.current_page.borrow().clone()
} }
pub fn get_current_page(&self) -> Option<&Box<dyn Pageable>> {
let current_page_idx: usize = (self.get_current_page_nr() - 1).try_into().unwrap_or(0);
self.pages.get(current_page_idx)
}
pub fn next(&self) { pub fn next(&self) {
let next_page = self.current_page.borrow().clone() + 1; let next_page = self.current_page.borrow().clone() + 1;
self.go_to(next_page); self.go_to(next_page);
...@@ -41,11 +46,11 @@ impl PaginatorWidget { ...@@ -41,11 +46,11 @@ impl PaginatorWidget {
self.go_to(previous_page); self.go_to(previous_page);
} }
pub fn add_page(&mut self, page: ImagePageWidget) { pub fn add_page(&mut self, page: Box<dyn Pageable>) {
let page_nr = self.pages.len() + 1; let page_nr = self.pages.len() + 1;
let page_name = format!("page-{}", page_nr); let page_name = format!("page-{}", page_nr);
self.widget.add_named(&page.widget, &page_name); self.widget.add_named(&page.get_widget(), &page_name);
self.pages.push(page); self.pages.push(page);
} }
......
...@@ -31,6 +31,9 @@ impl Window { ...@@ -31,6 +31,9 @@ impl Window {
} }
pub fn start_tour(&self) { pub fn start_tour(&self) {
if let Some(page) = self.paginator.get_current_page() {
self.headerbar.set_page_title(&page.get_title());
}
self.container.set_visible_child_name("pages"); self.container.set_visible_child_name("pages");
self.headerbar.start_tour(); self.headerbar.start_tour();
} }
...@@ -42,7 +45,7 @@ impl Window { ...@@ -42,7 +45,7 @@ impl Window {
pub fn next_page(&self) { pub fn next_page(&self) {
let total_pages = self.paginator.get_total_pages(); let total_pages = self.paginator.get_total_pages();
let current_page = self.paginator.get_current_page(); let current_page = self.paginator.get_current_page_nr();
self.headerbar.set_page_nr(current_page + 1, total_pages); self.headerbar.set_page_nr(current_page + 1, total_pages);
if current_page == total_pages { if current_page == total_pages {
...@@ -50,17 +53,24 @@ impl Window { ...@@ -50,17 +53,24 @@ impl Window {
} else { } else {
self.paginator.next(); self.paginator.next();
} }
if let Some(page) = self.paginator.get_current_page() {
self.headerbar.set_page_title(&page.get_title());
}
} }
pub fn previous_page(&self) { pub fn previous_page(&self) {
let total_pages = self.paginator.get_total_pages(); let total_pages = self.paginator.get_total_pages();
let current_page = self.paginator.get_current_page(); let current_page = self.paginator.get_current_page_nr();
self.headerbar.set_page_nr(current_page - 1, total_pages); self.headerbar.set_page_nr(current_page - 1, total_pages);
match current_page { match current_page {
1 => self.end_tour(), 1 => self.end_tour(),
_ => self.paginator.previous(), _ => self.paginator.previous(),
} }
if let Some(page) = self.paginator.get_current_page() {
self.headerbar.set_page_title(&page.get_title());
}
} }
fn init(&mut self) { fn init(&mut self) {
...@@ -78,20 +88,48 @@ impl Window { ...@@ -78,20 +88,48 @@ impl Window {
let welcome_page = WelcomePageWidget::new(); let welcome_page = WelcomePageWidget::new();
self.container.add_named(&welcome_page.widget, "welcome"); self.container.add_named(&welcome_page.widget, "welcome");
self.paginator self.paginator.add_page(Box::new(ImagePageWidget::new(
.add_page(ImagePageWidget::new("/org/gnome/Tour/activities.svg", "Click Activities to view windows, launch apps and search")); "/org/gnome/Tour/activities.svg",
self.paginator "Activities Overview",
.add_page(ImagePageWidget::new("/org/gnome/Tour/search.svg", "In the Activities Overview, just start typing to search")); "Open Activities to start apps",
self.paginator "You can also view open windows, search and use workspaces.",
.add_page(ImagePageWidget::new("/org/gnome/Tour/calendar.svg", "Click the time to view the calendar, notifications and weather")); )));
self.paginator.add_page(ImagePageWidget::new(
self.paginator.add_page(Box::new(ImagePageWidget::new(
"/org/gnome/Tour/search.svg",
"Search",
"In the Activities Overview, just start typing to search",
"Search can be used to launch apps, find settings, do calculations and much more.",
)));
self.paginator.add_page(Box::new(ImagePageWidget::new(
"/org/gnome/Tour/calendar.svg",
"Date & Time",
"Click the time to see your now and next",
"This includes notifications, media controls, calendar events, the weather and world clocks.",
)));
self.paginator.add_page(Box::new(ImagePageWidget::new(
"/org/gnome/Tour/status-menu.svg", "/org/gnome/Tour/status-menu.svg",
"Use the status menu to view system information and access settings", "System Menu",
)); "View system information and settings",
self.paginator "Get an overview of the system status and quickly change settings.",
.add_page(ImagePageWidget::new("/org/gnome/Tour/software.svg", "Use the Software app to find and install apps")); )));
self.container.add_named(&self.paginator.widget, "pages"); self.paginator.add_page(Box::new(ImagePageWidget::new(
"/org/gnome/Tour/software.svg",
"Software",
"Find and install apps",
"The Software app makese it easy to find and install all the apps you need.",
)));
self.paginator.add_page(Box::new(ImagePageWidget::new(
"/org/gnome/Tour/help.svg",
"Learn More",
"That's it! To learn more, see the Help",
"The help app contains information, tips and tricks.",
)));
self.container.add_named(&self.paginator.widget, "pages");
self.widget.add(&self.container); self.widget.add(&self.container);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment