53 const uchar border_color[3],
54 const uchar text_color[3],
59 const int fractional_scale[2] = {
64 win_size, fractional_scale, win_state, csd_layout, csd_elems_orig);
66 if (csd_elems_num <= 0) {
70 const rcti window_rect = {
80 border_color[0] / 255.0f, border_color[1] / 255.0f, border_color[2] / 255.0f, 1.0f);
87 csd_elems[i].
bounds[0][0] = 0;
88 csd_elems[i].
bounds[0][1] = 0;
89 csd_elems[i].
bounds[1][0] = 0;
90 csd_elems[i].
bounds[1][1] = 0;
92 for (
int i = 0; i < csd_elems_num; i++) {
94 *elem = csd_elems_orig[i];
101 const rcti title_rect = {
112 const size_t title_len = strlen(title);
116 color[0] =
uchar((
int(border_color[0]) +
int(text_color[0])) / 2);
117 color[1] =
uchar((
int(border_color[1]) +
int(text_color[1])) / 2);
118 color[2] =
uchar((
int(border_color[2]) +
int(text_color[2])) / 2);
121 color[0] = text_color[0] / 2;
122 color[1] = text_color[1] / 2;
123 color[2] = text_color[2] / 2;
130 if (border_color ==
nullptr) {
131 const float shadow_color[4] = {0.0f, 0.0f, 0.0f, alpha};
139 const int title_width =
BLF_width(font_id, title, title_len);
143 const int offset_y = rect_size_y > title_height_max ? (rect_size_y - title_height_max) / 2 : 0;
148 float(title_decender + offset_y) + px_offset,
151 BLF_draw(font_id, title, title_len);
153 if (border_color ==
nullptr) {
160 constexpr int circle_segments = 16;
175 const int button_icons[] = {
183 const int button_margin = rect_size_y / 12;
192 for (
int i = 0; i <
ARRAY_SIZE(button_types); i++) {
197 const rcti butrect = {
203 const int but_radius = (
BLI_rcti_size_x(&butrect) / 2) - button_margin;
204 const int center[2] = {
213 const float button_color[4] = {1.0f, 1.0f, 1.0f, alpha};
216 for (
int i = 0; i <
ARRAY_SIZE(button_types); i++) {
221 const rcti butrect = {
249 const std::string window_title = ghost_window->
getTitle();
250 const char *title = window_title.c_str();
251 const bool is_active = (win->
active != 0);
256 uchar border_color[3], text_color[3];
264 const int font_size = fstyle.
points;
266 const float alpha = 1.0f;
290 if (!ghost_window->hasAlpha()) {
295 const rcti window_rect = {
313 if (!ghost_window->hasAlpha()) {
317 const int fractional_scale[2] = {
319 ghost_window->getDPIHint(),
330 const std::array<int, 4> corner_tiled_edges{
337 std::array<float, 4> radii;
339 radii[corner] = (tiled_edges & corner_tiled_edges[corner]) ? 0.0f :
float(radius);
341 if (std::ranges::all_of(radii, [](
const float value) {
return value == 0.0f; })) {
346 const rcti window_rect = {
356 .xmax =
float(win_size[0]),
358 .ymax =
float(win_size[1]),
361 const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
#define GHOST_CSD_DPI_FRACTIONAL_BASE
@ GHOST_kWindowStateMaximized
@ GHOST_kWindowStateNormal
@ GHOST_kCSDTypeButtonClose
@ GHOST_kCSDTypeButtonMinimize
@ GHOST_kCSDTypeButtonMaximize
@ GHOST_kCSDTypeButtonMenu
#define GHOST_kCSDType_NUM
@ GHOST_kWindowTiledRight
@ GHOST_kWindowTiledBottom
#define GPU_batch_uniform_4fv(batch, name, val)
#define ICON_DEFAULT_HEIGHT
#define ARRAY_SET_ITEMS(...)
virtual std::string getTitle() const =0
virtual uint16_t getDPIHint()=0
constexpr IndexRange()=default
void get_color_3ubv(int colorid, unsigned char col[3])
const uiStyle * style_get_dpi()
void WM_window_csd_draw_titlebar_ex(const int win_size[2], const char win_state, const GHOST_CSD_Layout *csd_layout, const bool is_active, const uint16_t dpi, const char *title, const int font_id, const int font_size, const uchar border_color[3], const uchar text_color[3], const float alpha)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_position(int fontid, float x, float y, float z)
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void GPU_polygon_smooth(bool enable)
void GPU_clear_color(float red, float green, float blue, float alpha)
int WM_window_csd_layout_callback(const int window_size[2], const int fractional_scale[2], const char window_state, const GHOST_CSD_Layout *csd_layout, GHOST_CSD_Elem *csd_elems)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
void wmWindowViewportTitle_ex(const rcti &rect, float offset)
void BLF_draw_svg_icon(uint icon_id, float x, float y, float size, const float color[4]=nullptr, float outline_alpha=1.0f, bool multicolor=false, FunctionRef< void(std::string &)> edit_source_cb=nullptr)
GPUVertFormat * immVertexFormat()
void BLF_disable(int fontid, FontFlags flag)
int WM_window_csd_fractional_scale_apply(int value, const int fractional_scale[2])
@ GPU_BLEND_OVERLAY_MASK_FROM_ALPHA
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void BLF_size(int fontid, float size)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
VecBase< int32_t, 2 > int2
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
@ GPU_SHADER_2D_ROUNDED_CORNER_MASK
@ GPU_SHADER_3D_UNIFORM_COLOR
const GHOST_CSD_Layout * WM_window_csd_layout_get()
void GPU_batch_draw_instance_range(gpu::Batch *batch, int instance_first, int instance_count)
void immUniformColor4f(float r, float g, float b, float a)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void WM_window_csd_draw_corner_mask(const wmWindow *win)
void wm_window_titlebar_theme_context_set(const wmWindow *win, const bScreen *screen)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void WM_window_csd_draw_titlebar(const wmWindow *win)
void GPU_batch_program_set_builtin(gpu::Batch *batch, GPUBuiltinShader shader_id)
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
bool WM_window_is_csd(const wmWindow *win)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
gpu::Batch * GPU_batch_preset_quad()
int2 WM_window_native_pixel_size(const wmWindow *win)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
void GPU_blend(GPUBlend blend)
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
bScreen * WM_window_get_active_screen(const wmWindow *win)
void WM_window_csd_clear_alpha(const wmWindow *win)
void BLF_enable(int fontid, FontFlags flag)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::WindowRuntime * runtime
#define WM_WINDOW_CSD_CORNER_RADIUS