Skip to content

Commit c3b3f49

Browse files
Directly alias sfBool instead of using a newtype wrapper
Fixes #163
1 parent 0c77e81 commit c3b3f49

File tree

3 files changed

+24
-41
lines changed

3 files changed

+24
-41
lines changed

src/system/bool_.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/system/mod.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,33 @@
44
//!
55
66
pub use self::clock::Clock;
7-
pub use self::bool_::Bool;
87
pub use self::sleep::sleep;
98
pub use self::time::Time;
109
pub use self::vector2::{Vector2, Vector2f, Vector2i, Vector2u};
1110
pub use self::vector3::{Vector3, Vector3f, Vector3i};
11+
use csfml_system_sys::{sfBool, sfFalse, sfTrue};
12+
13+
/// Boolean type used by CSFML.
14+
///
15+
/// Used in cases where we need directly pass a boolean value to CSFML, like in the case
16+
/// of `ContextSettings`.
17+
///
18+
/// # Example
19+
/// ```ignore
20+
/// use sfml::window::ContextSettings;
21+
/// use sfml::system;
22+
/// let mut context_settings = ContextSettings::default();
23+
/// context_settings.srgb_capable = system::TRUE;
24+
/// ```
25+
pub type Bool = sfBool;
26+
27+
/// Boolean false value used by CSFML.
28+
pub const FALSE: Bool = sfFalse;
29+
/// Boolean `true` value used by CSFML.
30+
pub const TRUE: Bool = sfTrue;
1231

1332
mod time;
1433
mod clock;
1534
mod sleep;
1635
mod vector2;
1736
mod vector3;
18-
mod bool_;

src/window/context_settings.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use csfml_window_sys::sfContextSettings;
22
use std::os::raw::c_uint;
3-
use system::Bool;
3+
use system::{Bool, FALSE};
44

55
/// Structure defining the settings of the OpenGL context attached to a window.
66
///
@@ -81,15 +81,15 @@ impl Default for ContextSettings {
8181
///
8282
/// ```
8383
/// # use sfml::window::ContextSettings;
84-
/// # use sfml::system::Bool;
84+
/// # use sfml::system;
8585
/// let values = ContextSettings {
8686
/// depth_bits: 0,
8787
/// stencil_bits: 0,
8888
/// antialiasing_level: 0,
8989
/// major_version: 1,
9090
/// minor_version: 1,
9191
/// attribute_flags: ContextSettings::ATTRIB_DEFAULT,
92-
/// srgb_capable: Bool::FALSE,
92+
/// srgb_capable: system::FALSE,
9393
/// };
9494
/// assert_eq!(ContextSettings::default(), values);
9595
/// ```
@@ -101,7 +101,7 @@ impl Default for ContextSettings {
101101
major_version: 1,
102102
minor_version: 1,
103103
attribute_flags: Self::ATTRIB_DEFAULT,
104-
srgb_capable: Bool::FALSE,
104+
srgb_capable: FALSE,
105105
}
106106
}
107107
}

0 commit comments

Comments
 (0)