Skip to content

Commit

Permalink
add version number
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirdConstructor committed Jan 7, 2021
1 parent 351bf76 commit ef9bcb2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl UIController for TestController {
let mut public_ps = kickmessvst::ParamSet::new();
kickmessvst::OpKickmess::init_params(&mut ps, &mut public_ps);
kickmessvst::editor::define_gui(&ps, ui);
ui.set_version(kickmessvst::VERSION);
}

fn window_closed(&self, _ui: &mut dyn UI) {
Expand Down
2 changes: 2 additions & 0 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ impl UIController for KickmessEditorController {
self.is_open.store(true, std::sync::atomic::Ordering::Relaxed);
define_gui(&self.params.ps, ui);

ui.set_version(crate::VERSION);

for (i, p) in self.params.params.iter().enumerate() {
ui.set_values(
&[UIInputValue {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use std::sync::Arc;
const MAX_BLOCKSIZE: usize = 64;
const MAX_POLY: usize = 16;

pub const VERSION: &str = env!("CARGO_PKG_VERSION");

struct Kickmess {
host: HostCallback,
params: Arc<KickmessVSTParams>,
Expand Down
2 changes: 2 additions & 0 deletions src/ui/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub const UI_PRIM2_CLR : (f64, f64, f64) = (26.0 / 255.0, 174.0 / 2
pub const UI_HLIGHT_CLR : (f64, f64, f64) = (233.0 / 255.0, 248.0 / 255.0, 64.0 / 255.0);
pub const UI_HLIGHT2_CLR : (f64, f64, f64) = (181.0 / 255.0, 196.0 / 255.0, 18.0 / 255.0);

pub const UI_VERSION_FONT_SIZE : f64 = 10.0;

pub const UI_HELP_FONT_SIZE : f64 = 16.0;
pub const UI_HELP_TXT_CLR : (f64, f64, f64) = UI_TXT_CLR;

Expand Down
16 changes: 15 additions & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ pub struct WValuePlugUI {
help_id: Option<usize>,

needs_redraw_flag: bool,

version_label: &'static str,
}

#[derive(Debug, Clone, Copy)]
Expand Down Expand Up @@ -183,6 +185,11 @@ impl UI for WValuePlugUI {
}
self.queue_redraw();
}

fn set_version(&mut self, version_label: &'static str) {
self.version_label = version_label;
self.queue_redraw();
}
}

impl WValuePlugUI {
Expand All @@ -204,7 +211,7 @@ impl WValuePlugUI {
input_mode: InputMode::None,
help_id: None,
help_texts: vec![],
// font: None,
version_label: "",
};
this.init_draw_cache();
this.controller.clone().init(&mut this);
Expand Down Expand Up @@ -1299,6 +1306,13 @@ impl WValuePlugUI {
&std::str::from_utf8(input.borrow().get_ref()).unwrap().trim());
}

if self.version_label.len() > 0 {
p.label_mono(
UI_VERSION_FONT_SIZE, 1, UI_LBL_TXT_CLR,
ww - 50.0, 0.0, 40.0, UI_ELEM_TXT_H,
self.version_label);
}

self.needs_redraw_flag = false;
}
}
1 change: 1 addition & 0 deletions src/ui/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ pub trait UI {
fn define_layout(&mut self, layout: Vec<UILayout>);
fn define_value_spec(&mut self, spec: Vec<UIValueSpec>);
fn set_values(&mut self, vals: &[UIInputValue]);
fn set_version(&mut self, version_label: &'static str);
}

pub trait UIController : Send + Sync {
Expand Down

0 comments on commit ef9bcb2

Please sign in to comment.