Skip to content

Commit 5d609c6

Browse files
committed
Final masmerge fixes
1 parent 4cbef5e commit 5d609c6

File tree

19 files changed

+201
-222
lines changed

19 files changed

+201
-222
lines changed

iui/src/controls/area.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! Provides a way to allocate an area in the window for custom drawing.
22
33
use controls::Control;
4-
use ui::UI;
54
use draw;
65
use libc::c_int;
76
use std::mem;
8-
use ui_sys::{self, uiArea, uiAreaDrawParams, uiAreaHandler, uiAreaKeyEvent, uiAreaMouseEvent,
9-
uiControl};
7+
use ui::UI;
108
pub use ui_sys::uiExtKey as ExtKey;
9+
use ui_sys::{
10+
self, uiArea, uiAreaDrawParams, uiAreaHandler, uiAreaKeyEvent, uiAreaMouseEvent, uiControl,
11+
};
1112

1213
pub trait AreaHandler {
1314
fn draw(&mut self, _area: &Area, _area_draw_params: &AreaDrawParams) {}
@@ -133,7 +134,12 @@ impl Area {
133134
}
134135
}
135136

136-
pub fn new_scrolling(ctx: &UI, area_handler: Box<AreaHandler>, width: i64, height: i64) -> Area {
137+
pub fn new_scrolling(
138+
ctx: &UI,
139+
area_handler: Box<AreaHandler>,
140+
width: i64,
141+
height: i64,
142+
) -> Area {
137143
unsafe {
138144
let mut rust_area_handler = RustAreaHandler::new(ctx, area_handler);
139145
let area = Area::from_raw(ui_sys::uiNewScrollingArea(

iui/src/controls/basic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::mem;
2-
use std::ffi::{CStr, CString};
3-
use libc::c_void;
4-
use ui_sys::{self, uiButton, uiControl, uiLabel};
51
use super::Control;
2+
use libc::c_void;
3+
use std::ffi::{CStr, CString};
4+
use std::mem;
65
use ui::UI;
6+
use ui_sys::{self, uiButton, uiControl, uiLabel};
77

88
define_control!{
99
/// A non-interactable piece of text.

iui/src/controls/entry.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! User input mechanisms: numbers, colors, and text in various forms.
22
3-
use std::mem;
3+
use super::Control;
4+
use libc::c_void;
45
use std::ffi::{CStr, CString};
56
use std::i64;
6-
use libc::c_void;
7-
use ui_sys::{self, uiControl, uiSpinbox, uiSlider, uiEntry, uiMultilineEntry, uiCombobox,
8-
uiCheckbox};
9-
use super::Control;
7+
use std::mem;
108
use ui::UI;
9+
use ui_sys::{
10+
self, uiCheckbox, uiCombobox, uiControl, uiEntry, uiMultilineEntry, uiSlider, uiSpinbox,
11+
};
1112

1213
pub trait NumericEntry {
1314
fn value(&self, ctx: &UI) -> i64;
@@ -136,7 +137,11 @@ impl MultilineEntry {
136137

137138
impl TextEntry for Entry {
138139
fn value(&self, _ctx: &UI) -> String {
139-
unsafe { CStr::from_ptr(ui_sys::uiEntryText(self.uiEntry)).to_string_lossy().into_owned() }
140+
unsafe {
141+
CStr::from_ptr(ui_sys::uiEntryText(self.uiEntry))
142+
.to_string_lossy()
143+
.into_owned()
144+
}
140145
}
141146
fn set_value(&mut self, _ctx: &UI, value: &str) {
142147
let cstring = CString::new(value.as_bytes().to_vec()).unwrap();
@@ -156,7 +161,9 @@ impl TextEntry for Entry {
156161

157162
extern "C" fn c_callback(entry: *mut uiEntry, data: *mut c_void) {
158163
unsafe {
159-
let string = CStr::from_ptr(ui_sys::uiEntryText(entry)).to_string_lossy().into_owned();
164+
let string = CStr::from_ptr(ui_sys::uiEntryText(entry))
165+
.to_string_lossy()
166+
.into_owned();
160167
mem::transmute::<*mut c_void, &mut Box<FnMut(String)>>(data)(string);
161168
mem::forget(entry);
162169
}
@@ -166,7 +173,11 @@ impl TextEntry for Entry {
166173

167174
impl TextEntry for MultilineEntry {
168175
fn value(&self, _ctx: &UI) -> String {
169-
unsafe { CStr::from_ptr(ui_sys::uiMultilineEntryText(self.uiMultilineEntry)).to_string_lossy().into_owned() }
176+
unsafe {
177+
CStr::from_ptr(ui_sys::uiMultilineEntryText(self.uiMultilineEntry))
178+
.to_string_lossy()
179+
.into_owned()
180+
}
170181
}
171182
fn set_value(&mut self, _ctx: &UI, value: &str) {
172183
let cstring = CString::new(value.as_bytes().to_vec()).unwrap();
@@ -186,7 +197,9 @@ impl TextEntry for MultilineEntry {
186197

187198
extern "C" fn c_callback(entry: *mut uiMultilineEntry, data: *mut c_void) {
188199
unsafe {
189-
let string = CStr::from_ptr(ui_sys::uiMultilineEntryText(entry)).to_string_lossy().into_owned();
200+
let string = CStr::from_ptr(ui_sys::uiMultilineEntryText(entry))
201+
.to_string_lossy()
202+
.into_owned();
190203
mem::transmute::<*mut c_void, &mut Box<FnMut(String)>>(data)(string);
191204
mem::forget(entry);
192205
}
@@ -279,4 +292,4 @@ impl Checkbox {
279292
}
280293
}
281294
}
282-
}
295+
}

iui/src/controls/layout.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::mem;
2-
use std::ffi::{CStr, CString};
3-
use libc::c_int;
4-
use ui_sys::{self, uiBox, uiControl, uiTab, uiGroup, uiSeparator};
51
use super::Control;
6-
use ui::UI;
72
use error::UIError;
3+
use libc::c_int;
4+
use std::ffi::{CStr, CString};
5+
use std::mem;
6+
use ui::UI;
7+
use ui_sys::{self, uiBox, uiControl, uiGroup, uiSeparator, uiTab};
88

99
/// Defines the ways in which the children of boxes can be layed out.
1010
pub enum LayoutStrategy {
@@ -164,9 +164,9 @@ impl TabGroup {
164164
pub fn new(_ctx: &UI) -> TabGroup {
165165
unsafe { TabGroup::from_raw(ui_sys::uiNewTab()) }
166166
}
167-
167+
168168
/// Add the given control as a new tab in the tab group with the given name.
169-
///
169+
///
170170
/// Returns the number of tabs in the group after adding the new tab.
171171
pub fn append<T: Into<Control>>(&mut self, _ctx: &UI, name: &str, control: T) -> u64 {
172172
let control = control.into();
@@ -178,20 +178,31 @@ impl TabGroup {
178178
}
179179

180180
/// Add the given control before the given index in the tab group, as a new tab with a given name.
181-
///
181+
///
182182
/// Returns the number of tabs in the group after adding the new tab.
183-
pub fn insert_at<T: Into<Control>>(&mut self, _ctx: &UI, name: &str, before: u64, control: T) -> u64 {
183+
pub fn insert_at<T: Into<Control>>(
184+
&mut self,
185+
_ctx: &UI,
186+
name: &str,
187+
before: u64,
188+
control: T,
189+
) -> u64 {
184190
unsafe {
185191
let c_string = CString::new(name.as_bytes().to_vec()).unwrap();
186-
ui_sys::uiTabInsertAt(self.uiTab, c_string.as_ptr(), before, control.into().ui_control);
192+
ui_sys::uiTabInsertAt(
193+
self.uiTab,
194+
c_string.as_ptr(),
195+
before,
196+
control.into().ui_control,
197+
);
187198
ui_sys::uiTabNumPages(self.uiTab) as u64
188199
}
189200
}
190201

191202
/// Remove the control at the given index in the tab group.
192-
///
203+
///
193204
/// Returns the number of tabs in the group after removing the tab, or an error if that index was out of bounds.
194-
///
205+
///
195206
/// NOTE: This will leak the deleted control! We have no way of actually getting it
196207
/// to decrement its reference count per `libui`'s UI as of today, unless we maintain a
197208
/// separate list of children ourselves…
@@ -201,7 +212,7 @@ impl TabGroup {
201212
unsafe { ui_sys::uiTabDelete(self.uiTab, index) };
202213
Ok(n)
203214
} else {
204-
Err(UIError::TabGroupIndexOutOfBounds { index: index, n: n } )
215+
Err(UIError::TabGroupIndexOutOfBounds { index: index, n: n })
205216
}
206217
}
207218

@@ -218,7 +229,7 @@ impl TabGroup {
218229

219230
define_control!{
220231
/// Horizontal line, to seperate things visually.
221-
rust_type: HorizontalSeparator,
232+
rust_type: HorizontalSeparator,
222233
sys_type: uiSeparator
223234
}
224235

iui/src/controls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//!
33
//! Note that `Control` and all specific control types are references to memory which is owned by the UI library.
44
5-
use ui_sys::{self, uiControl};
65
use ui::UI;
6+
use ui_sys::{self, uiControl};
77

88
use std::ptr;
99

iui/src/controls/window.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! Functionality related to creating, managing, and destroying GUI windows.
22
33
use controls::Control;
4-
use ui::UI;
54
use libc::{c_int, c_void};
65
use std::cell::RefCell;
76
use std::ffi::{CStr, CString};
87
use std::mem;
98
use std::path::PathBuf;
9+
use ui::UI;
1010
use ui_sys::{self, uiControl, uiWindow};
1111

1212
thread_local! {
@@ -104,8 +104,9 @@ impl Window {
104104
extern "C" fn c_callback(window: *mut uiWindow, data: *mut c_void) -> i32 {
105105
unsafe {
106106
let mut window = Window { uiWindow: window };
107-
mem::transmute::<*mut c_void, Box<Box<FnMut(&mut Window) -> bool>>>(data)(&mut window)
108-
as i32
107+
mem::transmute::<*mut c_void, Box<Box<FnMut(&mut Window) -> bool>>>(data)(
108+
&mut window,
109+
) as i32
109110
}
110111
}
111112
}
@@ -137,31 +138,30 @@ impl Window {
137138
/// Allow the user to select an existing file.
138139
pub fn open_file(&self, _ctx: &UI) -> Option<PathBuf> {
139140
let ptr = unsafe { ui_sys::uiOpenFile(self.uiWindow) };
140-
if ptr.is_null() { return None };
141+
if ptr.is_null() {
142+
return None;
143+
};
141144
let path_string: String = unsafe { CStr::from_ptr(ptr).to_string_lossy().into() };
142145
Some(path_string.into())
143146
}
144147

145148
/// Allow the user to select a new or existing file.
146149
pub fn save_file(&self, _ctx: &UI) -> Option<PathBuf> {
147150
let ptr = unsafe { ui_sys::uiSaveFile(self.uiWindow) };
148-
if ptr.is_null() { return None };
151+
if ptr.is_null() {
152+
return None;
153+
};
149154
let path_string: String = unsafe { CStr::from_ptr(ptr).to_string_lossy().into() };
150155
Some(path_string.into())
151156
}
152157

153-
154158
/// Open a generic message box to show a message to the user.
155159
/// Returns when the user acknowledges the message.
156160
pub fn modal_msg(&self, _ctx: &UI, title: &str, description: &str) {
157161
unsafe {
158162
let c_title = CString::new(title.as_bytes().to_vec()).unwrap();
159163
let c_description = CString::new(description.as_bytes().to_vec()).unwrap();
160-
ui_sys::uiMsgBox(
161-
self.uiWindow,
162-
c_title.as_ptr(),
163-
c_description.as_ptr(),
164-
)
164+
ui_sys::uiMsgBox(self.uiWindow, c_title.as_ptr(), c_description.as_ptr())
165165
}
166166
}
167167

@@ -171,11 +171,7 @@ impl Window {
171171
unsafe {
172172
let c_title = CString::new(title.as_bytes().to_vec()).unwrap();
173173
let c_description = CString::new(description.as_bytes().to_vec()).unwrap();
174-
ui_sys::uiMsgBoxError(
175-
self.uiWindow,
176-
c_title.as_ptr(),
177-
c_description.as_ptr(),
178-
)
174+
ui_sys::uiMsgBoxError(self.uiWindow, c_title.as_ptr(), c_description.as_ptr())
179175
}
180176
}
181177

iui/src/draw/brush.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use ui::UI;
21
use std::marker::PhantomData;
32
use std::ptr;
3+
use ui::UI;
44
use ui_sys::{uiDrawBrush, uiDrawBrushType};
55

66
pub use ui_sys::uiDrawBrushGradientStop as BrushGradientStop;
@@ -114,14 +114,20 @@ impl<'a> BrushRef<'a> {
114114
}
115115
}
116116

117+
/// A brush that paints all pixels with the same color, respecting alpha.
117118
#[derive(Copy, Clone, PartialEq, Debug)]
118119
pub struct SolidBrush {
120+
/// Red component of the color
119121
pub r: f64,
122+
/// Green component of the color
120123
pub g: f64,
124+
/// Blue component of the color
121125
pub b: f64,
126+
/// Alpha (α) component of the color (that is, opacity).
122127
pub a: f64,
123128
}
124129

130+
/// A brush that paints a linear gradient.
125131
#[derive(Clone, Debug)]
126132
pub struct LinearGradientBrush {
127133
pub start_x: f64,
@@ -131,6 +137,7 @@ pub struct LinearGradientBrush {
131137
pub stops: Vec<BrushGradientStop>,
132138
}
133139

140+
/// A brush that paints a radial gradient.
134141
#[derive(Clone, Debug)]
135142
pub struct RadialGradientBrush {
136143
pub start_x: f64,
@@ -139,4 +146,4 @@ pub struct RadialGradientBrush {
139146
pub outer_circle_center_y: f64,
140147
pub outer_radius: f64,
141148
pub stops: Vec<BrushGradientStop>,
142-
}
149+
}

0 commit comments

Comments
 (0)