Skip to main content

aylis_core/
lib.rs

1//! # aylis-core
2//!
3//! Núcleo do aylis: modelo de componentes, árvore, propriedades publicadas, layout
4//! (Align, Anchors, Margins, Padding), temas e as interfaces (traits) com a
5//! plataforma.
6//!
7//! Este crate **não depende de nada do sistema operacional**. Janela, input, timers e o
8//! desenho de verdade ficam em crates de plataforma e de renderização, que implementam
9//! os traits definidos aqui ([`Canvas`], [`TextService`], [`platform`]).
10//!
11//! ## Conceitos
12//!
13//! | Conceito | No Aylis |
14//! |---|---|
15//! | Componente | qualquer tipo que implementa [`Component`] |
16//! | Controle visual | um [`Component`] que tem um [`ControlBase`] |
17//! | Estender um componente | composição: o componente guarda o "pai" e devolve em [`Component::inner`] |
18//! | Criar e pôr num pai | [`Ui::add`] / [`Ui::create`] |
19//! | Liberar | [`Ui::free`] (libera os filhos junto) |
20//! | Achar pelo nome | [`Ui::find`] / [`Ui::find_in`] / [`Ui::find_path`] (`"frmClientes.btnSalvar"`) |
21//! | Nomes únicos por form | [`Ui::form_of`]: todo form é um escopo de nomes |
22//! | Abrir, abrir modal e fechar | [`Ui::show`] / [`Ui::show_modal`] (resultado numa função) / [`Ui::close`] |
23//! | Propriedade por nome | [`Ui::set_prop`] / [`Ui::get_prop`] |
24//! | Ligar um evento | [`Ui::on_click`] / [`Ui::on`] ou por nome via [`Ui::register_handler`] |
25
26pub mod activity;
27pub mod automation;
28pub mod background;
29mod busy;
30pub mod align;
31pub mod anim;
32pub mod canvas;
33pub mod clipboard;
34pub mod color;
35pub mod component;
36pub mod devices;
37pub mod error;
38pub mod files;
39pub mod event;
40pub mod event_value;
41pub mod exception;
42pub mod fonts;
43pub mod forms;
44/// Os monitores (lista, área útil, taxa) e a posição guardada de cada form.
45pub mod monitors;
46pub mod ndef;
47mod frames;
48// Repintar só o que mudou.
49mod damage;
50pub use damage::{FrameDamage, ScrollMove};
51mod ink;
52mod trace;
53pub mod handles;
54pub mod instances;
55pub mod geometry;
56pub mod gpu;
57pub mod i18n;
58pub mod icons;
59pub mod image;
60pub mod image_cache;
61pub mod keys;
62pub mod memory_panel;
63pub mod messages;
64mod input;
65mod intercept;
66mod keyflow;
67mod layout;
68pub use layout::is_right_to_left_language;
69pub mod overscroll;
70pub mod orientation;
71pub mod system_bars;
72/// Um form em vários monitores (uma janela por monitor).
73pub mod span;
74pub mod pages;
75pub mod paint;
76pub mod palette;
77pub mod path;
78pub mod date;
79pub mod platform;
80pub mod post;
81pub mod tasks;
82pub mod profile;
83pub mod providers;
84pub mod prop;
85pub mod question;
86pub mod registry;
87mod references;
88mod names;
89mod reveal;
90pub mod text;
91pub mod textcore;
92pub mod textassist;
93pub mod taskbar;
94pub mod theme;
95pub mod bindings;
96pub mod timing;
97pub mod transition;
98pub mod tray;
99pub mod themes;
100mod timers;
101pub mod ui;
102pub mod views;
103pub mod window;
104
105pub use align::{Align, Anchors, SelfAlign};
106pub use i18n::{tr, tr_with};
107pub use anim::{AnimationOptions, ColorAnimation, Easing, FloatAnimation, PropertyAnimation, Trigger};
108pub use canvas::{
109    BlendMode, Brush, Canvas, FontSpec, FontWeight, GpuDevice, GpuSurface, GradientStop, LineCap, LineJoin, Shadow, Stroke, TextAlign,
110    TextService, TextStyle, decorate_line,
111};
112pub use color::Color;
113pub use component::{
114    ArrangeItem, ChildPointer, ClipShape, ColorOverride, Component, ComponentId, Connection, ControlBase, ControlState, DesignHooks, DragDrop, LayoutHooks, Popup, Timed, AccessibleItems, FONT_WEIGHTS, FontOverride, MethodInfo, NativeCommand, NativeView, NativeViewSlot, PlatformHooks, WebMessage, navigation_allowed, url_origin,
115    prop_infos_of, read_prop,
116};
117pub use error::{Error, Result};
118pub use ui::DesignChanged;
119pub use input::{DragEnd, DragVisual, FORM_DRAG, HINT_DELAY, ScreenPointer};
120pub use event::{
121    ClickPointer, EventArgs, EventCtx, GestureEvent, GesturePhase, Intercepted, Key, KeyEvent, Modifiers, PointerButton, PointerEvent, PointerKind,
122    PopupRequest, ScrollOptions, SwipeDirection, SwipeEvent, WHEEL_LINE, WheelEvent,
123};
124pub use forms::{ModalResult, WindowPlacement};
125pub use bindings::Binding;
126pub use timing::TimerPrecision;
127pub use overscroll::Overscroll;
128pub use orientation::{FormOrientation, ScreenOrientation};
129pub use system_bars::{BarIcons, SystemBarsStyle};
130pub use transition::{TRANSITION_MS, Transition};
131pub use taskbar::{JumpTask, TaskbarEvent, TaskbarProgress, TaskbarSpec, ThumbButton};
132pub use tray::{TrayEvent, TrayEventKind, TraySpec};
133pub use window::{ResizeEdge, WINDOW_SETTINGS_CLASS, WindowBackdrop, WindowCommand, WindowOptions};
134pub use geometry::{Bounds, PointF, RectF, SizeF};
135pub use icons::Icon;
136pub use keys::{CharCase, CharFilter, mnemonic, parse_shortcut, shortcut_matches, shortcut_text, strip_mnemonic};
137pub use image::{Image, ImageFit, ImageSource, WeakImage};
138pub use image_cache::{ImageCache, ImageCacheLimits, LayerCache, LayerCaching};
139pub use paint::PaintCtx;
140pub use path::{Path, PathCmd};
141pub use date::{Date, DateTime, Time};
142pub use prop::RecordInfo;
143pub use event_value::{DateRange, EventArg, EventValue, FromSender};
144pub use gpu::FormPresent;
145pub use platform::{Biometry, CursorShape, NotificationPriority, Permission, PermissionState};
146pub use providers::ErrorCorrection;
147pub use post::Poster;
148pub use prop::{PropEnum, PropInfo, PropKind, PropValue};
149pub use registry::{ClassInfo, ClassRegistry, VariantInfo, split_variant};
150pub use text::{TextCase, Trimming};
151pub use theme::{ColorRef, Look, Material, Metric, ResolvedStyle, Style, StyleProps, Theme};
152pub use ui::ThemeSource;
153pub use ui::Ui;
154pub use exception::Exception;
155pub use textcore::TextMode;
156pub use question::{Answer, Asked};
157pub use views::{FormView, ViewChange, ViewOrientation};
158pub use ui::{EVENTS_PER_ROUND, LOOP_WARNING, MAX_EVENT_NESTING, MAX_TREE_DEPTH, SAFE_EVENT_NESTING, SAFE_TREE_DEPTH, is_identifier};
159
160/// Uma linha no stderr, como o `eprintln!`, mas sem entrar em pânico se ele estiver fechado:
161/// um app aberto pela IDE escreve num pipe, e com a IDE fechada (ou a execução parada) o
162/// `eprintln!` derrubava o app ("failed printing to stderr").
163#[macro_export]
164macro_rules! stderr_line {
165    ($($arg:tt)*) => {{
166        use ::std::io::Write as _;
167        let _ = ::std::writeln!(::std::io::stderr(), $($arg)*);
168    }};
169}
170
171/// Implementa `class_name`, `control` e `control_mut` para um controle "folha" (que guarda o
172/// próprio `ControlBase` no campo `base`). Fica no núcleo porque os controles moram em vários
173/// crates (`aylis-controls-base`, `aylis-controls-charts`...).
174#[macro_export]
175macro_rules! leaf_control {
176    ($name:literal) => {
177        fn class_name(&self) -> &'static str {
178            $name
179        }
180
181        fn control(&self) -> Option<&$crate::ControlBase> {
182            Some(&self.base)
183        }
184
185        fn control_mut(&mut self) -> Option<&mut $crate::ControlBase> {
186            Some(&mut self.base)
187        }
188    };
189}