makepad-platform 1.0.0

Makepad platform layer
Documentation
use crate::makepad_micro_serde::*;
use crate::makepad_derive_live::*;
use crate::LiveId;
use crate::action::*;
use crate::log::LogLevel;
// communication enums for studio

#[derive(SerBin, DeBin, Debug)]
pub struct EventSample{
    pub event_u32: u32,
    pub event_meta: u64,
    pub start: f64,
    pub end: f64,
}

#[derive(SerBin, DeBin, Debug)]
pub struct GPUSample{
    pub start: f64,
    pub end: f64,
}

#[derive(SerBin, DeBin, Debug)]
pub struct StudioLogItem{
    pub file_name:String,
    pub line_start: u32,
    pub line_end: u32,
    pub column_start: u32,
    pub column_end: u32,
    pub message: String,
    pub explanation: Option<String>,
    pub level: LogLevel
}

#[derive(SerBin, DeBin, Debug, Clone)]
pub struct JumpToFile{
    pub file_name: String,
    pub line: u32,
    pub column: u32    
}

#[derive(SerBin, DeBin, Debug, Clone)]
pub struct PatchFile{
    pub file_name: String,
    pub line: u32,
    pub column_start: u32,
    pub column_end: u32,
    pub undo_group: u64,
    pub replace: String
}

#[derive(SerBin, DeBin, SerRon, DeRon, Debug, Clone)]
pub struct DesignerComponentPosition{
    pub id: LiveId,
    pub left: f64,
    pub top: f64,
    pub width: f64,
    pub height: f64
}


#[derive(Default, SerBin, DeBin, SerRon, DeRon, Debug, Clone)]
pub struct DesignerZoomPan{
    pub zoom: f64,
    pub pan_x: f64,
    pub pan_y: f64,
}

#[derive(SerBin, DeBin, Debug, Clone)]
pub struct EditFile{
    pub file_name: String,
    pub line_start: u32,
    pub line_end: u32,
    pub column_start: u32,
    pub column_end: u32,
    pub replace: String
}

#[derive(SerBin, DeBin, Debug, Clone)]
pub struct SelectInFile{
    pub file_name: String,
    pub line_start: u32,
    pub line_end: u32,
    pub column_start: u32,
    pub column_end: u32,
}

#[derive(SerBin, DeBin, Debug, Clone)]
pub struct SwapSelection{
    pub s1_file_name: String,
    pub s1_line_start: u32,
    pub s1_line_end: u32,
    pub s1_column_start: u32,
    pub s1_column_end: u32,
    pub s2_file_name: String,
    pub s2_line_start: u32,
    pub s2_line_end: u32,
    pub s2_column_start: u32,
    pub s2_column_end: u32,
}


#[derive(SerBin, DeBin, Debug)]
pub enum AppToStudio{
    LogItem(StudioLogItem),
    EventSample(EventSample),
    GPUSample(GPUSample),
    JumpToFile(JumpToFile),
    SelectInFile(SelectInFile),
    PatchFile(PatchFile),
    DesignerComponentMoved(DesignerComponentPosition),
    DesignerZoomPan(DesignerZoomPan),
    EditFile(EditFile),
    DesignerStarted,
    DesignerFileSelected{
        file_name:String,
    },
    SwapSelection(SwapSelection),
    Screenshot(StudioScreenshotResponse),
    FocusDesign
}

#[derive(SerBin, DeBin, Debug)]
pub struct StudioScreenshotResponse{
    pub request_ids: Vec<u64>,
    pub image: Option<Vec<u8>>,
    pub width: u32,
    pub height: u32
}

#[derive(SerBin, DeBin)]
pub struct AppToStudioVec(pub Vec<AppToStudio>);

#[derive(Debug, Default, SerBin, DeBin)]
pub struct StudioScreenshotRequest{
   pub request_id: u64,
   pub kind_id: u32
}

#[derive(Debug, DefaultNone, SerBin, DeBin)]
pub enum StudioToApp{
    Screenshot(StudioScreenshotRequest),
    KeepAlive,
    LiveChange{
        file_name: String,
        content: String
    },
    DesignerLoadState{
        zoom_pan: DesignerZoomPan,
        positions: Vec<DesignerComponentPosition>
    },
    DesignerSelectFile{
        file_name: String,
    },
    None,
}

#[derive(SerBin, DeBin)]
pub struct StudioToAppVec(pub Vec<StudioToApp>);