mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[client,sdl] show a logo on connection dialog
* Show a icon to indicate the type of message * Show the FreeRDP logo below the icon
This commit is contained in:
@@ -5,14 +5,14 @@ add_executable(freerdp-res2bin
|
|||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
sdl_resource_manager.cpp
|
sdl_resource_manager.cpp
|
||||||
sdl_resource_manager.hpp
|
sdl_resource_manager.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RES_SVG_FILES
|
set(RES_SVG_FILES
|
||||||
${CMAKE_SOURCE_DIR}/resources/FreeRDP_Icon.svg
|
${CMAKE_SOURCE_DIR}/resources/FreeRDP_Icon.svg
|
||||||
${CMAKE_SOURCE_DIR}/resources/error_FILL0_wght400_GRAD0_opsz24.svg
|
${CMAKE_SOURCE_DIR}/resources/icon_info.svg
|
||||||
${CMAKE_SOURCE_DIR}/resources/feedback_FILL0_wght400_GRAD0_opsz24.svg
|
${CMAKE_SOURCE_DIR}/resources/icon_warning.svg
|
||||||
${CMAKE_SOURCE_DIR}/resources/warning_FILL0_wght400_GRAD0_opsz24.svg
|
${CMAKE_SOURCE_DIR}/resources/icon_error.svg
|
||||||
)
|
)
|
||||||
|
|
||||||
set(RES_FONT_FILES
|
set(RES_FONT_FILES
|
||||||
|
|||||||
@@ -26,8 +26,12 @@
|
|||||||
|
|
||||||
static const SDL_Color backgroundcolor = { 0x38, 0x36, 0x35, 0xff };
|
static const SDL_Color backgroundcolor = { 0x38, 0x36, 0x35, 0xff };
|
||||||
static const SDL_Color textcolor = { 0xd1, 0xcf, 0xcd, 0xff };
|
static const SDL_Color textcolor = { 0xd1, 0xcf, 0xcd, 0xff };
|
||||||
|
static const SDL_Color infocolor = { 0x43, 0xe0, 0x0f, 0x60 };
|
||||||
|
static const SDL_Color warncolor = { 0xcd, 0xca, 0x35, 0x60 };
|
||||||
|
static const SDL_Color errorcolor = { 0xf7, 0x22, 0x30, 0x60 };
|
||||||
|
|
||||||
static const Uint32 vpadding = 5;
|
static const Uint32 vpadding = 5;
|
||||||
|
static const Uint32 hpadding = 5;
|
||||||
|
|
||||||
SDLConnectionDialog::SDLConnectionDialog(rdpContext* context)
|
SDLConnectionDialog::SDLConnectionDialog(rdpContext* context)
|
||||||
: _context(context), _window(nullptr), _renderer(nullptr)
|
: _context(context), _window(nullptr), _renderer(nullptr)
|
||||||
@@ -136,7 +140,7 @@ bool SDLConnectionDialog::setModal()
|
|||||||
if (sdl->windows.empty())
|
if (sdl->windows.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto parent = sdl->windows.front().window;
|
auto parent = sdl->windows.front().window();
|
||||||
SDL_SetWindowModalFor(_window, parent);
|
SDL_SetWindowModalFor(_window, parent);
|
||||||
SDL_RaiseWindow(_window);
|
SDL_RaiseWindow(_window);
|
||||||
}
|
}
|
||||||
@@ -166,7 +170,7 @@ bool SDLConnectionDialog::update(SDL_Renderer* renderer)
|
|||||||
|
|
||||||
for (auto& btn : _list)
|
for (auto& btn : _list)
|
||||||
{
|
{
|
||||||
if (!btn.update_text(renderer, _msg, textcolor))
|
if (!btn.widget.update_text(renderer, _msg, btn.fgcolor, btn.bgcolor))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,32 +341,49 @@ bool SDLConnectionDialog::createWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string res_name;
|
std::string res_name;
|
||||||
|
SDL_Color res_bgcolor;
|
||||||
switch (_type_active)
|
switch (_type_active)
|
||||||
{
|
{
|
||||||
case MSG_INFO:
|
case MSG_INFO:
|
||||||
res_name = "feedback_FILL0_wght400_GRAD0_opsz24.svg";
|
res_name = "icon_info.svg";
|
||||||
|
res_bgcolor = infocolor;
|
||||||
break;
|
break;
|
||||||
case MSG_WARN:
|
case MSG_WARN:
|
||||||
res_name = "warning_FILL0_wght400_GRAD0_opsz24.svg";
|
res_name = "icon_warning.svg";
|
||||||
|
res_bgcolor = warncolor;
|
||||||
break;
|
break;
|
||||||
case MSG_ERROR:
|
case MSG_ERROR:
|
||||||
res_name = "error_FILL0_wght400_GRAD0_opsz24.svg";
|
res_name = "icon_error.svg";
|
||||||
|
res_bgcolor = errorcolor;
|
||||||
break;
|
break;
|
||||||
case MSG_DISCARD:
|
case MSG_DISCARD:
|
||||||
default:
|
default:
|
||||||
res_name = "FreeRDP_Icon.svg";
|
res_name = "";
|
||||||
|
res_bgcolor = backgroundcolor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SdlWidget icon = { _renderer,
|
int height = (total_height - 3 * vpadding) / 2;
|
||||||
{ 0, vpadding, widget_width / 4,
|
SDL_Rect iconRect{ hpadding, vpadding, widget_width / 4 - 2 * hpadding, height };
|
||||||
total_height - 3 * vpadding - widget_height },
|
widget_cfg_t icon{ textcolor,
|
||||||
SDLResourceManager::get(SDLResourceManager::typeImages(), res_name) };
|
res_bgcolor,
|
||||||
|
{ _renderer, iconRect,
|
||||||
|
SDLResourceManager::get(SDLResourceManager::typeImages(), res_name) } };
|
||||||
_list.emplace_back(std::move(icon));
|
_list.emplace_back(std::move(icon));
|
||||||
|
|
||||||
|
iconRect.y += height;
|
||||||
|
|
||||||
|
widget_cfg_t logo{ textcolor,
|
||||||
|
backgroundcolor,
|
||||||
|
{ _renderer, iconRect,
|
||||||
|
SDLResourceManager::get(SDLResourceManager::typeImages(),
|
||||||
|
"FreeRDP_Icon.svg") } };
|
||||||
|
_list.emplace_back(std::move(logo));
|
||||||
|
|
||||||
SDL_Rect rect = { widget_width / 4, vpadding, widget_width * 3 / 4,
|
SDL_Rect rect = { widget_width / 4, vpadding, widget_width * 3 / 4,
|
||||||
total_height - 3 * vpadding - widget_height };
|
total_height - 3 * vpadding - widget_height };
|
||||||
auto w = SdlWidget(_renderer, rect, false);
|
widget_cfg_t w{ textcolor, backgroundcolor, { _renderer, rect, false } };
|
||||||
w.set_wrap(true, widget_width);
|
w.widget.set_wrap(true, widget_width);
|
||||||
_list.emplace_back(std::move(w));
|
_list.emplace_back(std::move(w));
|
||||||
rect.y += widget_height + vpadding;
|
rect.y += widget_height + vpadding;
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,14 @@ class SDLConnectionDialog
|
|||||||
private:
|
private:
|
||||||
static Uint32 timeout(Uint32 intervalMS, void* _this);
|
static Uint32 timeout(Uint32 intervalMS, void* _this);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct widget_cfg_t
|
||||||
|
{
|
||||||
|
SDL_Color fgcolor;
|
||||||
|
SDL_Color bgcolor;
|
||||||
|
SdlWidget widget;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rdpContext* _context;
|
rdpContext* _context;
|
||||||
SDL_Window* _window;
|
SDL_Window* _window;
|
||||||
@@ -97,7 +105,7 @@ class SDLConnectionDialog
|
|||||||
MsgType _type_active = MSG_NONE;
|
MsgType _type_active = MSG_NONE;
|
||||||
SDL_TimerID _timer = -1;
|
SDL_TimerID _timer = -1;
|
||||||
bool _running = false;
|
bool _running = false;
|
||||||
std::vector<SdlWidget> _list;
|
std::vector<widget_cfg_t> _list;
|
||||||
SdlButtonList _buttons;
|
SdlButtonList _buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -236,11 +236,6 @@ SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, vo
|
|||||||
auto settings = instance->context->settings;
|
auto settings = instance->context->settings;
|
||||||
const BOOL enabled = freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled);
|
const BOOL enabled = freerdp_settings_get_bool(settings, FreeRDP_AutoReconnectionEnabled);
|
||||||
|
|
||||||
SDL_Window* window = nullptr;
|
|
||||||
if (!sdl->windows.empty())
|
|
||||||
{
|
|
||||||
window = sdl->windows.begin()->window;
|
|
||||||
}
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
{
|
{
|
||||||
sdl->connection_dialog->showError(
|
sdl->connection_dialog->showError(
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 380 B |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 295 B |
Reference in New Issue
Block a user