Add ability to debug element trees as JSON

This commit is contained in:
Nathan Sobo 2021-04-06 23:50:13 -06:00
parent 57a3207897
commit 0664321125
25 changed files with 554 additions and 41 deletions

View file

@ -6,10 +6,12 @@ use gpui::{
vector::{vec2f, Vector2F},
PathBuilder,
},
json::{self, ToJson},
text_layout::{self, TextLayoutCache},
AfterLayoutContext, AppContext, Border, Element, Event, EventContext, FontCache, LayoutContext,
PaintContext, Quad, Scene, SizeConstraint, ViewHandle,
};
use json::json;
use smallvec::SmallVec;
use std::cmp::Ordering;
use std::{
@ -477,6 +479,19 @@ impl Element for BufferElement {
false
}
}
fn debug(
&self,
bounds: RectF,
_: &Self::LayoutState,
_: &Self::PaintState,
_: &gpui::DebugContext,
) -> json::Value {
json!({
"type": "BufferElement",
"bounds": bounds.to_json()
})
}
}
pub struct LayoutState {