From 8642508f6a318fd74c1d23e3cdffc46bee3f9281 Mon Sep 17 00:00:00 2001 From: Jack Mac Date: Sun, 12 Sep 2021 17:49:30 -0400 Subject: [PATCH] fixed doc issues --- imgui/src/drag_drop.rs | 28 ++++++++++++++-------------- imgui/src/widget/progress_bar.rs | 20 +++++++------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/imgui/src/drag_drop.rs b/imgui/src/drag_drop.rs index ed4d6b4..2fbf0b5 100644 --- a/imgui/src/drag_drop.rs +++ b/imgui/src/drag_drop.rs @@ -75,10 +75,10 @@ bitflags!( /// ```no_run /// # use imgui::*; /// fn show_ui(ui: &Ui<'_>) { -/// ui.button(im_str!("Hello, I am a drag source!")); +/// ui.button("Hello, I am a drag source!"); /// /// // Creates an empty DragSource with no tooltip -/// DragDropSource::new(im_str!("BUTTON_DRAG")).begin(ui); +/// DragDropSource::new("BUTTON_DRAG").begin(ui); /// } /// ``` /// @@ -142,9 +142,9 @@ impl> DragDropSource { /// ```no_run /// # use imgui::*; /// fn show_ui(ui: &Ui<'_>, drop_message: &mut Option) { - /// ui.button(im_str!("Drag me!")); + /// ui.button("Drag me!"); /// - /// let drag_drop_name = im_str!("Test Drag"); + /// let drag_drop_name = "Test Drag"; /// /// // drag drop SOURCE /// if DragDropSource::new(drag_drop_name).begin(ui).is_some() { @@ -154,7 +154,7 @@ impl> DragDropSource { /// *drop_message = Some("Test Payload".to_string()); /// } /// - /// ui.button(im_str!("Target me!")); + /// ui.button("Target me!"); /// /// // drag drop TARGET /// if let Some(target) = imgui::DragDropTarget::new(ui) { @@ -195,9 +195,9 @@ impl> DragDropSource { /// ```no_run /// # use imgui::*; /// fn show_ui(ui: &Ui<'_>) { - /// ui.button(im_str!("Drag me!")); + /// ui.button("Drag me!"); /// - /// let drag_drop_name = im_str!("Test Drag"); + /// let drag_drop_name = "Test Drag"; /// let msg_to_send = "hello there sailor"; /// /// // drag drop SOURCE @@ -206,12 +206,12 @@ impl> DragDropSource { /// tooltip.end(); /// } /// - /// ui.button(im_str!("Target me!")); + /// ui.button("Target me!"); /// /// // drag drop TARGET /// if let Some(target) = imgui::DragDropTarget::new(ui) { /// if let Some(Ok(payload_data)) = target - /// .accept_payload::<&'static str>(drag_drop_name, DragDropFlags::empty()) + /// .accept_payload::<&'static str, _>(drag_drop_name, DragDropFlags::empty()) /// { /// let msg = payload_data.data; /// assert_eq!(msg, msg_to_send); @@ -312,18 +312,18 @@ impl Drop for DragDropSourceToolTip<'_> { /// # use imgui::*; /// fn show_ui(ui: &Ui<'_>) { /// // Drop something on this button please! -/// ui.button(im_str!("Hello, I am a drag Target!")); +/// ui.button("Hello, I am a drag Target!"); /// /// if let Some(target) = DragDropTarget::new(ui) { /// // accepting an empty payload (which is really just raising an event) -/// if let Some(_payload_data) = target.accept_payload_empty(im_str!("BUTTON_DRAG"), DragDropFlags::empty()) { +/// if let Some(_payload_data) = target.accept_payload_empty("BUTTON_DRAG", DragDropFlags::empty()) { /// println!("Nice job getting on the payload!"); /// } /// /// // and we can accept multiple, different types of payloads with one drop target. /// // this is a good pattern for handling different kinds of drag/drop situations with /// // different kinds of data in them. -/// if let Some(Ok(payload_data)) = target.accept_payload::(im_str!("BUTTON_ID"), DragDropFlags::empty()) { +/// if let Some(Ok(payload_data)) = target.accept_payload::("BUTTON_ID", DragDropFlags::empty()) { /// println!("Our payload's data was {}", payload_data.data); /// } /// } @@ -379,9 +379,9 @@ impl<'ui> DragDropTarget<'ui> { /// /// Note: If you began this operation with `begin_payload_unchecked` it always incorrect /// to use this function. Use `accept_payload_unchecked` instead - pub fn accept_payload( + pub fn accept_payload>( &self, - name: impl AsRef, + name: Name, flags: DragDropFlags, ) -> Option, PayloadIsWrongType>> { let output = unsafe { self.accept_payload_unchecked(name, flags) }; diff --git a/imgui/src/widget/progress_bar.rs b/imgui/src/widget/progress_bar.rs index 5a806af..7995d9d 100644 --- a/imgui/src/widget/progress_bar.rs +++ b/imgui/src/widget/progress_bar.rs @@ -12,18 +12,18 @@ use crate::Ui; /// # let ui = imgui.frame(); /// ProgressBar::new(0.6) /// .size([100.0, 12.0]) -/// .overlay_text(im_str!("Progress!")) +/// .overlay_text("Progress!") /// .build(&ui); /// ``` #[derive(Copy, Clone, Debug)] #[must_use] -pub struct ProgressBar { +pub struct ProgressBar { fraction: f32, size: [f32; 2], overlay_text: Option, } -impl ProgressBar<&'static str> { +impl ProgressBar { /// Creates a progress bar with a given fraction showing /// the progress (0.0 = 0%, 1.0 = 100%). /// @@ -41,17 +41,11 @@ impl ProgressBar<&'static str> { } impl> ProgressBar { - /// Creates a progress bar with a given fraction showing - /// the progress (0.0 = 0%, 1.0 = 100%). - /// - /// The progress bar will be automatically sized to fill the entire width of the window if no - /// custom size is specified. - #[inline] - #[doc(alias = "ProgressBar")] - pub fn new_with_overlay(fraction: f32, overlay_text: T) -> Self { + /// Sets an optional text that will be drawn over the progress bar. + pub fn overlay_text>(self, overlay_text: T2) -> ProgressBar { ProgressBar { - fraction, - size: [-1.0, 0.0], + fraction: self.fraction, + size: self.size, overlay_text: Some(overlay_text), } }