Everywhere: Rename title_bar => titlebar

This commit is contained in:
Andreas Kling 2021-04-18 15:35:57 +02:00
parent 81daca5dd7
commit 12546259ff
9 changed files with 65 additions and 65 deletions

View file

@ -130,8 +130,8 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event)
auto paint_window = [&](auto& title, const Gfx::IntRect& rect, auto state, const Gfx::Bitmap& icon) {
int window_button_width = m_preview_palette.window_title_button_width();
int window_button_height = m_preview_palette.window_title_button_height();
auto title_bar_text_rect = Gfx::WindowTheme::current().title_bar_text_rect(Gfx::WindowTheme::WindowType::Normal, rect, m_preview_palette);
int pos = title_bar_text_rect.right() + 1;
auto titlebar_text_rect = Gfx::WindowTheme::current().titlebar_text_rect(Gfx::WindowTheme::WindowType::Normal, rect, m_preview_palette);
int pos = titlebar_text_rect.right() + 1;
Vector<Button> buttons;
buttons.append(Button { {}, m_close_bitmap });
@ -141,7 +141,7 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event)
for (auto& button : buttons) {
pos -= window_button_width;
Gfx::IntRect rect { pos, 0, window_button_width, window_button_height };
rect.center_vertically_within(title_bar_text_rect);
rect.center_vertically_within(titlebar_text_rect);
button.rect = rect;
}

View file

@ -43,12 +43,12 @@ ClassicWindowTheme::~ClassicWindowTheme()
{
}
Gfx::IntRect ClassicWindowTheme::title_bar_icon_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
Gfx::IntRect ClassicWindowTheme::titlebar_icon_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
{
if (window_type == WindowType::ToolWindow)
return {};
auto titlebar_rect = title_bar_rect(window_type, window_rect, palette);
auto titlebar_rect = this->titlebar_rect(window_type, window_rect, palette);
Gfx::IntRect icon_rect {
titlebar_rect.x() + 2,
titlebar_rect.y(),
@ -60,10 +60,10 @@ Gfx::IntRect ClassicWindowTheme::title_bar_icon_rect(WindowType window_type, con
return icon_rect;
}
Gfx::IntRect ClassicWindowTheme::title_bar_text_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
Gfx::IntRect ClassicWindowTheme::titlebar_text_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
{
auto titlebar_rect = title_bar_rect(window_type, window_rect, palette);
auto titlebar_icon_rect = title_bar_icon_rect(window_type, window_rect, palette);
auto titlebar_rect = this->titlebar_rect(window_type, window_rect, palette);
auto titlebar_icon_rect = this->titlebar_icon_rect(window_type, window_rect, palette);
return {
titlebar_rect.x() + 3 + (titlebar_icon_rect.is_empty() ? 0 : (titlebar_icon_rect.width() + 2)),
titlebar_rect.y(),
@ -80,9 +80,9 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window
auto& title_font = FontDatabase::default_bold_font();
auto titlebar_rect = title_bar_rect(WindowType::Normal, window_rect, palette);
auto titlebar_icon_rect = title_bar_icon_rect(WindowType::Normal, window_rect, palette);
auto titlebar_inner_rect = title_bar_text_rect(WindowType::Normal, window_rect, palette);
auto titlebar_rect = this->titlebar_rect(WindowType::Normal, window_rect, palette);
auto titlebar_icon_rect = this->titlebar_icon_rect(WindowType::Normal, window_rect, palette);
auto titlebar_inner_rect = titlebar_text_rect(WindowType::Normal, window_rect, palette);
auto titlebar_title_rect = titlebar_inner_rect;
titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(title_text));
@ -122,8 +122,8 @@ void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState w
auto& title_font = FontDatabase::default_bold_font();
auto titlebar_rect = title_bar_rect(WindowType::ToolWindow, window_rect, palette);
auto titlebar_inner_rect = title_bar_text_rect(WindowType::ToolWindow, window_rect, palette);
auto titlebar_rect = this->titlebar_rect(WindowType::ToolWindow, window_rect, palette);
auto titlebar_inner_rect = titlebar_text_rect(WindowType::ToolWindow, window_rect, palette);
auto titlebar_title_rect = titlebar_inner_rect;
titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(title_text));
@ -149,13 +149,13 @@ IntRect ClassicWindowTheme::menubar_rect(WindowType window_type, const IntRect&
{
if (window_type != WindowType::Normal)
return {};
return { 4, 3 + title_bar_height(window_type, palette) + 2, window_rect.width(), menubar_height * menu_row_count };
return { 4, 3 + titlebar_height(window_type, palette) + 2, window_rect.width(), menubar_height * menu_row_count };
}
IntRect ClassicWindowTheme::title_bar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
{
auto& title_font = FontDatabase::default_bold_font();
auto window_titlebar_height = title_bar_height(window_type, palette);
auto window_titlebar_height = titlebar_height(window_type, palette);
// FIXME: The top of the titlebar doesn't get redrawn properly if this padding is different
int total_vertical_padding = title_font.glyph_height() - 1;
@ -186,7 +186,7 @@ void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRec
frame_rect.set_location({ 0, 0 });
Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette);
auto titlebar_rect = title_bar_rect(WindowType::Notification, window_rect, palette);
auto titlebar_rect = this->titlebar_rect(WindowType::Notification, window_rect, palette);
painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, titlebar_rect, palette.active_window_border1(), palette.active_window_border2());
if (palette.active_window_title_stripes().alpha() > 0) {
@ -202,7 +202,7 @@ void ClassicWindowTheme::paint_notification_frame(Painter& painter, const IntRec
IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const IntRect& window_rect, const Gfx::Palette& palette, int menu_row_count) const
{
auto window_titlebar_height = title_bar_height(window_type, palette);
auto window_titlebar_height = titlebar_height(window_type, palette);
switch (window_type) {
case WindowType::Normal:
@ -232,28 +232,28 @@ Vector<IntRect> ClassicWindowTheme::layout_buttons(WindowType window_type, const
int pos;
Vector<IntRect> button_rects;
if (window_type == WindowType::Notification)
pos = title_bar_rect(window_type, window_rect, palette).top() + 2;
pos = titlebar_rect(window_type, window_rect, palette).top() + 2;
else
pos = title_bar_text_rect(window_type, window_rect, palette).right() + 1;
pos = titlebar_text_rect(window_type, window_rect, palette).right() + 1;
for (size_t i = 0; i < buttons; i++) {
if (window_type == WindowType::Notification) {
// The button height & width have to be equal or it leaks out of its area
Gfx::IntRect rect { 0, pos, window_button_height, window_button_height };
rect.center_horizontally_within(title_bar_rect(window_type, window_rect, palette));
rect.center_horizontally_within(titlebar_rect(window_type, window_rect, palette));
button_rects.append(rect);
pos += window_button_height;
} else {
pos -= window_button_width;
Gfx::IntRect rect { pos, 0, window_button_width, window_button_height };
rect.center_vertically_within(title_bar_text_rect(window_type, window_rect, palette));
rect.center_vertically_within(titlebar_text_rect(window_type, window_rect, palette));
button_rects.append(rect);
}
}
return button_rects;
}
int ClassicWindowTheme::title_bar_height(WindowType window_type, const Palette& palette) const
int ClassicWindowTheme::titlebar_height(WindowType window_type, const Palette& palette) const
{
auto& title_font = FontDatabase::default_bold_font();
switch (window_type) {

View file

@ -40,10 +40,10 @@ public:
virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, const StringView& title, const Palette&, const IntRect& leftmost_button_rect) const override;
virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const override;
virtual int title_bar_height(WindowType, const Palette&) const override;
virtual IntRect title_bar_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual int titlebar_height(WindowType, const Palette&) const override;
virtual IntRect titlebar_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect titlebar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect titlebar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const override;
virtual IntRect menubar_rect(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const override;

View file

@ -55,10 +55,10 @@ public:
virtual void paint_tool_window_frame(Painter&, WindowState, const IntRect& window_rect, const StringView& title, const Palette&, const IntRect& leftmost_button_rect) const = 0;
virtual void paint_notification_frame(Painter&, const IntRect& window_rect, const Palette&, const IntRect& close_button_rect) const = 0;
virtual int title_bar_height(WindowType, const Palette&) const = 0;
virtual IntRect title_bar_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect title_bar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect title_bar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual int titlebar_height(WindowType, const Palette&) const = 0;
virtual IntRect titlebar_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect titlebar_icon_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect titlebar_text_rect(WindowType, const IntRect& window_rect, const Palette&) const = 0;
virtual IntRect menubar_rect(WindowType, const IntRect& window_rect, const Palette&, int menu_row_count) const = 0;

View file

@ -392,7 +392,7 @@ OwnPtr<Messages::WindowServer::SetWindowIconBitmapResponse> ClientConnection::ha
window.set_default_icon();
}
window.frame().invalidate_title_bar();
window.frame().invalidate_titlebar();
WindowManager::the().tell_wms_window_icon_changed(window);
return make<Messages::WindowServer::SetWindowIconBitmapResponse>();
}

View file

@ -142,7 +142,7 @@ void Window::set_title(const String& title)
if (m_title == title)
return;
m_title = title;
frame().invalidate_title_bar();
frame().invalidate_titlebar();
WindowManager::the().notify_title_changed(*this);
}
@ -760,7 +760,7 @@ Gfx::IntRect Window::tiled_rect(WindowTileType tiled) const
VERIFY(tiled != WindowTileType::None);
int frame_width = (m_frame.rect().width() - m_rect.width()) / 2;
int title_bar_height = m_frame.title_bar_rect().height();
int titlebar_height = m_frame.titlebar_rect().height();
int menu_height = WindowManager::the().maximized_window_rect(*this).y();
int max_height = WindowManager::the().maximized_window_rect(*this).height();
@ -779,32 +779,32 @@ Gfx::IntRect Window::tiled_rect(WindowTileType tiled) const
return Gfx::IntRect(0,
menu_height,
Screen::the().width() - frame_width,
(max_height - title_bar_height) / 2 - frame_width);
(max_height - titlebar_height) / 2 - frame_width);
case WindowTileType::Bottom:
return Gfx::IntRect(0,
menu_height + (title_bar_height + max_height) / 2 + frame_width,
menu_height + (titlebar_height + max_height) / 2 + frame_width,
Screen::the().width() - frame_width,
(max_height - title_bar_height) / 2 - frame_width);
(max_height - titlebar_height) / 2 - frame_width);
case WindowTileType::TopLeft:
return Gfx::IntRect(0,
menu_height,
Screen::the().width() / 2 - frame_width,
(max_height - title_bar_height) / 2 - frame_width);
(max_height - titlebar_height) / 2 - frame_width);
case WindowTileType::TopRight:
return Gfx::IntRect(Screen::the().width() / 2 + frame_width,
menu_height,
Screen::the().width() / 2 - frame_width,
(max_height - title_bar_height) / 2 - frame_width);
(max_height - titlebar_height) / 2 - frame_width);
case WindowTileType::BottomLeft:
return Gfx::IntRect(0,
menu_height + (title_bar_height + max_height) / 2 + frame_width,
menu_height + (titlebar_height + max_height) / 2 + frame_width,
Screen::the().width() / 2 - frame_width,
(max_height - title_bar_height) / 2);
(max_height - titlebar_height) / 2);
case WindowTileType::BottomRight:
return Gfx::IntRect(Screen::the().width() / 2 + frame_width,
menu_height + (title_bar_height + max_height) / 2 + frame_width,
menu_height + (titlebar_height + max_height) / 2 + frame_width,
Screen::the().width() / 2 - frame_width,
(max_height - title_bar_height) / 2);
(max_height - titlebar_height) / 2);
default:
VERIFY_NOT_REACHED();
}

