清理不需要的代码
This commit is contained in:
parent
2d026313ff
commit
aa926e31fc
cmake
src
@ -90,7 +90,7 @@ function(retrieve_files_custom path extension out_files)
|
||||
|
||||
foreach(dir_name IN LISTS dir_components)
|
||||
# 检查是否是平台相关目录
|
||||
if(dir_name MATCHES "^(windows|linux|mac|ios|android|mobile|desktop)$")
|
||||
if(dir_name MATCHES "^(windows|linux|mac|ios|android|unix|mobile|desktop)$")
|
||||
set(found_platform_dir TRUE)
|
||||
is_current_platform(${dir_name} platform_matches)
|
||||
if(NOT platform_matches)
|
||||
|
@ -1,11 +0,0 @@
|
||||
#include "arranged_children.h"
|
||||
|
||||
#include "widget/mwidget.h"
|
||||
|
||||
void arranged_children::add_widget(const arranged_widget& in_widget_geometry) {
|
||||
add_widget(in_widget_geometry.get_widget()->get_visibility(), in_widget_geometry);
|
||||
}
|
||||
|
||||
void arranged_children::insert_widget(const arranged_widget& in_widget_geometry, size_t in_index) {
|
||||
insert_widget(in_widget_geometry.get_widget()->get_visibility(), in_widget_geometry, in_index);
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
#pragma once
|
||||
/**
|
||||
* @file arranged_children.h
|
||||
* @brief 定义UI组件布局后的几何结构和组织
|
||||
*
|
||||
* 本文件定义了arranged_widget和arranged_children类,用于管理
|
||||
* 已排列的UI组件及其几何关系。这些类在布局系统中用于存储和操作
|
||||
* 组件的位置和大小。
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "geometry.h"
|
||||
#include "misc/mirage_type.h"
|
||||
|
||||
class mwidget;
|
||||
/**
|
||||
* @class arranged_widget
|
||||
* @brief 表示已排列好的单个组件及其几何信息
|
||||
*
|
||||
* arranged_widget将一个UI组件与其对应的几何信息关联起来,
|
||||
* 用于在UI布局系统中跟踪组件的位置和大小。
|
||||
*/
|
||||
class arranged_widget {
|
||||
public:
|
||||
/**
|
||||
* @brief 构造函数
|
||||
* @param in_geometry 组件的几何信息
|
||||
* @param in_widget 组件的共享指针
|
||||
*/
|
||||
arranged_widget(geometry_t in_geometry, std::shared_ptr<mwidget> in_widget) : geometry_(std::move(in_geometry)),
|
||||
widget_(std::move(in_widget)) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取几何信息引用
|
||||
* @return 几何信息的引用
|
||||
*/
|
||||
[[nodiscard]] auto& get_geometry() { return geometry_; }
|
||||
|
||||
/**
|
||||
* @brief 获取几何信息常量引用
|
||||
* @return 几何信息的常量引用
|
||||
*/
|
||||
[[nodiscard]] const auto& get_geometry() const { return geometry_; }
|
||||
|
||||
/**
|
||||
* @brief 获取组件常量引用
|
||||
* @return 组件共享指针的常量引用
|
||||
*/
|
||||
[[nodiscard]] const auto& get_widget() const { return widget_; }
|
||||
|
||||
/**
|
||||
* @brief 设置新的几何信息
|
||||
* @param in_geometry 新的几何信息
|
||||
*/
|
||||
void set_geometry(const geometry_t& in_geometry) { geometry_ = in_geometry; }
|
||||
|
||||
/**
|
||||
* @brief 相等比较操作符
|
||||
* @param in_other 要比较的另一个arranged_widget
|
||||
* @return 如果组件指针相同则返回true
|
||||
*/
|
||||
[[nodiscard]] auto operator==(const arranged_widget& in_other) const {
|
||||
return widget_ == in_other.widget_;
|
||||
}
|
||||
|
||||
private:
|
||||
/** 组件的几何信息 */
|
||||
geometry_t geometry_;
|
||||
|
||||
/** 组件的共享指针 */
|
||||
std::shared_ptr<mwidget> widget_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class arranged_children
|
||||
* @brief 管理一组已排列的子组件
|
||||
*
|
||||
* arranged_children用于存储和管理一组已排列的子组件,提供了添加、插入和
|
||||
* 过滤子组件的功能。它基于可见性属性对子组件进行筛选。
|
||||
*/
|
||||
class arranged_children {
|
||||
public:
|
||||
/**
|
||||
* @brief 构造函数
|
||||
* @param in_visibility_filter 可见性过滤器
|
||||
*
|
||||
* 创建一个具有指定可见性过滤条件的arranged_children实例。
|
||||
*/
|
||||
explicit arranged_children(visibility_t in_visibility_filter = visibility_t::any_visible) : visibility_filter_(in_visibility_filter) {}
|
||||
|
||||
//-------------- 可见性过滤 --------------
|
||||
|
||||
/**
|
||||
* @brief 检查是否接受指定的可见性
|
||||
* @param in_visibility 要检查的可见性
|
||||
* @return 如果该可见性级别被接受则返回true
|
||||
*/
|
||||
[[nodiscard]] auto accepts(visibility_t in_visibility) const {
|
||||
return has_any_flag(in_visibility, visibility_filter_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置可见性过滤器
|
||||
* @param in_visibility_filter 新的可见性过滤级别
|
||||
*/
|
||||
void set_filter(visibility_t in_visibility_filter) {
|
||||
visibility_filter_ = in_visibility_filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加标志到筛选器
|
||||
* @param in_flag 要添加的可见性标志
|
||||
*/
|
||||
void add_filter_flag(visibility_t in_flag) {
|
||||
visibility_filter_ |= in_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 移除筛选器中的标志
|
||||
* @param in_flag 要移除的可见性标志
|
||||
*/
|
||||
void remove_filter_flag(visibility_t in_flag) {
|
||||
visibility_filter_ &= ~in_flag;
|
||||
}
|
||||
|
||||
//-------------- 子项操作 --------------
|
||||
|
||||
/**
|
||||
* @brief 反转子组件的顺序
|
||||
*/
|
||||
void reverse() {
|
||||
std::ranges::reverse(children_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加带有可见性覆盖的组件
|
||||
* @param in_visibility_override 可见性覆盖值
|
||||
* @param in_widget_geometry 要添加的已排列组件
|
||||
*
|
||||
* 根据可见性过滤规则添加组件,只有当可见性满足条件时才会添加。
|
||||
*/
|
||||
void add_widget(visibility_t in_visibility_override, const arranged_widget& in_widget_geometry) {
|
||||
if (accepts(in_visibility_override))
|
||||
children_.push_back(in_widget_geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 在指定位置插入带有可见性覆盖的组件
|
||||
* @param in_visibility_override 可见性覆盖值
|
||||
* @param in_widget_geometry 要插入的已排列组件
|
||||
* @param in_index 插入位置的索引
|
||||
*
|
||||
* 根据可见性过滤规则在指定位置插入组件,只有当可见性满足条件时才会插入。
|
||||
*/
|
||||
void insert_widget(visibility_t in_visibility_override, const arranged_widget& in_widget_geometry, size_t in_index) {
|
||||
if (accepts(in_visibility_override))
|
||||
children_.insert(children_.begin() + in_index, in_widget_geometry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 添加组件
|
||||
* @param in_widget_geometry 要添加的已排列组件
|
||||
*
|
||||
* 使用组件自身的可见性进行添加。
|
||||
*/
|
||||
void add_widget(const arranged_widget& in_widget_geometry);
|
||||
|
||||
/**
|
||||
* @brief 在指定位置插入组件
|
||||
* @param in_widget_geometry 要插入的已排列组件
|
||||
* @param in_index 插入位置的索引
|
||||
*
|
||||
* 使用组件自身的可见性在指定位置进行插入。
|
||||
*/
|
||||
void insert_widget(const arranged_widget& in_widget_geometry, size_t in_index);
|
||||
|
||||
//-------------- 访问器 --------------
|
||||
|
||||
/**
|
||||
* @brief 获取子组件列表的常量引用
|
||||
* @return 子组件列表的常量引用
|
||||
*/
|
||||
[[nodiscard]] const auto& get_children() const { return children_; }
|
||||
|
||||
/**
|
||||
* @brief 获取子组件列表的引用
|
||||
* @return 子组件列表的引用
|
||||
*/
|
||||
[[nodiscard]] auto& get_children() { return children_; }
|
||||
|
||||
private:
|
||||
/** 可见性过滤级别 */
|
||||
visibility_t visibility_filter_;
|
||||
|
||||
/** 子组件列表 */
|
||||
std::vector<arranged_widget> children_;
|
||||
};
|
@ -1 +0,0 @@
|
||||
#include "geometry.h"
|
@ -1,39 +0,0 @@
|
||||
#pragma once
|
||||
#include <Eigen/Eigen>
|
||||
#include <vector>
|
||||
|
||||
#include "layout_transform.h"
|
||||
#include "rect.h"
|
||||
|
||||
class geometry_transformer {
|
||||
public:
|
||||
template<typename T>
|
||||
static auto transform_points(const transform2d& in_transform, const std::vector<Eigen::Vector2<T>>& in_points) {
|
||||
std::vector<Eigen::Vector2<T>> result;
|
||||
result.reserve(in_points.size());
|
||||
|
||||
for (const auto& point : in_points) {
|
||||
result.push_back(in_transform.transform_point(point));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static auto transform_rect(const transform2d& in_transform, const rect_t<T>& in_rect) {
|
||||
// 变换矩形的四个顶点
|
||||
auto top_left = in_transform.transform_point(in_rect.top_left());
|
||||
auto top_right = in_transform.transform_point(in_rect.top_right());
|
||||
auto bottom_left = in_transform.transform_point(in_rect.bottom_left());
|
||||
auto bottom_right = in_transform.transform_point(in_rect.bottom_right());
|
||||
|
||||
// 如果只有平移和缩放(没有旋转),则可以直接计算包围盒
|
||||
if (std::abs(in_transform.get_matrix()(0, 1)) < 1e-6f &&
|
||||
std::abs(in_transform.get_matrix()(1, 0)) < 1e-6f
|
||||
) {
|
||||
auto min = top_left.cwiseMin(top_right).cwiseMin(bottom_left).cwiseMin(bottom_right);
|
||||
auto max = top_left.cwiseMax(top_right).cwiseMax(bottom_left).cwiseMax(bottom_right);
|
||||
return rect_t<T>(min, max - min);
|
||||
}
|
||||
return rect_t<T>::bounding_box({top_left, top_right, bottom_left, bottom_right});
|
||||
}
|
||||
};
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "mwidget.h"
|
||||
#include "geometry/arranged_children.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "misc/mirage_type.h"
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
#include "geometry/arranged_children.h"
|
||||
#include "geometry/geometry.h"
|
||||
#include "misc/invalidate_reason.h"
|
||||
#include "misc/key_type/key_type.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user