debug: add optional tracing via lttng-ust
* new feature `tracing`, enable with `--features tracing` * draw entry/exit tracepoints Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
This commit is contained in:
parent
7085a2eed8
commit
ca0bc137ad
File diff suppressed because it is too large
Load Diff
|
@ -3,11 +3,16 @@ name = "calendar"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[features]
|
||||
tracing = ["dep:lttng-ust"]
|
||||
|
||||
[dependencies]
|
||||
#iced = "0.4.2"
|
||||
#iced_native = "0.5.1"
|
||||
iced = { path = "../iced" }
|
||||
iced_native = { path = "../iced/native" }
|
||||
chrono = "0.4"
|
||||
chrono = "0.4"
|
||||
lttng-ust = { version = "0.1.0", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
lttng-ust-generate = "0.1.0"
|
|
@ -0,0 +1,25 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use lttng_ust_generate::{Provider, Generator, CTFType, CIntegerType};
|
||||
|
||||
fn main() {
|
||||
// the provider is called calendar
|
||||
let mut provider = Provider::new("calendar");
|
||||
|
||||
// class for drawing events
|
||||
let draw_class = provider.create_class("draw")
|
||||
.add_field("width", CTFType::Integer(CIntegerType::I32))
|
||||
.add_field("height", CTFType::Integer(CIntegerType::I32));
|
||||
|
||||
// drawing events
|
||||
draw_class.instantiate("draw_entry");
|
||||
draw_class.instantiate("draw_exit");
|
||||
|
||||
Generator::default()
|
||||
.generated_lib_name("calendar_tracepoints")
|
||||
.register_provider(provider)
|
||||
.output_file_name(PathBuf::from(env::var("OUT_DIR").unwrap()).join("tracepoints.rs"))
|
||||
.generate()
|
||||
.expect("Unable to generate tracepoint bindings");
|
||||
}
|
|
@ -16,7 +16,19 @@ use iced_native::alignment;
|
|||
use iced_native::widget::Tree;
|
||||
use chrono::{NaiveDate, Datelike, Duration, Local};
|
||||
use super::basics::CellGrid;
|
||||
use crate::model::events::{Event, EventsCollection};
|
||||
use crate::model::events::EventsCollection;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
extern crate lttng_ust;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
use lttng_ust::import_tracepoints;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
import_tracepoints!(
|
||||
concat!(env!("OUT_DIR"), "/tracepoints.rs"),
|
||||
tracepoints
|
||||
);
|
||||
|
||||
const MONTH_NAMES: [&str;12] = [
|
||||
"gen",
|
||||
|
@ -543,8 +555,6 @@ impl<'a> CalendarYearView<'a> {
|
|||
self.params.day_today_bg
|
||||
} else if weekday > 4 {
|
||||
self.params.day_weekend_bg
|
||||
} else if self.events.is_any_in_day(current_day) {
|
||||
self.params.ev_bg
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
};
|
||||
|
@ -571,6 +581,25 @@ impl<'a> CalendarYearView<'a> {
|
|||
horizontal_alignment: alignment::Horizontal::Left,
|
||||
vertical_alignment: alignment::Vertical::Top,
|
||||
});
|
||||
// render events, if enough space
|
||||
|
||||
let day_text_size = renderer.measure(content, font_size as u16, Default::default(), day_bounds.size());
|
||||
let ev_height: f32 = 12.0;
|
||||
if day_bounds.height - day_text_size.1 > ev_height {
|
||||
if self.events.is_any_in_day(current_day) {
|
||||
renderer.fill_quad(renderer::Quad {
|
||||
bounds: Rectangle {
|
||||
y: y + day_text_size.1,
|
||||
height: ev_height,
|
||||
..day_bounds
|
||||
},
|
||||
border_radius: 0.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: self.params.day_other_month_fg,
|
||||
},
|
||||
self.params.ev_bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,6 +649,8 @@ where
|
|||
) {
|
||||
let bounds = layout.bounds();
|
||||
let margin: f32 = 20.0;
|
||||
#[cfg(feature = "tracing")]
|
||||
tracepoints::calendar::draw_entry(bounds.width as i32, bounds.height as i32);
|
||||
|
||||
// week column only visible if there is enough space
|
||||
let month_w = if self.params.show_weeks {
|
||||
|
@ -651,6 +682,8 @@ where
|
|||
let width = bounds.width - month_w;
|
||||
let height = bounds.height - first_row_h;
|
||||
self.draw_days(renderer, Rectangle{x, y, width, height});
|
||||
#[cfg(feature = "tracing")]
|
||||
tracepoints::calendar::draw_exit(bounds.width as i32, bounds.height as i32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue