wrflib/
component_base.rs

1// Copyright (c) 2021-present, Cruise LLC
2//
3// This source code is licensed under the Apache License, Version 2.0,
4// found in the LICENSE-APACHE file in the root directory of this source tree.
5// You may not use this file except in compliance with the License.
6
7use crate::*;
8
9#[derive(Copy, Clone, Debug, PartialEq)]
10pub(crate) struct ComponentId(u64);
11
12#[derive(Default, Debug)]
13pub struct ComponentBase {
14    pub(crate) id: Option<ComponentId>,
15    pub(crate) area: Area,
16}
17
18impl ComponentBase {
19    pub fn register_component_area(&mut self, cx: &mut Cx, area: Area) {
20        if self.id.is_none() {
21            self.id = Some(ComponentId(cx.next_component_id));
22            cx.next_component_id += 1;
23        }
24        self.area = area;
25    }
26}