mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-15 23:48:31 +00:00
Add full support to the column API
This commit is contained in:
parent
5f2bdc0604
commit
54853f4114
@ -5,6 +5,7 @@
|
||||
### Added
|
||||
|
||||
- Window scrolling API
|
||||
- Full support for the column API
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
57
src/columns.rs
Normal file
57
src/columns.rs
Normal file
@ -0,0 +1,57 @@
|
||||
use crate::string::ImStr;
|
||||
use crate::sys;
|
||||
use crate::Ui;
|
||||
|
||||
/// # Columns
|
||||
impl<'ui> Ui<'ui> {
|
||||
pub fn columns(&self, count: i32, id: &ImStr, border: bool) {
|
||||
unsafe { sys::igColumns(count, id.as_ptr(), border) }
|
||||
}
|
||||
/// Switches to the next column.
|
||||
///
|
||||
/// If the current row is finished, switches to first column of the next row
|
||||
pub fn next_column(&self) {
|
||||
unsafe { sys::igNextColumn() }
|
||||
}
|
||||
/// Returns the index of the current column
|
||||
pub fn current_column_index(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnIndex() }
|
||||
}
|
||||
/// Returns the width of the current column (in pixels)
|
||||
pub fn current_column_width(&self) -> f32 {
|
||||
unsafe { sys::igGetColumnWidth(-1) }
|
||||
}
|
||||
/// Returns the width of the given column (in pixels)
|
||||
pub fn column_width(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnWidth(column_index) }
|
||||
}
|
||||
/// Sets the width of the current column (in pixels)
|
||||
pub fn set_current_column_width(&self, width: f32) {
|
||||
unsafe { sys::igSetColumnWidth(-1, width) };
|
||||
}
|
||||
/// Sets the width of the given column (in pixels)
|
||||
pub fn set_column_width(&self, column_index: i32, width: f32) {
|
||||
unsafe { sys::igSetColumnWidth(column_index, width) };
|
||||
}
|
||||
/// Returns the offset of the current column (in pixels from the left side of the content
|
||||
/// region)
|
||||
pub fn current_column_offset(&self) -> f32 {
|
||||
unsafe { sys::igGetColumnOffset(-1) }
|
||||
}
|
||||
/// Returns the offset of the given column (in pixels from the left side of the content region)
|
||||
pub fn column_offset(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnOffset(column_index) }
|
||||
}
|
||||
/// Sets the offset of the current column (in pixels from the left side of the content region)
|
||||
pub fn set_current_column_offset(&self, offset_x: f32) {
|
||||
unsafe { sys::igSetColumnOffset(-1, offset_x) };
|
||||
}
|
||||
/// Sets the offset of the given column (in pixels from the left side of the content region)
|
||||
pub fn set_column_offset(&self, column_index: i32, offset_x: f32) {
|
||||
unsafe { sys::igSetColumnOffset(column_index, offset_x) };
|
||||
}
|
||||
/// Returns the current amount of columns
|
||||
pub fn column_count(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnsCount() }
|
||||
}
|
||||
}
|
||||
@ -351,3 +351,22 @@ impl<'ui> Ui<'ui> {
|
||||
unsafe { sys::igGetTextLineHeightWithSpacing() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ui> Ui<'ui> {
|
||||
#[deprecated(since = "0.2.0", note = "use Ui::current_column_index instead")]
|
||||
pub fn get_column_index(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnIndex() }
|
||||
}
|
||||
#[deprecated(since = "0.2.0", note = "use Ui::column_offset instead")]
|
||||
pub fn get_column_offset(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnOffset(column_index) }
|
||||
}
|
||||
#[deprecated(since = "0.2.0", note = "use Ui::column_width instead")]
|
||||
pub fn get_column_width(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnWidth(column_index) }
|
||||
}
|
||||
#[deprecated(since = "0.2.0", note = "use Ui::column_count instead")]
|
||||
pub fn get_columns_count(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnsCount() }
|
||||
}
|
||||
}
|
||||
|
||||
32
src/lib.rs
32
src/lib.rs
@ -51,6 +51,7 @@ use internal::RawCast;
|
||||
|
||||
mod child_frame;
|
||||
mod clipboard;
|
||||
mod columns;
|
||||
mod context;
|
||||
mod drag;
|
||||
mod fonts;
|
||||
@ -204,37 +205,6 @@ impl<'ui> Ui<'ui> {
|
||||
}
|
||||
}
|
||||
|
||||
// Layout
|
||||
impl<'ui> Ui<'ui> {
|
||||
pub fn columns<'p>(&self, count: i32, id: &'p ImStr, border: bool) {
|
||||
unsafe { sys::igColumns(count, id.as_ptr(), border) }
|
||||
}
|
||||
|
||||
pub fn next_column(&self) {
|
||||
unsafe { sys::igNextColumn() }
|
||||
}
|
||||
|
||||
pub fn get_column_index(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnIndex() }
|
||||
}
|
||||
|
||||
pub fn get_column_offset(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnOffset(column_index) }
|
||||
}
|
||||
|
||||
pub fn set_column_offset(&self, column_index: i32, offset_x: f32) {
|
||||
unsafe { sys::igSetColumnOffset(column_index, offset_x) }
|
||||
}
|
||||
|
||||
pub fn get_column_width(&self, column_index: i32) -> f32 {
|
||||
unsafe { sys::igGetColumnWidth(column_index) }
|
||||
}
|
||||
|
||||
pub fn get_columns_count(&self) -> i32 {
|
||||
unsafe { sys::igGetColumnsCount() }
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ImId<'a> {
|
||||
Int(i32),
|
||||
Str(&'a str),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user