[cimgui 1.53.1] Remove ImGuiWindowFlags::ShowBorders

This commit is contained in:
Malik Olivier Boussejra 2018-04-30 00:43:45 +09:00
parent adfa447d2f
commit 112d21133b
5 changed files with 27 additions and 19 deletions

View File

@ -19,6 +19,9 @@
and `sys::ImDrawList_AddConvexPolyFilled`.
- Rename `ImGuiStyleVar::ChildWindowRounding` to `ImGuiStyleVar::ChildRounding`.
- Rename `StyleVar::ChildWindowRounding` to `StyleVar::ChildRounding`.
- Remove `ImGuiWindowFlags::ShowBorders` window flag. Borders are now fully
set up in the ImGuiStyle structure.
- Obsolete `Window::show_borders`. Use `StyleVar` instead.
- Style: Add `PopupRounding`, `FrameBorderSize`, `WindowBorderSize`, `PopupBorderSize`.

View File

@ -23,7 +23,6 @@ struct State {
show_app_metrics: bool,
show_app_about: bool,
no_titlebar: bool,
no_border: bool,
no_resize: bool,
no_move: bool,
no_scrollbar: bool,
@ -72,7 +71,6 @@ impl Default for State {
show_app_metrics: false,
show_app_about: false,
no_titlebar: false,
no_border: true,
no_resize: false,
no_move: false,
no_scrollbar: false,
@ -269,7 +267,6 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
ui.window(im_str!("ImGui Demo"))
.title_bar(!state.no_titlebar)
.show_borders(!state.no_border)
.resizable(!state.no_resize)
.movable(!state.no_move)
.scroll_bar(!state.no_scrollbar)
@ -344,15 +341,14 @@ fn show_test_window(ui: &Ui, state: &mut State, opened: &mut bool) {
if ui.collapsing_header(im_str!("Window options")).build() {
ui.checkbox(im_str!("No titlebar"), &mut state.no_titlebar);
ui.same_line(150.0);
ui.checkbox(im_str!("No border"), &mut state.no_border);
ui.same_line(300.0);
ui.checkbox(im_str!("No resize"), &mut state.no_resize);
ui.checkbox(im_str!("No move"), &mut state.no_move);
ui.same_line(150.0);
ui.checkbox(im_str!("No scrollbar"), &mut state.no_scrollbar);
ui.same_line(300.0);
ui.checkbox(im_str!("No collapse"), &mut state.no_collapse);
ui.checkbox(im_str!("No menu"), &mut state.no_menu);
ui.checkbox(im_str!("No move"), &mut state.no_move);
ui.same_line(150.0);
ui.checkbox(im_str!("No resize"), &mut state.no_resize);
ui.same_line(300.0);
ui.checkbox(im_str!("No collapse"), &mut state.no_collapse);
ui.tree_node(im_str!("Style")).build(|| {
ui.show_default_style_editor()

View File

@ -244,7 +244,6 @@ bitflags!(
const NoScrollWithMouse = 1 << 4;
const NoCollapse = 1 << 5;
const AlwaysAutoResize = 1 << 6;
const ShowBorders = 1 << 7;
const NoSavedSettings = 1 << 8;
const NoInputs = 1 << 9;
const MenuBar = 1 << 10;

View File

@ -7,6 +7,7 @@ use super::{ImStr, ImVec2, ImGuiWindowFlags, Ui};
pub struct ChildFrame<'ui, 'p> {
name: &'p ImStr,
size: ImVec2,
border: bool,
flags: ImGuiWindowFlags,
_phantom: PhantomData<&'ui Ui<'ui>>,
}
@ -16,6 +17,7 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> {
ChildFrame {
name: name,
size: size.into(),
border: false,
flags: ImGuiWindowFlags::empty(),
_phantom: PhantomData,
}
@ -47,7 +49,7 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> {
}
#[inline]
pub fn show_borders(mut self, value: bool) -> Self {
self.flags.set(ImGuiWindowFlags::ShowBorders, value);
self.border = value;
self
}
#[inline]
@ -103,12 +105,8 @@ impl<'ui, 'p> ChildFrame<'ui, 'p> {
self
}
pub fn build<F: FnOnce()>(self, f: F) {
// See issue for history.
// https://github.com/Gekkio/imgui-rs/pull/58
let show_border = false;
let render_child_frame =
unsafe { sys::igBeginChild(self.name.as_ptr(), self.size, show_border, self.flags) };
unsafe { sys::igBeginChild(self.name.as_ptr(), self.size, self.border, self.flags) };
if render_child_frame {
f();
}

View File

@ -2,7 +2,7 @@ use sys;
use std::marker::PhantomData;
use std::ptr;
use super::{ImGuiCond, ImGuiWindowFlags, ImStr, ImVec2, Ui};
use super::{ImGuiCond, ImGuiStyleVar, ImGuiWindowFlags, ImStr, ImVec2, Ui};
#[must_use]
pub struct Window<'ui, 'p> {
@ -13,6 +13,8 @@ pub struct Window<'ui, 'p> {
name: &'p ImStr,
opened: Option<&'p mut bool>,
flags: ImGuiWindowFlags,
// Deprecated. Should be removed along with Window::show_borders
border: bool,
_phantom: PhantomData<&'ui Ui<'ui>>,
}
@ -26,6 +28,7 @@ impl<'ui, 'p> Window<'ui, 'p> {
name: name,
opened: None,
flags: ImGuiWindowFlags::empty(),
border: false,
_phantom: PhantomData,
}
}
@ -87,8 +90,9 @@ impl<'ui, 'p> Window<'ui, 'p> {
self
}
#[inline]
#[deprecated(since = "0.0.19", note = "please use StyleVar instead")]
pub fn show_borders(mut self, value: bool) -> Self {
self.flags.set(ImGuiWindowFlags::ShowBorders, value);
self.border = value;
self
}
#[inline]
@ -156,6 +160,9 @@ impl<'ui, 'p> Window<'ui, 'p> {
if !self.size_cond.is_empty() {
sys::igSetNextWindowSize(self.size.into(), self.size_cond);
}
if self.border {
sys::igPushStyleVar(ImGuiStyleVar::FrameBorderSize, 1.0);
}
sys::igBegin(
self.name.as_ptr(),
self.opened.map(|x| x as *mut bool).unwrap_or(
@ -167,6 +174,11 @@ impl<'ui, 'p> Window<'ui, 'p> {
if render {
f();
}
unsafe { sys::igEnd() };
unsafe {
sys::igEnd();
if self.border {
sys::igPopStyleVar(1);
}
};
}
}