Modified the namespace of the UI component

Signed-off-by: jiajia_deng <2894220@gmail.com>
This commit is contained in:
jiajia_deng 2019-09-22 11:08:20 +08:00
parent 93bc30d9e0
commit ad9a6b3edc
41 changed files with 145 additions and 106 deletions

View File

@ -9,18 +9,9 @@
#include "base/thread/framework_thread.h"
#include "base/memory/singleton.h"
/**
* 线 ID 使
*/
enum ThreadIds
{
kThreadMain,
kThreadDatabase,
kThreadGlobalMisc,
};
namespace nbase
{
class MessageLoop;
class MessageLoopProxy;

View File

@ -2,7 +2,7 @@
#include "cef_js_bridge.h"
#include "ipc_string_define.h"
namespace nim_cef {
namespace nim_comp {
CefJSBridge::CefJSBridge()
{
@ -245,7 +245,7 @@ bool CefJSBridge::ExecuteCppCallbackFunc(int cpp_callback_id, const CefString& j
auto callback = it->second;
if (callback)
{
nbase::ThreadManager::PostTask(kThreadMain, [=]() { callback(json_string); });
nbase::ThreadManager::PostTask(kThreadUI, [=]() { callback(json_string); });
}
// 执行完成后从缓存中移除
@ -291,7 +291,7 @@ bool CefJSBridge::ExecuteCppFunc(const CefString& function_name, const CefString
if (it != browser_registered_function_.cend())
{
auto function = it->second;
nbase::ThreadManager::PostTask(kThreadMain, [=]() {
nbase::ThreadManager::PostTask(kThreadUI, [=]() {
function(params, [=](bool has_error, const std::string& json_result) {
// 测试代码,需要封装到管理器中
args->SetInt(0, js_callback_id);
@ -307,7 +307,7 @@ bool CefJSBridge::ExecuteCppFunc(const CefString& function_name, const CefString
if (it != browser_registered_function_.cend())
{
auto function = it->second;
nbase::ThreadManager::PostTask(kThreadMain, [=]() {
nbase::ThreadManager::PostTask(kThreadUI, [=]() {
function(params, [=](bool has_error, const std::string& json_result) {
// 测试代码,需要封装到管理器中
args->SetInt(0, js_callback_id);

View File

@ -2,7 +2,7 @@
#include "include/cef_app.h"
#include "base/memory/singleton.h"
namespace nim_cef
namespace nim_comp
{
typedef std::function<void(bool has_error, const std::string& result)> ReportResultFunction;

View File

@ -9,7 +9,7 @@
#include "cef_control/manager/cef_manager.h"
#include "cef_control/util/util.h"
namespace nim_cef
namespace nim_comp
{
ClientApp::ClientApp()

View File

@ -14,7 +14,7 @@
#include "include/cef_app.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
class ClientApp : public CefApp,
public CefBrowserProcessHandler,

View File

@ -7,7 +7,7 @@
#include "include/cef_v8.h"
#include "cef_control/util/util.h"
namespace nim_cef
namespace nim_comp
{
//////////////////////////////////////////////////////////////////////////////////////////
// CefBrowserProcessHandler methods.

View File

@ -12,7 +12,7 @@
#include "cef_control/app/ipc_string_define.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
//////////////////////////////////////////////////////////////////////////////////////////
// CefRenderProcessHandler methods.

View File

@ -6,7 +6,7 @@
*/
#pragma once
namespace nim_cef
namespace nim_comp
{
static const char kFocusedNodeChangedMessage[] = "FocusedNodeChanged"; // web页面中获取焦点的元素改变
static const char kExecuteCppCallbackMessage[] = "ExecuteCppCallback"; // 执行 C++ 的消息回调函数

View File

@ -4,7 +4,7 @@
#include "cef_control/app/ipc_string_define.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
bool CefJSHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)

View File

@ -9,7 +9,7 @@
#include "include/cef_app.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
class CefJSHandler : public CefV8Handler

View File

@ -2,8 +2,7 @@
#include "cef_control.h"
#include "cef_control/util/util.h"
namespace ui
{
namespace nim_comp {
void CefControl::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const std::string* buffer, int width, int height)
{

View File

@ -8,8 +8,7 @@
#include "cef_control_base.h"
#include "cef_control/util/memory_dc.h"
namespace ui
{
namespace nim_comp {
class CefControl :public CefControlBase, public IUIMessageFilter
{

View File

@ -2,8 +2,7 @@
#include "cef_control_base.h"
#include "cef_control/util/util.h"
namespace ui
{
namespace nim_comp {
void CefControlBase::OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const std::string* buffer, int width, int height)
{

View File

@ -10,10 +10,11 @@
#include "cef_control/app/cef_js_bridge.h"
#include "cef_control/handler/browser_handler.h"
namespace ui
{
namespace nim_comp {
class CefControlBase : public Control, public nim_cef::BrowserHandler::HandlerDelegate
using namespace ui;
class CefControlBase : public Control, public nim_comp::BrowserHandler::HandlerDelegate
{
public:
CefControlBase(void);
@ -123,7 +124,7 @@ public:
* @param[in] global_function
* @return true false
*/
bool RegisterCppFunc(const std::wstring& function_name, nim_cef::CppFunction function, bool global_function = false);
bool RegisterCppFunc(const std::wstring& function_name, nim_comp::CppFunction function, bool global_function = false);
/**
* @brief C++
@ -140,7 +141,7 @@ public:
* @param[in] frame_name frame 使 frame
* @return true false
*/
bool CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_cef::CallJsFunctionCallback callback, const std::wstring& frame_name = L"");
bool CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_comp::CallJsFunctionCallback callback, const std::wstring& frame_name = L"");
/**
* @brief
@ -150,7 +151,7 @@ public:
* @param[in] frame_id ID frame 使 frame
* @return true false
*/
bool CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_cef::CallJsFunctionCallback callback, int frame_id);
bool CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_comp::CallJsFunctionCallback callback, int frame_id);
/**
* @brief
@ -413,8 +414,8 @@ private:
virtual bool OnExecuteCppCallbackFunc(int cpp_callback_id, const CefString& json_string) OVERRIDE;
protected:
CefRefPtr<nim_cef::BrowserHandler> browser_handler_ = nullptr;
std::shared_ptr<nim_cef::CefJSBridge> js_bridge_;
CefRefPtr<nim_comp::BrowserHandler> browser_handler_ = nullptr;
std::shared_ptr<nim_comp::CefJSBridge> js_bridge_;
CefString url_;
bool devtool_attached_;

View File

@ -7,8 +7,7 @@
#include "cef_control/manager/cef_manager.h"
#include "cef_control/app/cef_js_bridge.h"
namespace ui
{
namespace nim_comp {
CefControlBase::CefControlBase(void)
{
@ -179,7 +178,7 @@ CefString CefControlBase::GetMainURL(const CefString& url)
return CefString(temp.c_str());
}
bool CefControlBase::RegisterCppFunc(const std::wstring& function_name, nim_cef::CppFunction function, bool global_function/* = false*/)
bool CefControlBase::RegisterCppFunc(const std::wstring& function_name, nim_comp::CppFunction function, bool global_function/* = false*/)
{
if (browser_handler_.get() && browser_handler_->GetBrowser().get() && js_bridge_.get())
{
@ -197,7 +196,7 @@ void CefControlBase::UnRegisterCppFunc(const std::wstring& function_name)
}
}
bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_cef::CallJsFunctionCallback callback, const std::wstring& frame_name /*= L""*/)
bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_comp::CallJsFunctionCallback callback, const std::wstring& frame_name /*= L""*/)
{
if (browser_handler_.get() && browser_handler_->GetBrowser().get() && js_bridge_.get())
{
@ -215,7 +214,7 @@ bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const
return false;
}
bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_cef::CallJsFunctionCallback callback, int frame_id)
bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const std::wstring& params, nim_comp::CallJsFunctionCallback callback, int frame_id)
{
if (browser_handler_.get() && browser_handler_->GetBrowser().get() && js_bridge_.get())
{

View File

@ -7,13 +7,12 @@
#include "cef_control/manager/cef_manager.h"
#include "cef_control/app/cef_js_bridge.h"
namespace ui
{
namespace
{
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
}
namespace nim_comp {
namespace {
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
}
CefControl::CefControl(void)
{
@ -39,7 +38,7 @@ void CefControl::Init()
{
m_pWindow->AddMessageFilter(this);
browser_handler_ = new nim_cef::BrowserHandler;
browser_handler_ = new nim_comp::BrowserHandler;
browser_handler_->SetHostWindow(m_pWindow->GetHWND());
browser_handler_->SetHandlerDelegate(this);
ReCreateBrowser();
@ -47,7 +46,7 @@ void CefControl::Init()
if (!js_bridge_.get())
{
js_bridge_.reset(new nim_cef::CefJSBridge);
js_bridge_.reset(new nim_comp::CefJSBridge);
}
__super::Init();
@ -280,7 +279,7 @@ bool CefControl::AttachDevTools(Control* control)
{
auto weak = view->GetWeakFlag();
auto task = [this, weak, view](){
nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, weak, view](){
nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this, weak, view](){
if (weak.expired())
return;
AttachDevTools(view);

View File

@ -6,8 +6,7 @@
#include "cef_control/handler/browser_handler.h"
#include "cef_control/manager/cef_manager.h"
namespace ui
{
namespace nim_comp {
CefNativeControl::CefNativeControl(void)
{
@ -33,7 +32,7 @@ void CefNativeControl::Init()
SetWindowLong(m_pWindow->GetHWND(), GWL_STYLE, style | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
ASSERT((GetWindowExStyle(m_pWindow->GetHWND()) & WS_EX_LAYERED) == 0 && L"无法在分层窗口内使用本控件");
browser_handler_ = new nim_cef::BrowserHandler;
browser_handler_ = new nim_comp::BrowserHandler;
browser_handler_->SetHostWindow(m_pWindow->GetHWND());
browser_handler_->SetHandlerDelegate(this);
ReCreateBrowser();
@ -41,7 +40,7 @@ void CefNativeControl::Init()
if (!js_bridge_.get())
{
js_bridge_.reset(new nim_cef::CefJSBridge);
js_bridge_.reset(new nim_comp::CefJSBridge);
}
__super::Init();
@ -151,7 +150,7 @@ bool CefNativeControl::AttachDevTools(Control* /*view*/)
{
auto task = ToWeakCallback([this]()
{
nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this](){
nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this](){
AttachDevTools(nullptr);
}));
});
@ -165,7 +164,7 @@ bool CefNativeControl::AttachDevTools(Control* /*view*/)
CefBrowserSettings settings;
windowInfo.width = 900;
windowInfo.height = 700;
browser->GetHost()->ShowDevTools(windowInfo, new nim_cef::BrowserHandler, settings, CefPoint());
browser->GetHost()->ShowDevTools(windowInfo, new nim_comp::BrowserHandler, settings, CefPoint());
devtool_attached_ = true;
if (cb_devtool_visible_change_ != nullptr)
cb_devtool_visible_change_(devtool_attached_);

View File

@ -7,8 +7,9 @@
#pragma once
#include "cef_control_base.h"
namespace ui
{
namespace nim_comp {
using namespace ui;
class CefNativeControl : public CefControlBase
{

View File

@ -6,7 +6,7 @@
#include "cef_control/app/ipc_string_define.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
BrowserHandler::BrowserHandler()
{
@ -135,7 +135,7 @@ bool BrowserHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
void BrowserHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
REQUIRE_UI_THREAD();
nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, browser](){
nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this, browser](){
browser_list_.emplace_back(browser);
if (browser_ != nullptr)
browser_->GetHost()->WasHidden(true);
@ -167,7 +167,7 @@ bool BrowserHandler::DoClose(CefRefPtr<CefBrowser> browser)
void BrowserHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
REQUIRE_UI_THREAD();
nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, browser](){
nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this, browser](){
CefManager::GetInstance()->SubBrowserCount();
auto it = std::find_if(browser_list_.begin(), browser_list_.end(), [&](const CefRefPtr<CefBrowser>& item){
return item->IsSame(browser);
@ -248,13 +248,13 @@ bool BrowserHandler::GetScreenPoint(CefRefPtr<CefBrowser> browser, int viewX, in
void BrowserHandler::OnPopupShow(CefRefPtr<CefBrowser> browser, bool show)
{
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPopupShow, handle_delegate_, browser, show));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPopupShow, handle_delegate_, browser, show));
}
void BrowserHandler::OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect)
{
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPopupSize, handle_delegate_, browser, rect));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPopupSize, handle_delegate_, browser, rect));
}
void BrowserHandler::OnPaint(CefRefPtr<CefBrowser> browser,
@ -273,7 +273,7 @@ void BrowserHandler::OnPaint(CefRefPtr<CefBrowser> browser,
paint_buffer_.resize(buffer_length + 1);
memcpy(&paint_buffer_[0], (char*)buffer, width * height * 4);
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPaint, handle_delegate_, browser, type, dirtyRects, &paint_buffer_, width, height));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPaint, handle_delegate_, browser, type, dirtyRects, &paint_buffer_, width, height));
}
}
@ -338,14 +338,14 @@ void BrowserHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<Ce
{
// Update the URL in the address bar...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnAddressChange, handle_delegate_, browser, frame, url));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnAddressChange, handle_delegate_, browser, frame, url));
}
void BrowserHandler::OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title)
{
// Update the browser window title...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnTitleChange, handle_delegate_, browser, title));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnTitleChange, handle_delegate_, browser, title));
}
bool BrowserHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString& message, const CefString& source, int line)
@ -360,28 +360,28 @@ void BrowserHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool is
{
// Update UI for browser state...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadingStateChange, handle_delegate_, browser, isLoading, canGoBack, canGoForward));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadingStateChange, handle_delegate_, browser, isLoading, canGoBack, canGoForward));
}
void BrowserHandler::OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
{
// A frame has started loading content...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadStart, handle_delegate_, browser, frame));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadStart, handle_delegate_, browser, frame));
}
void BrowserHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode)
{
// A frame has finished loading content...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadEnd, handle_delegate_, browser, frame, httpStatusCode));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadEnd, handle_delegate_, browser, frame, httpStatusCode));
}
void BrowserHandler::OnLoadError(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl)
{
// A frame has failed to load content...
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadError, handle_delegate_, browser, frame, errorCode, errorText, failedUrl));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadError, handle_delegate_, browser, frame, errorCode, errorText, failedUrl));
}
bool BrowserHandler::OnJSDialog(CefRefPtr<CefBrowser> browser, const CefString& origin_url, const CefString& accept_lang, JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr<CefJSDialogCallback> callback, bool& suppress_message)
@ -424,7 +424,7 @@ CefRequestHandler::ReturnValue BrowserHandler::OnBeforeResourceLoad(
void BrowserHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser, TerminationStatus status)
{
if (handle_delegate_)
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnRenderProcessTerminated, handle_delegate_, browser, status));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnRenderProcessTerminated, handle_delegate_, browser, status));
}

View File

@ -10,7 +10,7 @@
#include "cef_control/util/auto_unregister.h"
#include "cef_control/app/cef_js_bridge.h"
namespace nim_cef
namespace nim_comp
{
// BrowserHandler implements CefClient and a number of other interfaces.
class BrowserHandler :

View File

@ -6,7 +6,7 @@
#include "cef_control/app/client_app.h"
#include "cef_control/handler/browser_handler.h"
namespace nim_cef
namespace nim_comp
{
BOOL CefMessageLoopDispatcher::IsIdleMessage(const MSG* pMsg)
@ -173,7 +173,7 @@ void CefManager::PostQuitMessage(int nExitCode)
// 应该等所有浏览器对象都销毁后再调用::PostQuitMessage
if (browser_count_ == 0)
{
nbase::ThreadManager::PostTask(kThreadMain, [nExitCode]()
nbase::ThreadManager::PostTask(kThreadUI, [nExitCode]()
{
::PostQuitMessage(nExitCode);
});
@ -185,7 +185,7 @@ void CefManager::PostQuitMessage(int nExitCode)
CefManager::GetInstance()->PostQuitMessage(nExitCode);
};
nbase::ThreadManager::PostDelayedTask(kThreadMain, cb, nbase::TimeDelta::FromMilliseconds(500));
nbase::ThreadManager::PostDelayedTask(kThreadUI, cb, nbase::TimeDelta::FromMilliseconds(500));
}
}

View File

@ -7,7 +7,7 @@
#pragma once
#include "include/cef_app.h"
namespace nim_cef
namespace nim_comp
{
/** @class CefMessageLoopDispatcher
* @brief multi_threaded_message_loop为false时Cef的消息循环接口

View File

@ -2,6 +2,8 @@
#include <unordered_map>
typedef std::function<void()> UnregisterCallback;
namespace nim_comp {
class AutoUnregister
{
public:
@ -64,3 +66,5 @@ public:
private:
std::unordered_map<int, std::shared_ptr<TCallback>> element_list_;
};
}

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "ui_menu.h"
namespace ui {
namespace nim_comp {
/////////////////////////////////////////////////////////////////////////////////////
//

View File

@ -3,10 +3,9 @@
#pragma once
namespace ui
{
/////////////////////////////////////////////////////////////////////////////////////
//
namespace nim_comp {
using namespace ui;
enum MenuAlignment
{
@ -56,7 +55,7 @@ public:
};
class ListContainerElement;
class CMenuElementUI : public ListContainerElement
class CMenuElementUI : public ui::ListContainerElement
{
friend CMenuWnd;
public:
@ -66,6 +65,6 @@ public:
virtual bool ButtonUp(EventArgs& msg) override;
};
} // namespace ui
} // namespace nim_comp
#endif // __UIMENU_H__

View File

@ -2,6 +2,8 @@
#include "async_do_modal.h"
#include "async_modal_runner.h"
namespace nim_comp {
bool AsyncDoModal(ModalWndBase *dlg)
{
return AsyncModalRunnerManager::GetInstance()->DoModal(dlg);
@ -11,3 +13,5 @@ void CancelAllAsyncModalDialogs()
{
AsyncModalRunnerManager::GetInstance()->CancelAllThreads();
}
}

View File

@ -3,6 +3,8 @@
#include "modal_wnd_base.h"
namespace nim_comp {
// The function will create a helper thread and run a modal dialog on it.
// Once the modal dialog ended, the thread will be destroyed automatically.
// NOTE: Once this function is called, the ownership of |dlg| will be taken.
@ -13,4 +15,6 @@ bool AsyncDoModal(ModalWndBase *dlg);
// Typically, the function should be called when the application wants to quit.
void CancelAllAsyncModalDialogs();
}
#endif // NIM_WIN_GUI_MSG_BOX_ASYNC_DO_MODAL_H_

View File

@ -4,6 +4,8 @@
#include <algorithm>
namespace nim_comp {
static const char kModalThreadName[] = "AsyncModalRunner";
AsyncModalRunner::AsyncModalRunner(Delegate *delegate)
@ -102,7 +104,7 @@ void AsyncModalRunnerManager::CancelAllThreads()
void AsyncModalRunnerManager::OnThreadWillExit(AsyncModalRunner *runner)
{
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&AsyncModalRunnerManager::Deregister, this, runner));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&AsyncModalRunnerManager::Deregister, this, runner));
}
void AsyncModalRunnerManager::Deregister(AsyncModalRunner *runner)
@ -121,3 +123,5 @@ void AsyncModalRunnerManager::Deregister(AsyncModalRunner *runner)
// If the runner is found,
// it will be destroyed out of the scope of the lock
}
}

View File

@ -18,9 +18,10 @@
#ifndef NIM_WIN_GUI_MSG_BOX_ASYNC_MODAL_RUNNER_H_
#define NIM_WIN_GUI_MSG_BOX_ASYNC_MODAL_RUNNER_H_
#include "modal_wnd_base.h"
namespace nim_comp {
class AsyncModalRunner : protected nbase::Thread
{
public:
@ -76,4 +77,6 @@ private:
std::list<std::shared_ptr<AsyncModalRunner> > runners_;
};
}
#endif //NIM_WIN_GUI_MSG_BOX_ASYNC_MODAL_RUNNER_H_

View File

@ -6,6 +6,8 @@
#include "base/util/string_util.h"
#include "base/file/file_util.h"
namespace nim_comp {
CFileDialogEx::CFileDialogEx(void)
{
memset(&m_szDefExt, 0, sizeof(m_szDefExt));
@ -172,7 +174,7 @@ void CFileDialogEx::SyncShowModal()
if (file_name.size() == 0)
{
StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, file_directory);
nbase::ThreadManager::PostTask(kThreadMain, closure);
nbase::ThreadManager::PostTask(kThreadUI, closure);
}
else
{
@ -182,7 +184,7 @@ void CFileDialogEx::SyncShowModal()
if (nbase::FilePathIsExist(file_path, false))
{
StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, file_path);
nbase::ThreadManager::PostTask(kThreadMain, closure);
nbase::ThreadManager::PostTask(kThreadUI, closure);
}
get_length += file_name.size()+1;
file_name = m_stOFN.lpstrFile + get_length;
@ -192,14 +194,14 @@ void CFileDialogEx::SyncShowModal()
else
{
StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, GetPathName());
nbase::ThreadManager::PostTask(kThreadMain, closure);
nbase::ThreadManager::PostTask(kThreadUI, closure);
}
}
else if (file_dialog_type_ == FDT_SaveFile)
{
BOOL ret = ::GetSaveFileName(&m_stOFN);
StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, GetPathName());
nbase::ThreadManager::PostTask(kThreadMain, closure);
nbase::ThreadManager::PostTask(kThreadUI, closure);
}
else
{
@ -279,3 +281,5 @@ std::wstring CFileDialogEx::GetNextPathName(POSITION& pos)
return strPath;
}
}

View File

@ -5,6 +5,8 @@
#include <commdlg.h>
namespace nim_comp {
struct __POSITION {};
typedef __POSITION* POSITION;
@ -58,4 +60,6 @@ private:
FileDialogCallback2 file_dialog_callback2_;
};
}
#endif //_TOOL_FILE_DIALOGEX_H_

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "msgbox.h"
namespace nim_comp {
using namespace ui;
@ -178,6 +179,8 @@ void MsgBox::EndMsgBox(MsgBoxRet ret)
if (msgbox_callback_)
{
nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(msgbox_callback_, ret));
nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(msgbox_callback_, ret));
}
}
}

View File

@ -1,6 +1,8 @@
#pragma once
#include "duilib/UIlib.h"
namespace nim_comp {
enum MsgBoxRet
{
MB_YES,
@ -57,3 +59,5 @@ private:
MsgboxCallback msgbox_callback_;
};
}

View File

@ -0,0 +1,13 @@
#ifndef _PUBLIC_DEFINE_H_
#define _PUBLIC_DEFINE_H_
namespace nim_comp {
enum ThreadId
{
kThreadUI
};
}
#endif // _PUBLIC_DEFINE_H_

View File

@ -1,7 +1,7 @@
#include "stdafx.h"
#include "shadow_wnd.h"
namespace ui {
namespace nim_comp {
ShadowWnd::ShadowWnd()
{

View File

@ -5,9 +5,9 @@
#include "windows_manager/window_ex.h"
namespace ui {
namespace nim_comp {
using namespace nim_comp;
using namespace ui;
/** @class ShadowWnd
* @brief WS_EX_LAYERED

View File

@ -20,6 +20,9 @@
#include <mutex>
#include <atomic>
// public define
#include "public_define.h"
// base
#include "base/base.h"

View File

@ -3,8 +3,8 @@
using namespace ui;
namespace shared
{
namespace nim_comp {
const LPCTSTR Toast::kClassName = L"Toast";
void Toast::ShowToast(const std::wstring &content, int duration, HWND parent)
@ -90,7 +90,7 @@ void Toast::SetDuration(int duration)
if (duration <= 0)
return;
nbase::ThreadManager::PostDelayedTask(kThreadMain, ToWeakCallback([this]()
nbase::ThreadManager::PostDelayedTask(kThreadUI, ToWeakCallback([this]()
{
this->Close();
}), nbase::TimeDelta::FromMilliseconds(duration));

View File

@ -1,7 +1,6 @@
#pragma once
namespace shared
{
namespace nim_comp {
/** @class Toast
* @brief MessageBox的简化版
* @copyright (c) 2016, NetEase Inc. All rights reserved

View File

@ -107,7 +107,7 @@
</Link>
<Lib>
<AdditionalLibraryDirectories>..\libs\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>nim_libcef_d.lib;libcef_dll_wrapper_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/IGNORE:4006,4221 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -128,7 +128,7 @@
</Link>
<Lib>
<AdditionalLibraryDirectories>..\libs\x64\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>nim_libcef_d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/IGNORE:4006,4221 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -153,7 +153,7 @@
</Link>
<Lib>
<AdditionalLibraryDirectories>..\libs\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>nim_libcef.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/IGNORE:4006,4221 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
@ -178,12 +178,13 @@
</Link>
<Lib>
<AdditionalLibraryDirectories>..\libs\x64\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>nim_libcef.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/IGNORE:4006,4221 %(AdditionalOptions)</AdditionalOptions>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="cef_control\util\auto_unregister.h" />
<ClInclude Include="public_define.h" />
<ClInclude Include="ui_cef_control.h" />
<ClInclude Include="cef_control\app\cef_js_bridge.h" />
<ClInclude Include="cef_control\app\client_app.h" />

View File

@ -132,6 +132,9 @@
<ClInclude Include="cef_control\util\auto_unregister.h">
<Filter>cef_control\util</Filter>
</ClInclude>
<ClInclude Include="public_define.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">