View file

@ -243,19 +243,19 @@ Gfx::IntRect WindowFrame::menubar_rect() const
return Gfx::WindowTheme::current().menubar_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette(), menu_row_count());
}
Gfx::IntRect WindowFrame::title_bar_rect() const
Gfx::IntRect WindowFrame::titlebar_rect() const
{
return Gfx::WindowTheme::current().title_bar_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
return Gfx::WindowTheme::current().titlebar_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
}
Gfx::IntRect WindowFrame::title_bar_icon_rect() const
Gfx::IntRect WindowFrame::titlebar_icon_rect() const
{
return Gfx::WindowTheme::current().title_bar_icon_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
return Gfx::WindowTheme::current().titlebar_icon_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
}
Gfx::IntRect WindowFrame::title_bar_text_rect() const
Gfx::IntRect WindowFrame::titlebar_text_rect() const
{
return Gfx::WindowTheme::current().title_bar_text_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
return Gfx::WindowTheme::current().titlebar_text_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
}
Gfx::WindowTheme::WindowState WindowFrame::window_state_for_theme() const
@ -539,10 +539,10 @@ Gfx::IntRect WindowFrame::render_rect() const
return inflated_for_shadow(rect());
}
void WindowFrame::invalidate_title_bar()
void WindowFrame::invalidate_titlebar()
{
m_dirty = true;
invalidate(title_bar_rect());
invalidate(titlebar_rect());
}
void WindowFrame::invalidate()
@ -636,7 +636,7 @@ void WindowFrame::on_mouse_event(const MouseEvent& event)
if (m_window.blocking_modal_window())
return;
if (title_bar_icon_rect().contains(event.position())) {
if (titlebar_icon_rect().contains(event.position())) {
if (event.type() == Event::MouseDown && (event.button() == MouseButton::Left || event.button() == MouseButton::Right)) {
// Manually start a potential double click. Since we're opening
// a menu, we will only receive the MouseDown event, so we
@ -650,7 +650,7 @@ void WindowFrame::on_mouse_event(const MouseEvent& event)
auto& wm = WindowManager::the();
wm.start_menu_doubleclick(m_window, event);
m_window.popup_window_menu(title_bar_rect().bottom_left().translated(rect().location()), WindowMenuDefaultAction::Close);
m_window.popup_window_menu(titlebar_rect().bottom_left().translated(rect().location()), WindowMenuDefaultAction::Close);
return;
} else if (event.type() == Event::MouseUp && event.button() == MouseButton::Left) {
// Since the MouseDown event opened a menu, another MouseUp
@ -670,10 +670,10 @@ void WindowFrame::on_mouse_event(const MouseEvent& event)
// This is slightly hackish, but expand the title bar rect by two pixels downwards,
// so that mouse events between the title bar and window contents don't act like
// mouse events on the border.
auto adjusted_title_bar_rect = title_bar_rect();
adjusted_title_bar_rect.set_height(adjusted_title_bar_rect.height() + 2);
auto adjusted_titlebar_rect = titlebar_rect();
adjusted_titlebar_rect.set_height(adjusted_titlebar_rect.height() + 2);
if (adjusted_title_bar_rect.contains(event.position())) {
if (adjusted_titlebar_rect.contains(event.position())) {
wm.clear_resize_candidate();
if (event.type() == Event::MouseDown)
@ -778,7 +778,7 @@ void WindowFrame::start_flash_animation()
if (!m_flash_timer) {
m_flash_timer = Core::Timer::construct(100, [this] {
VERIFY(m_flash_counter);
invalidate_title_bar();
invalidate_titlebar();
if (!--m_flash_counter)
m_flash_timer->stop();
});

View file

@ -54,13 +54,13 @@ public:
void render_to_cache();
void on_mouse_event(const MouseEvent&);
void notify_window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect);
void invalidate_title_bar();
void invalidate_titlebar();
void invalidate(Gfx::IntRect relative_rect);
void invalidate();
Gfx::IntRect title_bar_rect() const;
Gfx::IntRect title_bar_icon_rect() const;
Gfx::IntRect title_bar_text_rect() const;
Gfx::IntRect titlebar_rect() const;
Gfx::IntRect titlebar_icon_rect() const;
Gfx::IntRect titlebar_text_rect() const;
Gfx::IntRect menubar_rect() const;
int menu_row_count() const;

View file

@ -1471,8 +1471,8 @@ Gfx::IntRect WindowManager::maximized_window_rect(const Window& window) const
Gfx::IntRect rect = Screen::the().rect();
// Subtract window title bar (leaving the border)
rect.set_y(rect.y() + window.frame().title_bar_rect().height() + window.frame().menubar_rect().height());
rect.set_height(rect.height() - window.frame().title_bar_rect().height() - window.frame().menubar_rect().height());
rect.set_y(rect.y() + window.frame().titlebar_rect().height() + window.frame().menubar_rect().height());
rect.set_height(rect.height() - window.frame().titlebar_rect().height() - window.frame().menubar_rect().height());
// Subtract taskbar window height if present
const_cast<WindowManager*>(this)->for_each_visible_window_of_type_from_back_to_front(WindowType::Taskbar, [&rect](Window& taskbar_window) {
@ -1578,7 +1578,7 @@ void WindowManager::maximize_windows(Window& window, bool maximized)
Gfx::IntPoint WindowManager::get_recommended_window_position(const Gfx::IntPoint& desired)
{
// FIXME: Find a better source for the width and height to shift by.
Gfx::IntPoint shift(8, Gfx::WindowTheme::current().title_bar_height(Gfx::WindowTheme::WindowType::Normal, palette()) + 10);
Gfx::IntPoint shift(8, Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette()) + 10);
// FIXME: Find a better source for this.
int taskbar_height = 28;
@ -1596,7 +1596,7 @@ Gfx::IntPoint WindowManager::get_recommended_window_position(const Gfx::IntPoint
point = overlap_window->position() + shift;
point = { point.x() % Screen::the().width(),
(point.y() >= (Screen::the().height() - taskbar_height))
? Gfx::WindowTheme::current().title_bar_height(Gfx::WindowTheme::WindowType::Normal, palette())
? Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette())
: point.y() };
} else {
point = desired;