Skip to content

Commit

Permalink
Merge pull request #192 from KinoxKlark/upgrade/v1.79
Browse files Browse the repository at this point in the history
Upgrade/v1.82
  • Loading branch information
KinoxKlark committed Aug 27, 2021
2 parents 560c416 + 8f4e372 commit b6ae8d4
Show file tree
Hide file tree
Showing 34 changed files with 7,471 additions and 1,253 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ clean:
.PHONY: build
build: bootstrap
_CYTHONIZE_WITH_COVERAGE=1 ${PYTHON} -m pip install -e . -v
${PYTHON} ci/completion.py -o README.md with-pxd imgui/cimgui.pxd
${PYTHON} ci/completion.py -o README.md with-pxd imgui/cimgui.pxd imgui/internal.pxd


.PHONY: rebuild
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![completion](https://img.shields.io/badge/completion-81%25%20%28373%20of%20458%29-blue.svg)](https://github.com/swistakm/pyimgui)
[![completion](https://img.shields.io/badge/completion-70%25%20%28518%20of%20735%29-blue.svg)](https://github.com/swistakm/pyimgui)
[![Coverage Status](https://coveralls.io/repos/github/swistakm/pyimgui/badge.svg?branch=master)](https://coveralls.io/github/swistakm/pyimgui?branch=master)
[![Documentation Status](https://readthedocs.org/projects/pyimgui/badge/?version=latest)](https://pyimgui.readthedocs.io/en/latest/?badge=latest)

Expand Down
6 changes: 3 additions & 3 deletions ansifeed-cpp/AnsiTextColored.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ namespace ImGui
// so this is merely to handle direct calls.

// Align to be pixel perfect
pos.x = (float)(int)pos.x + font->DisplayOffset.x;
pos.y = (float)(int)pos.y + font->DisplayOffset.y;
pos.x = (float)(int)pos.x;
pos.y = (float)(int)pos.y;
float x = pos.x;
float y = pos.y;
if (y > clip_rect.w)
Expand Down Expand Up @@ -475,7 +475,7 @@ namespace ImGui
if (text_end == NULL)
text_end = text + strlen(text); // FIXME-OPT

const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrentLineTextBaseOffset);
const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
const float wrap_pos_x = window->DC.TextWrapPos;
const bool wrap_enabled = wrap_pos_x >= 0.0f;
if (text_end - text > 2000 && !wrap_enabled) {
Expand Down
10 changes: 6 additions & 4 deletions ci/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ def with_nm(ctx, srclib, dstlib):


@cli.command(name='with-pxd')
@click.argument('pxd_file', type=click.File('r'))
@click.argument('pxd_files', type=click.File('r', encoding='utf-8'), nargs=-1)
@click.pass_context
def with_pxd(ctx, pxd_file):
lines = pxd_file.readlines()

def with_pxd(ctx, pxd_files):
lines = []
for pxd_file in pxd_files:
lines += pxd_file.readlines()

all_count = len(list(filter(ALL_RE.match, lines)))
done_count = len(list(filter(DONE_RE.match, lines)))

Expand Down
2 changes: 2 additions & 0 deletions config-cpp/py_imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern "C" {
// lousy workaround for missing stdint.h in Visual C++ for Python
typedef unsigned __int64 uint64_t;
typedef signed __int64 int64_t;
typedef unsigned __int32 uint32_t;
typedef signed __int32 int32_t;
#endif

// Redefine IM_ASSERT to raise Python specific exceptions
Expand Down
39 changes: 35 additions & 4 deletions doc/examples/integrations_all_in_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,53 @@ def pysdl2_init():
def main_pygame():
pygame.init()
size = 800, 600
pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)
pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE)

imgui.create_context()
impl = PygameRenderer()

io = imgui.get_io()
io.fonts.add_font_default()
io.display_size = size
renderer = PygameRenderer()

show_custom_window = True

while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
renderer.process_event(event)
impl.process_event(event)
impl.process_inputs()
imgui.new_frame()
on_frame()

if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):

clicked_quit, selected_quit = imgui.menu_item(
"Quit", 'Cmd+Q', False, True
)

if clicked_quit:
exit(1)

imgui.end_menu()
imgui.end_main_menu_bar()

imgui.show_test_window()

if show_custom_window:
is_expand, show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()

# note: cannot use screen.fill((1, 1, 1)) because pygame's screen
# does not support fill() on OpenGL sufraces
gl.glClearColor(1, 1, 1, 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
imgui.render()
impl.render(imgui.get_draw_data())
pygame.display.flip()


Expand Down Expand Up @@ -162,6 +192,7 @@ def __init__(self):
self._text = "Input text here"

def draw(self, *args, **kwargs):
self.process_inputs()
imgui.new_frame()
on_frame()
gl.glClearColor(1., 1., 1., 1)
Expand Down
12 changes: 8 additions & 4 deletions doc/examples/integrations_cocos2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class HelloWorld(ImguiLayer):
def __init__(self):
super(HelloWorld, self).__init__()
self._text = "Input text here"
self.show_custom_window = True

def draw(self, *args, **kwargs):
self.process_inputs()
imgui.new_frame()

if imgui.begin_main_menu_bar():
Expand All @@ -34,10 +36,12 @@ def draw(self, *args, **kwargs):

imgui.show_test_window()

imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
if self.show_custom_window:
is_expand, self.show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()

gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
Expand Down
18 changes: 11 additions & 7 deletions doc/examples/integrations_glfw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def main():
imgui.create_context()
window = impl_glfw_init()
impl = GlfwRenderer(window)


show_custom_window = True

while not glfw.window_should_close(window):
glfw.poll_events()
impl.process_inputs()
Expand All @@ -31,12 +33,14 @@ def main():
imgui.end_main_menu_bar()


imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_ansi("B\033[31marA\033[mnsi ")
imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)
imgui.extra.text_ansi_colored("Eggs", 0.2, 1., 0.)
imgui.end()
if show_custom_window:
is_expand, show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bar")
imgui.text_ansi("B\033[31marA\033[mnsi ")
imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)
imgui.extra.text_ansi_colored("Eggs", 0.2, 1., 0.)
imgui.end()

show_test_window()
#imgui.show_test_window()
Expand Down
14 changes: 9 additions & 5 deletions doc/examples/integrations_pygame.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def main():

io = imgui.get_io()
io.display_size = size

show_custom_window = True

while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()

impl.process_event(event)
impl.process_inputs()

imgui.new_frame()

Expand All @@ -45,10 +47,12 @@ def main():

imgui.show_test_window()

imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
if show_custom_window:
is_expand, show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()

# note: cannot use screen.fill((1, 1, 1)) because pygame's screen
# does not support fill() on OpenGL sufraces
Expand Down
23 changes: 15 additions & 8 deletions doc/examples/integrations_pyglet.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
# or PygletProgrammablePipelineRenderer, but create_renderer handles the
# version checking for us.
from imgui.integrations.pyglet import create_renderer

def main():

window = pyglet.window.Window(width=1280, height=720, resizable=True)
gl.glClearColor(1, 1, 1, 1)
imgui.create_context()
impl = create_renderer(window)


global show_custom_window
show_custom_window = True

def update(dt):
impl.process_inputs()
imgui.new_frame()
if imgui.begin_main_menu_bar():
if imgui.begin_menu("File", True):
Expand All @@ -36,14 +40,17 @@ def update(dt):
show_test_window()
#imgui.show_test_window()

imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
global show_custom_window
if show_custom_window:
is_expand, show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)

imgui.text_ansi("B\033[31marA\033[mnsi ")
imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)
imgui.text_ansi("B\033[31marA\033[mnsi ")
imgui.text_ansi_colored("Eg\033[31mgAn\033[msi ", 0.2, 1., 0.)

imgui.end()
imgui.end()

def draw(dt):
update(dt)
Expand Down
12 changes: 8 additions & 4 deletions doc/examples/integrations_pysdl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def main():
imgui.create_context()
impl = SDL2Renderer(window)

show_custom_window = True

running = True
event = SDL_Event()
while running:
Expand Down Expand Up @@ -41,10 +43,12 @@ def main():
show_test_window()
#imgui.show_test_window()

imgui.begin("Custom window", True)
imgui.text("Bar")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()
if show_custom_window:
is_expand, show_custom_window = imgui.begin("Custom window", True)
if is_expand:
imgui.text("Bars")
imgui.text_colored("Eggs", 0.2, 1., 0.)
imgui.end()

gl.glClearColor(1., 1., 1., 1)
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
Expand Down
41 changes: 22 additions & 19 deletions doc/examples/testwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,17 +534,18 @@ def show_test_window():
imgui.show_style_editor()
imgui.end()
if show_app_about:
show_app_about = imgui.begin(
is_expand, show_app_about = imgui.begin(
label="About Dear ImGui",
closable=show_app_about,
flags=imgui.WINDOW_ALWAYS_AUTO_RESIZE,
)
imgui.text("Dear ImGui, " + imgui.get_version())
imgui.separator()
imgui.text("By Omar Cornut and all dear imgui contributors.")
imgui.text(
"Dear ImGui is licensed under the MIT License, see LICENSE for more information."
)
if is_expand:
imgui.text("Dear ImGui, " + imgui.get_version())
imgui.separator()
imgui.text("By Omar Cornut and all dear imgui contributors.")
imgui.text(
"Dear ImGui is licensed under the MIT License, see LICENSE for more information."
)
imgui.end()

window_flags = 0
Expand Down Expand Up @@ -730,7 +731,7 @@ def show_test_window():
)
imgui.checkbox(
label="io.ConfigResizeWindowsFromEdges [beta]",
state=io.config_resize_windows_from_edges,
state=io.config_windows_resize_from_edges,
)
imgui.same_line()
show_help_marker(
Expand Down Expand Up @@ -961,20 +962,22 @@ def show_test_window():
max_value=1.0,
format="ratio = %.3f",
)
changed, widgets_basic_f2_1 = imgui.slider_float(
label="slider float (curve)",
value=widgets_basic_f2_1,
min_value=-10.0,
max_value=10.0,
format="%.4f",
power=2.0,
)
# TODO -- figure out how to fix this power argument
# and change it into an Enum
# changed, widgets_basic_f2_1 = imgui.slider_float(
# label="slider float (curve)",
# value=widgets_basic_f2_1,
# min_value=-10.0,
# max_value=10.0,
# format="%.4f",
# power=2.0,
# )
# in degrees
changed, widgets_basic_angle = imgui.slider_angle(
label="slider angle",
value=widgets_basic_angle,
min_value=0.0,
max_value=180.0,
rad_value=widgets_basic_angle,
value_degrees_min=0.0,
value_degrees_max=180.0,
)

changed, widgets_basic_col1 = imgui.color_edit3(
Expand Down
2 changes: 2 additions & 0 deletions doc/source/guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ Usage guide
treenode-flags
selectable-flag
inputtext-flags
slider-flags
tabbar-flags

17 changes: 17 additions & 0 deletions doc/source/guide/slider-flags.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.. _guide-slider-flags:

Using slider flags
======================

Slider functions accept various flags to manage their behaviour.

List of all available slider flags (click to see documentation):

.. _slider-flag-options:

* :py:data:`imgui.SLIDER_FLAGS_NONE`
* :py:data:`imgui.SLIDER_FLAGS_ALWAYS_CLAMP` Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
* :py:data:`imgui.SLIDER_FLAGS_LOGARITHMIC` Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
* :py:data:`imgui.SLIDER_FLAGS_NO_ROUND_TO_FORMAT` Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
* :py:data:`imgui.SLIDER_FLAGS_NO_INPUT` Disable CTRL+Click or Enter key allowing to input text directly into the widget

Loading

0 comments on commit b6ae8d4

Please sign in to comment.