mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
WindowServer: Allow specifying different shadows for menus and tooltips
Also update the Redmond 2000 theme to drop shadows more Redmond-like.
This commit is contained in:
parent
c9aa7539a6
commit
964894dee6
9 changed files with 49 additions and 17 deletions
BIN
Base/res/icons/themes/Redmond/menu-shadow.png
Normal file
BIN
Base/res/icons/themes/Redmond/menu-shadow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -73,5 +73,6 @@ TitleButtonWidth=15
|
||||||
TitleButtonHeight=15
|
TitleButtonHeight=15
|
||||||
|
|
||||||
[Paths]
|
[Paths]
|
||||||
|
MenuShadow=/res/icons/themes/Default/window-shadow.png
|
||||||
|
TooltipShadow=/res/icons/themes/Default/window-shadow.png
|
||||||
WindowShadow=/res/icons/themes/Default/window-shadow.png
|
WindowShadow=/res/icons/themes/Default/window-shadow.png
|
||||||
|
|
||||||
|
|
|
@ -68,4 +68,6 @@ TitleButtonWidth=17
|
||||||
TitleButtonHeight=15
|
TitleButtonHeight=15
|
||||||
|
|
||||||
[Paths]
|
[Paths]
|
||||||
|
MenuShadow=/res/icons/themes/Redmond/menu-shadow.png
|
||||||
TitleButtonIcons=/res/icons/themes/Redmond/16x16/
|
TitleButtonIcons=/res/icons/themes/Redmond/16x16/
|
||||||
|
TooltipShadow=/res/icons/themes/Redmond/menu-shadow.png
|
||||||
|
|
|
@ -141,6 +141,8 @@ public:
|
||||||
|
|
||||||
String title_button_icons_path() const { return path(PathRole::TitleButtonIcons); }
|
String title_button_icons_path() const { return path(PathRole::TitleButtonIcons); }
|
||||||
String window_shadow_path() const { return path(PathRole::WindowShadow); }
|
String window_shadow_path() const { return path(PathRole::WindowShadow); }
|
||||||
|
String menu_shadow_path() const { return path(PathRole::MenuShadow); }
|
||||||
|
String tooltip_shadow_path() const { return path(PathRole::TooltipShadow); }
|
||||||
|
|
||||||
Color color(ColorRole role) const { return m_impl->color(role); }
|
Color color(ColorRole role) const { return m_impl->color(role); }
|
||||||
int metric(MetricRole role) const { return m_impl->metric(role); }
|
int metric(MetricRole role) const { return m_impl->metric(role); }
|
||||||
|
|
|
@ -119,6 +119,8 @@ Core::AnonymousBuffer load_system_theme(const String& path)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
DO_PATH(TitleButtonIcons);
|
DO_PATH(TitleButtonIcons);
|
||||||
|
DO_PATH(MenuShadow);
|
||||||
|
DO_PATH(TooltipShadow);
|
||||||
DO_PATH(WindowShadow);
|
DO_PATH(WindowShadow);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -145,6 +145,8 @@ enum class PathRole {
|
||||||
NoRole,
|
NoRole,
|
||||||
TitleButtonIcons,
|
TitleButtonIcons,
|
||||||
WindowShadow,
|
WindowShadow,
|
||||||
|
MenuShadow,
|
||||||
|
TooltipShadow,
|
||||||
__Count,
|
__Count,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,12 +56,16 @@ static Gfx::Bitmap* s_minimize_icon;
|
||||||
static Gfx::Bitmap* s_maximize_icon;
|
static Gfx::Bitmap* s_maximize_icon;
|
||||||
static Gfx::Bitmap* s_restore_icon;
|
static Gfx::Bitmap* s_restore_icon;
|
||||||
static Gfx::Bitmap* s_close_icon;
|
static Gfx::Bitmap* s_close_icon;
|
||||||
static Gfx::Bitmap* s_window_shadow;
|
|
||||||
|
|
||||||
static String s_last_title_button_icons_path;
|
static String s_last_title_button_icons_path;
|
||||||
static int s_last_title_button_icons_scale;
|
static int s_last_title_button_icons_scale;
|
||||||
|
|
||||||
|
static Gfx::Bitmap* s_window_shadow;
|
||||||
|
static Gfx::Bitmap* s_menu_shadow;
|
||||||
|
static Gfx::Bitmap* s_tooltip_shadow;
|
||||||
static String s_last_window_shadow_path;
|
static String s_last_window_shadow_path;
|
||||||
|
static String s_last_menu_shadow_path;
|
||||||
|
static String s_last_tooltip_shadow_path;
|
||||||
|
|
||||||
static Gfx::IntRect frame_rect_for_window(Window& window, const Gfx::IntRect& rect)
|
static Gfx::IntRect frame_rect_for_window(Window& window, const Gfx::IntRect& rect)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +115,15 @@ void WindowFrame::set_button_icons()
|
||||||
if (m_window.is_frameless())
|
if (m_window.is_frameless())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_close_button->set_icon(*s_close_icon);
|
||||||
|
if (m_window.is_minimizable())
|
||||||
|
m_minimize_button->set_icon(*s_minimize_icon);
|
||||||
|
if (m_window.is_resizable())
|
||||||
|
m_maximize_button->set_icon(m_window.is_maximized() ? *s_restore_icon : *s_maximize_icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowFrame::reload_config()
|
||||||
|
{
|
||||||
String icons_path = WindowManager::the().palette().title_button_icons_path();
|
String icons_path = WindowManager::the().palette().title_button_icons_path();
|
||||||
int icons_scale = WindowManager::the().compositor_icon_scale();
|
int icons_scale = WindowManager::the().compositor_icon_scale();
|
||||||
|
|
||||||
|
@ -152,30 +165,34 @@ void WindowFrame::set_button_icons()
|
||||||
full_path.clear();
|
full_path.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_close_button->set_icon(*s_close_icon);
|
|
||||||
if (m_window.is_minimizable())
|
|
||||||
m_minimize_button->set_icon(*s_minimize_icon);
|
|
||||||
if (m_window.is_resizable())
|
|
||||||
m_maximize_button->set_icon(m_window.is_maximized() ? *s_restore_icon : *s_maximize_icon);
|
|
||||||
|
|
||||||
s_last_title_button_icons_path = icons_path;
|
s_last_title_button_icons_path = icons_path;
|
||||||
s_last_title_button_icons_scale = icons_scale;
|
s_last_title_button_icons_scale = icons_scale;
|
||||||
|
|
||||||
String window_shadow_path = WindowManager::the().palette().window_shadow_path();
|
auto load_shadow = [](const String& path, String& last_path, Gfx::Bitmap*& shadow_bitmap) {
|
||||||
if (!s_window_shadow || s_window_shadow->scale() != icons_scale || s_last_window_shadow_path != window_shadow_path) {
|
if (!shadow_bitmap || shadow_bitmap->scale() != s_last_title_button_icons_scale || last_path != path) {
|
||||||
s_window_shadow = Gfx::Bitmap::load_from_file(window_shadow_path, icons_scale).leak_ref();
|
shadow_bitmap = Gfx::Bitmap::load_from_file(path, s_last_title_button_icons_scale).leak_ref();
|
||||||
m_shadow_dirty = true;
|
last_path = path;
|
||||||
}
|
}
|
||||||
s_last_window_shadow_path = window_shadow_path;
|
};
|
||||||
|
load_shadow(WindowManager::the().palette().window_shadow_path(), s_last_window_shadow_path, s_window_shadow);
|
||||||
|
load_shadow(WindowManager::the().palette().menu_shadow_path(), s_last_menu_shadow_path, s_menu_shadow);
|
||||||
|
load_shadow(WindowManager::the().palette().tooltip_shadow_path(), s_last_tooltip_shadow_path, s_tooltip_shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::Bitmap* WindowFrame::window_shadow() const
|
Gfx::Bitmap* WindowFrame::window_shadow() const
|
||||||
{
|
{
|
||||||
if (m_window.is_frameless())
|
if (m_window.is_frameless())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (m_window.type() == WindowType::Desktop)
|
switch (m_window.type()) {
|
||||||
|
case WindowType::Desktop:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return s_window_shadow;
|
case WindowType::Menu:
|
||||||
|
return s_menu_shadow;
|
||||||
|
case WindowType::Tooltip:
|
||||||
|
return s_tooltip_shadow;
|
||||||
|
default:
|
||||||
|
return s_window_shadow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowFrame::frame_has_alpha() const
|
bool WindowFrame::frame_has_alpha() const
|
||||||
|
|
|
@ -41,6 +41,8 @@ class Window;
|
||||||
|
|
||||||
class WindowFrame {
|
class WindowFrame {
|
||||||
public:
|
public:
|
||||||
|
static void reload_config();
|
||||||
|
|
||||||
WindowFrame(Window&);
|
WindowFrame(Window&);
|
||||||
~WindowFrame();
|
~WindowFrame();
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,8 @@ void WindowManager::reload_config()
|
||||||
m_drag_cursor = get_cursor("Drag");
|
m_drag_cursor = get_cursor("Drag");
|
||||||
m_wait_cursor = get_cursor("Wait");
|
m_wait_cursor = get_cursor("Wait");
|
||||||
m_crosshair_cursor = get_cursor("Crosshair");
|
m_crosshair_cursor = get_cursor("Crosshair");
|
||||||
|
|
||||||
|
WindowFrame::reload_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Gfx::Font& WindowManager::font() const
|
const Gfx::Font& WindowManager::font() const
|
||||||
|
@ -1434,6 +1436,7 @@ bool WindowManager::update_theme(String theme_path, String theme_name)
|
||||||
m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme);
|
m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme);
|
||||||
Compositor::the().set_background_color(palette().desktop_background().to_string());
|
Compositor::the().set_background_color(palette().desktop_background().to_string());
|
||||||
HashTable<ClientConnection*> notified_clients;
|
HashTable<ClientConnection*> notified_clients;
|
||||||
|
WindowFrame::reload_config();
|
||||||
for_each_window([&](Window& window) {
|
for_each_window([&](Window& window) {
|
||||||
if (window.client()) {
|
if (window.client()) {
|
||||||
if (!notified_clients.contains(window.client())) {
|
if (!notified_clients.contains(window.client())) {
|
||||||
|
@ -1523,9 +1526,10 @@ void WindowManager::reload_icon_bitmaps_after_scale_change(bool allow_hidpi_icon
|
||||||
{
|
{
|
||||||
m_allow_hidpi_icons = allow_hidpi_icons;
|
m_allow_hidpi_icons = allow_hidpi_icons;
|
||||||
reload_config();
|
reload_config();
|
||||||
|
WindowFrame::reload_config();
|
||||||
for_each_window([&](Window& window) {
|
for_each_window([&](Window& window) {
|
||||||
auto& window_frame = window.frame();
|
auto& window_frame = window.frame();
|
||||||
window_frame.set_button_icons();
|
window_frame.theme_changed();
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue