Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T03:35:10.031Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

window_movable.rs

126 lines · 3.5 KB · rust
1#![cfg_attr(target_family = "wasm", no_main)]
2
3use gpui::{
4    App, Bounds, Context, FocusHandle, Window, WindowBounds, WindowOptions, div, prelude::*, px,
5    rgb, size,
6};
7use gpui::{SharedString, TitlebarOptions};
8use gpui_platform::application;
9
10struct ExampleWindow {
11    label: SharedString,
12    focus_handle: FocusHandle,
13}
14
15impl Render for ExampleWindow {
16    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
17        div()
18            .track_focus(&self.focus_handle)
19            .flex()
20            .flex_col()
21            .gap_3()
22            .bg(rgb(0x2e2e2e))
23            .size_full()
24            .justify_center()
25            .items_center()
26            .p_8()
27            .text_lg()
28            .text_color(rgb(0xffffff))
29            .child(self.label.clone())
30            .child(
31                div()
32                    .text_sm()
33                    .text_color(rgb(0xb0b0b0))
34                    .child("Try to drag the titlebar, and check the Window menu."),
35            )
36    }
37}
38
39fn open_test_window(
40    cx: &mut App,
41    bounds: Bounds<gpui::Pixels>,
42    label: &str,
43    is_movable: bool,
44    appears_transparent: bool,
45    app_owns_titlebar_drag: bool,
46) {
47    let label = SharedString::from(format!(
48        "{label}\nis_movable: {is_movable}\n\
49         appears_transparent: {appears_transparent}\n\
50         app_owns_titlebar_drag: {app_owns_titlebar_drag}"
51    ));
52
53    cx.open_window(
54        WindowOptions {
55            window_bounds: Some(WindowBounds::Windowed(bounds)),
56            is_movable,
57            app_owns_titlebar_drag,
58            titlebar: Some(TitlebarOptions {
59                title: Some(label.clone()),
60                appears_transparent,
61                ..Default::default()
62            }),
63            ..Default::default()
64        },
65        |window, cx| {
66            cx.new(|cx| {
67                let focus_handle = cx.focus_handle();
68                focus_handle.focus(window, cx);
69                ExampleWindow {
70                    label,
71                    focus_handle,
72                }
73            })
74        },
75    )
76    .unwrap();
77}
78
79fn run_example() {
80    application().run(|cx: &mut App| {
81        let window_size = size(px(420.), px(280.0));
82        let base = Bounds::centered(None, window_size, cx);
83
84        // (label, is_movable, appears_transparent, app_owns_titlebar_drag, col, row)
85        let windows = [
86            ("Native titlebar, movable", true, false, false, 0.0, 0.0),
87            (
88                "Native titlebar, NOT movable",
89                false,
90                false,
91                false,
92                1.0,
93                0.0,
94            ),
95            ("Custom titlebar, movable", true, true, false, 0.0, 1.0),
96            ("Custom titlebar, NOT movable", false, true, false, 1.0, 1.0),
97        ];
98
99        for (label, is_movable, appears_transparent, app_owns_titlebar_drag, col, row) in windows {
100            let mut bounds = base;
101            bounds.origin.x += window_size.width * col;
102            bounds.origin.y += window_size.height * row;
103            open_test_window(
104                cx,
105                bounds,
106                label,
107                is_movable,
108                appears_transparent,
109                app_owns_titlebar_drag,
110            );
111        }
112    });
113}
114
115#[cfg(not(target_family = "wasm"))]
116fn main() {
117    run_example();
118}
119
120#[cfg(target_family = "wasm")]
121#[wasm_bindgen::prelude::wasm_bindgen(start)]
122pub fn start() {
123    gpui_platform::web_init();
124    run_example();
125}
126
Served at tenant.openagents/omega Member data and write actions are omitted.