Resovled issues with PR
This commit is contained in:
parent
57aa3ad671
commit
6e0736dbfc
6 changed files with 18 additions and 33 deletions
|
|
@ -3,13 +3,6 @@ name = "vertical-spin-button"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["xdg-portal"]
|
||||
rfd = ["libcosmic/rfd"]
|
||||
xdg-portal = ["libcosmic/xdg-portal"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
[dependencies.libcosmic]
|
||||
features = ["debug", "winit", "wayland", "desktop", "tokio"]
|
||||
path ="../.."
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use cosmic::widget::{button, container, text, spin_button, spin_button_standard, spin_button::Orientation};
|
||||
use cosmic::widget::{button, container, text, spin_button, vertical_spin_button, /*spin_button::Orientation*/};
|
||||
use cosmic::{
|
||||
app::{Core, Task},
|
||||
iced::{
|
||||
|
|
@ -85,40 +85,36 @@ impl Application for SpinButtonExamplApp {
|
|||
|
||||
fn view(&self) -> Element<Self::Message> {
|
||||
let vert_spinner_row = row![
|
||||
spin_button(
|
||||
vertical_spin_button(
|
||||
"i8", // label: displayed above the widget no matter the orientation
|
||||
1, // step: how much to increment/decrement by
|
||||
self.i8_num, // current value, this is also what's displayed in the center of the widget
|
||||
-5, // minimum value, if decremented below this the widget's current value rolls to the max value
|
||||
5, // maximum value, if incremented above this the widget's current value rolls to the min value
|
||||
Some(Orientation::Vertical), // oreintation of the widget
|
||||
SpinBtnMessages::UpdateI8Num // message to send to the application's update function
|
||||
),
|
||||
spin_button(
|
||||
vertical_spin_button(
|
||||
"i16",
|
||||
1,
|
||||
self.i16_num,
|
||||
0,
|
||||
10,
|
||||
Some(Orientation::Vertical),
|
||||
SpinBtnMessages::UpdateI16Num
|
||||
),
|
||||
spin_button(
|
||||
vertical_spin_button(
|
||||
"i32",
|
||||
1,
|
||||
self.i32_num,
|
||||
0,
|
||||
12,
|
||||
Some(Orientation::Vertical),
|
||||
SpinBtnMessages::UpdateI32Num
|
||||
),
|
||||
spin_button(
|
||||
vertical_spin_button(
|
||||
"i64",
|
||||
10,
|
||||
self.i64_num,
|
||||
15,
|
||||
35,
|
||||
Some(Orientation::Vertical),
|
||||
SpinBtnMessages::UpdateI64Num
|
||||
),
|
||||
]
|
||||
|
|
@ -126,13 +122,13 @@ impl Application for SpinButtonExamplApp {
|
|||
|
||||
let horiz_spinner_row = column![
|
||||
row![
|
||||
// This function can be called instead if a Horizontal Spin Button is needed.
|
||||
spin_button(
|
||||
"i128",
|
||||
100,
|
||||
self.i128_num,
|
||||
-1000,
|
||||
500,
|
||||
None, // Passing None gives a default of a Horizontal Spin Button widget
|
||||
SpinBtnMessages::UpdateI128Num
|
||||
),
|
||||
],
|
||||
|
|
@ -144,15 +140,12 @@ impl Application for SpinButtonExamplApp {
|
|||
self.f32_num,
|
||||
-35.3,
|
||||
12.3,
|
||||
Some(Orientation::Horizontal), // It can also be explicitly passed as Orientation::Horizontal
|
||||
SpinBtnMessages::UpdateF32Num
|
||||
)
|
||||
],
|
||||
vertical_space().height(5),
|
||||
row![
|
||||
// This function can be called instead if a Horizontal Spin Button is needed.
|
||||
// This shortens up the API call for default/standard Spin Button widgets.
|
||||
spin_button_standard(
|
||||
spin_button(
|
||||
"f64",
|
||||
1.3,
|
||||
self.f64_num,
|
||||
|
|
|
|||
2
iced
2
iced
|
|
@ -1 +1 @@
|
|||
Subproject commit d0c2a0371b476866cb0f7045fba0215425493d62
|
||||
Subproject commit 256863574bacfb1d2797c2a48cba7a3388cbeb59
|
||||
|
|
@ -102,7 +102,7 @@ pub(crate) fn iced_settings<App: Application>(
|
|||
iced.default_font = settings.default_font;
|
||||
iced.default_text_size = iced::Pixels(settings.default_text_size);
|
||||
let exit_on_close = settings.exit_on_close;
|
||||
//iced.is_daemon = false;
|
||||
iced.is_daemon = false;
|
||||
iced.exit_on_close_request = settings.is_daemon;
|
||||
let mut window_settings = iced::window::Settings::default();
|
||||
window_settings.exit_on_close_request = exit_on_close;
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ pub mod settings;
|
|||
|
||||
pub mod spin_button;
|
||||
#[doc(inline)]
|
||||
pub use spin_button::{spin_button, spin_button_standard, SpinButton};
|
||||
pub use spin_button::{spin_button, vertical_spin_button, SpinButton};
|
||||
|
||||
pub mod tab_bar;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
// Updated by Bryan Hyland <bryan.hyland32@gmail.com>
|
||||
// Updated on: 17Nov24
|
||||
// Updated on: 18Nov24
|
||||
|
||||
//! A control for incremental adjustments of a value.
|
||||
|
||||
|
|
@ -89,17 +89,16 @@ pub fn spin_button<'a, T, M>(
|
|||
value: T,
|
||||
min: T,
|
||||
max: T,
|
||||
orientation: Option<Orientation>,
|
||||
on_press: impl Fn(T) -> M + 'static,
|
||||
) -> SpinButton<'a, T, M>
|
||||
where
|
||||
T: Add<Output = T> + Sub<Output = T> + PartialEq + PartialOrd + Display + Copy
|
||||
{
|
||||
SpinButton::new(label, step, value, min, max, orientation, on_press)
|
||||
SpinButton::new(label, step, value, min, max, None, on_press)
|
||||
}
|
||||
|
||||
/// Shorthand to create a standard (horizontal) spin button widget
|
||||
pub fn spin_button_standard<'a, T, M>(
|
||||
pub fn vertical_spin_button<'a, T, M>(
|
||||
label: impl Into<String>,
|
||||
step: T,
|
||||
value: T,
|
||||
|
|
@ -110,7 +109,7 @@ pub fn spin_button_standard<'a, T, M>(
|
|||
where
|
||||
T: Add<Output = T> + Sub<Output = T> + PartialEq + PartialOrd + Display + Copy
|
||||
{
|
||||
SpinButton::new(label, step, value, min, max, None, on_press)
|
||||
SpinButton::new(label, step, value, min, max, Some(Orientation::Vertical), on_press)
|
||||
}
|
||||
|
||||
fn increment<T>(step: T, value: T, min: T, max: T) -> T
|
||||
|
|
@ -220,14 +219,14 @@ where
|
|||
T: Add<Output = T> + Sub<Output = T> + PartialEq + PartialOrd + Display + Copy
|
||||
{
|
||||
// Create a text widget that holds the value
|
||||
let val_text = text(format!("{}", spin_btn.value)).size(14);
|
||||
let val_text = text::title4(format!("{}", spin_btn.value));
|
||||
// Create a spinner container variable that contains the column with all of
|
||||
// the combined widgets that make up the widget.
|
||||
let spinner_container = column::with_capacity(3)
|
||||
.push(
|
||||
// Use a button for the increment functionality
|
||||
button::icon(icon::from_name("list-add-symbolic"))
|
||||
.padding([0, 12])
|
||||
.padding([5, 0])
|
||||
.on_press((spin_btn.on_press)(increment::<T>(
|
||||
spin_btn.step, spin_btn.value, spin_btn.min, spin_btn.max,
|
||||
))),
|
||||
|
|
@ -237,7 +236,7 @@ where
|
|||
.push(
|
||||
// Use a button for the decrement functionality
|
||||
button::icon(icon::from_name("list-remove-symbolic"))
|
||||
.padding([0, 12])
|
||||
.padding([5, 0])
|
||||
.on_press((spin_btn.on_press)(decrement::<T>(
|
||||
spin_btn.step, spin_btn.value, spin_btn.min, spin_btn.max,
|
||||
))),
|
||||
|
|
@ -248,7 +247,7 @@ where
|
|||
// First Row -> The label/title for the spin button.
|
||||
// Second Row -> The spin button container from above.
|
||||
let content_list = column::with_children(vec![
|
||||
row::with_capacity(1).push(text(spin_btn.label.clone())).into(),
|
||||
row::with_capacity(1).push(text::title4(spin_btn.label.clone())).into(),
|
||||
row::with_children(vec![Element::from(spinner_container)]).into(),
|
||||
])
|
||||
.width(75)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue