Creating the standard input focus frame implementation object

customkeyfocus.C's x::w::create_nonrecursive_visibility_focusframe_impl() and x::w::create_always_visible_focusframe_impl() assemble the implementation object for a standard input focus frame container. They implement two ways of handling the visibility of the focus frame container's contents.

A widget's show() or hide() makes the widget visible or invisible. A container's show_all() and hide_all() recursively updates the visibility of the container itself and everything inside it. This is equivalent to show() or hide() not just for the container itself, but for everything inside it, recursively.

This matters because a given widget is visible not only when it's show()n, but only if all of its parent containers are also show()n. hide()ing a container makes the entire container disappear, even if some widgets in the container are show()n. Each widget maintains its own visibility state, and the final visibility of a given widget requires all of its parent containers to be visible.

The x::w::nonrecursive_visibilityObj template mixin

x::w::create_nonrecursive_visibility_focusframe_impl() uses x::w::nonrecursive_visibilityObj to create the focus frame container's implementation object class. x::w::nonrecursive_visibilityObj is a template mixin that overrides show_all() and hide_all() for the resulting widget. They become equivalent to show() and hide().

This makes the resulting container behave similar to a monolithic widget. Otherwise, a hide_all() followed by show() results in the container being visible, but none of the container's elements being visible. This is because hide_all() hid everything, but show() made only the container visible.

For a simple widget, and not a container, show() and hide() are the same as show_all() and hide_all(). Only containers have other widgets that show_all() and hide_all() affects. This template mixin makes containers look like simple widgets in that respect.

The x::w::nonrecursive_visibilityObj template mixin results in a container that behaves as a monolithic widget, for visibility purposes. hide_all() followed by show() makes the container's contents appear, as if the container is just a single widget, because hide_all() ignored the container's elements in the first place.


New widgets are not visible upon creation, by default. This remains the case. Each widget that gets added to this container should still be show()n (or show_all()ed, perhaps), in order for this to work correctly.

This is why customkeyfocus.C still needs to show() the custom widget after it gets added to a non-recursive visibility input focus frame.

The x::w::always_visibleObj template mixin

x::w::create_always_visible_focusframe_impl() uses the x::w::always_visibleObj to create the focus frame container's implementation object class. x::w::always_visibilityObj is a template mixin that overrides show_all() and hide_all() for the resulting widget.

x::w::always_visibleObj disables show_all() and hide_all() for its container, but only for the container itself. show_all() and hide_all() still apply to all widgets in the container. Additionally, x::w::always_visibleObj automatically show()s the container after it gets created.


Only show_all() and hide_all() get disabled. show() and hide() still have the usual effect on the container.

The x::w::container_visibleObj template mixin

x::w::create_nonrecursive_visibility_focusframe_impl() and x::w::create_always_visible_focusframe_impl() use the x::w::container_visible_elementObj template mixin. LibCXXW automatically provides scroll-bars for the application's window if it's too big to fit on the screen. When that happens, widgets that receive keyboard focus get automatically scrolled into view if they are not fully visible.

This template mixin adjusts the scrolling so that its entire container gets scrolled into view instead of just some widget in the container. The standard input focus frame is a container, and using this template mixin scrolls the entire input focus frame into view, instead of the focusable widget in the container, leaving one edge of the input focus frame scrolled out of view.