feat: add fullscreen_window C++ function for ImGui apps
Componente que crea una ventana ImGui fullscreen sin decoraciones, eliminando la necesidad de usar el sistema de ventanas interno. Usado por registry_dashboard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include "core/fullscreen_window.h"
|
||||
#include "imgui.h"
|
||||
|
||||
bool fullscreen_window_begin(const char* id) {
|
||||
const ImGuiViewport* vp = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(vp->WorkPos);
|
||||
ImGui::SetNextWindowSize(vp->WorkSize);
|
||||
return ImGui::Begin(id, nullptr,
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
ImGuiWindowFlags_NoNavFocus);
|
||||
}
|
||||
|
||||
void fullscreen_window_end() {
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
// fullscreen_window — ImGui window that covers the entire viewport.
|
||||
// No title bar, no resize, no move, no collapse. Supports scrolling.
|
||||
//
|
||||
// Usage:
|
||||
// if (fullscreen_window_begin()) {
|
||||
// // render content here
|
||||
// }
|
||||
// fullscreen_window_end(); // ALWAYS call, even if begin returned false
|
||||
//
|
||||
// The default id "##fullscreen" is invisible (## prefix suppresses display).
|
||||
// Use a different id if you need multiple fullscreen windows stacked.
|
||||
|
||||
bool fullscreen_window_begin(const char* id = "##fullscreen");
|
||||
void fullscreen_window_end();
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
name: fullscreen_window
|
||||
kind: component
|
||||
lang: cpp
|
||||
domain: core
|
||||
version: "0.1.0"
|
||||
purity: pure
|
||||
signature: "bool fullscreen_window_begin(const char* id = \"##fullscreen\"); void fullscreen_window_end()"
|
||||
description: "Ventana ImGui fullscreen sin decoraciones que ocupa todo el viewport, elimina la necesidad de usar el sistema de ventanas interno"
|
||||
tags: [imgui, layout, fullscreen, window]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: [imgui]
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "cpp/functions/core/fullscreen_window.cpp"
|
||||
framework: imgui
|
||||
params:
|
||||
- name: id
|
||||
desc: "Identificador ImGui de la ventana, default ##fullscreen (el prefijo ## oculta el texto del titulo)"
|
||||
output: "true si la ventana es visible (siempre true en fullscreen); llamar siempre fullscreen_window_end() independientemente del valor de retorno"
|
||||
---
|
||||
|
||||
# fullscreen_window
|
||||
|
||||
Wrapper que crea una ventana ImGui que ocupa exactamente el viewport de trabajo (`WorkPos` / `WorkSize`). Elimina todas las decoraciones: title bar, resize grip, move, collapse. Ideal como capa raiz de una aplicacion ImGui donde el contenido propio gestiona el layout.
|
||||
|
||||
## Uso
|
||||
|
||||
```cpp
|
||||
if (fullscreen_window_begin()) {
|
||||
// todo el layout de la app va aqui
|
||||
dashboard_grid_begin(3, 8.0f);
|
||||
// ...
|
||||
dashboard_grid_end();
|
||||
}
|
||||
fullscreen_window_end(); // siempre llamar
|
||||
```
|
||||
|
||||
Con ID explicito (si se necesitan multiples capas):
|
||||
|
||||
```cpp
|
||||
if (fullscreen_window_begin("##background")) {
|
||||
render_background();
|
||||
}
|
||||
fullscreen_window_end();
|
||||
```
|
||||
|
||||
## Implementacion
|
||||
|
||||
- `GetMainViewport()` obtiene el viewport principal (compatible con viewports multi-monitor de ImGui)
|
||||
- `SetNextWindowPos(vp->WorkPos)` posiciona en el area de trabajo (excluye menu bars del OS)
|
||||
- `SetNextWindowSize(vp->WorkSize)` ocupa exactamente el area disponible
|
||||
- Flags: `NoTitleBar | NoResize | NoMove | NoCollapse | NoBringToFrontOnFocus | NoNavFocus`
|
||||
- `NoBringToFrontOnFocus` y `NoNavFocus` evitan que la ventana fullscreen robe el foco de ventanas superpuestas
|
||||
|
||||
## Notas
|
||||
|
||||
- Pura en el sentido de que no hace I/O ni tiene estado propio; solo configura el estado next-frame de ImGui.
|
||||
- `WorkPos`/`WorkSize` respetan los menu bars del sistema operativo (en plataformas que los tienen). Para ocupar literalmente toda la pantalla usar `Pos`/`Size` del viewport.
|
||||
- Compatible con `dashboard_grid` y `dashboard_panel`: el fullscreen_window actua como contenedor raiz y los paneles/grids se renderizan dentro.
|
||||
- El patron begin/end es idiomatico en ImGui: `end` debe llamarse siempre para cerrar la ventana correctamente, aunque `begin` retorne false.
|
||||
Reference in New Issue
Block a user