mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
WorkspacePicker: Use full words for some variable names
This patch updates the spelling of "col" to be "column" and "v{col,row}s" to be spelled out as "workspace_{row,column}s".
This commit is contained in:
parent
81bedb5066
commit
b3f8734e22
Notes:
sideshowbarker
2024-07-17 08:38:58 +09:00
Author: https://github.com/networkException Commit: https://github.com/SerenityOS/serenity/commit/b3f8734e22 Pull-request: https://github.com/SerenityOS/serenity/pull/14653
@ -18,18 +18,18 @@ class DesktopStatusWidget : public GUI::Widget {
|
||||
public:
|
||||
virtual ~DesktopStatusWidget() override = default;
|
||||
|
||||
Gfx::IntRect rect_for_desktop(unsigned row, unsigned col) const
|
||||
Gfx::IntRect rect_for_desktop(unsigned row, unsigned column) const
|
||||
{
|
||||
auto& desktop = GUI::Desktop::the();
|
||||
|
||||
auto vcols = desktop.workspace_columns();
|
||||
auto vrows = desktop.workspace_rows();
|
||||
auto workspace_columns = desktop.workspace_columns();
|
||||
auto workspace_rows = desktop.workspace_rows();
|
||||
|
||||
auto desktop_width = (width() - gap() * (vcols - 1)) / vcols;
|
||||
auto desktop_height = (height() - gap() * (vrows - 1)) / vrows;
|
||||
auto desktop_width = (width() - gap() * (workspace_columns - 1)) / workspace_columns;
|
||||
auto desktop_height = (height() - gap() * (workspace_rows - 1)) / workspace_rows;
|
||||
|
||||
return {
|
||||
col * (desktop_width + gap()), row * (desktop_height + gap()),
|
||||
column * (desktop_width + gap()), row * (desktop_height + gap()),
|
||||
desktop_width, desktop_height
|
||||
};
|
||||
}
|
||||
@ -48,9 +48,9 @@ public:
|
||||
auto inactive_color = palette().inactive_window_border1();
|
||||
|
||||
for (unsigned row = 0; row < desktop.workspace_rows(); ++row) {
|
||||
for (unsigned col = 0; col < desktop.workspace_columns(); ++col) {
|
||||
painter.fill_rect(rect_for_desktop(row, col),
|
||||
(row == current_row() && col == current_col()) ? active_color : inactive_color);
|
||||
for (unsigned column = 0; column < desktop.workspace_columns(); ++column) {
|
||||
painter.fill_rect(rect_for_desktop(row, column),
|
||||
(row == current_row() && column == current_column()) ? active_color : inactive_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,36 +59,36 @@ public:
|
||||
{
|
||||
auto base_rect = rect_for_desktop(0, 0);
|
||||
auto row = event.y() / (base_rect.height() + gap());
|
||||
auto col = event.x() / (base_rect.width() + gap());
|
||||
auto column = event.x() / (base_rect.width() + gap());
|
||||
|
||||
// Handle case where divider is clicked.
|
||||
if (rect_for_desktop(row, col).contains(event.position()))
|
||||
GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, col);
|
||||
if (rect_for_desktop(row, column).contains(event.position()))
|
||||
GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, column);
|
||||
}
|
||||
|
||||
virtual void mousewheel_event(GUI::MouseEvent& event) override
|
||||
{
|
||||
auto& desktop = GUI::Desktop::the();
|
||||
|
||||
auto col = current_col();
|
||||
auto column = current_column();
|
||||
auto row = current_row();
|
||||
|
||||
auto vcols = desktop.workspace_columns();
|
||||
auto vrows = desktop.workspace_rows();
|
||||
auto workspace_columns = desktop.workspace_columns();
|
||||
auto workspace_rows = desktop.workspace_rows();
|
||||
auto direction = event.wheel_delta_y() < 0 ? 1 : -1;
|
||||
|
||||
if (event.modifiers() & Mod_Shift)
|
||||
col = abs((int)col + direction) % vcols;
|
||||
column = abs((int)column + direction) % workspace_columns;
|
||||
else
|
||||
row = abs((int)row + direction) % vrows;
|
||||
row = abs((int)row + direction) % workspace_rows;
|
||||
|
||||
GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, col);
|
||||
GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, column);
|
||||
}
|
||||
|
||||
unsigned current_row() const { return m_current_row; }
|
||||
void set_current_row(unsigned row) { m_current_row = row; }
|
||||
unsigned current_col() const { return m_current_col; }
|
||||
void set_current_col(unsigned col) { m_current_col = col; }
|
||||
unsigned current_column() const { return m_current_column; }
|
||||
void set_current_column(unsigned column) { m_current_column = column; }
|
||||
|
||||
unsigned gap() const { return m_gap; }
|
||||
|
||||
@ -98,7 +98,7 @@ private:
|
||||
unsigned m_gap { 1 };
|
||||
|
||||
unsigned m_current_row { 0 };
|
||||
unsigned m_current_col { 0 };
|
||||
unsigned m_current_column { 0 };
|
||||
};
|
||||
|
||||
DesktopStatusWindow::DesktopStatusWindow()
|
||||
@ -122,7 +122,7 @@ void DesktopStatusWindow::wm_event(GUI::WMEvent& event)
|
||||
if (event.type() == GUI::Event::WM_WorkspaceChanged) {
|
||||
auto& changed_event = static_cast<GUI::WMWorkspaceChangedEvent&>(event);
|
||||
m_widget->set_current_row(changed_event.current_row());
|
||||
m_widget->set_current_col(changed_event.current_column());
|
||||
m_widget->set_current_column(changed_event.current_column());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user