Fixing warnings and style.

This commit is contained in:
Ben Vanik 2015-05-09 18:13:19 -07:00
parent 5954d23438
commit 21edd65354
10 changed files with 27 additions and 30 deletions

View File

@ -19,7 +19,8 @@ namespace xe {
namespace ui {
MainWindow::MainWindow(Emulator* emulator)
: PlatformWindow(L"xenia"), emulator_(emulator),
: PlatformWindow(L"xenia"),
emulator_(emulator),
main_menu_(MenuItem::Type::kNormal) {}
MainWindow::~MainWindow() = default;
@ -70,11 +71,12 @@ bool MainWindow::Initialize() {
// FIXME: This code is really messy.
auto file = std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&File");
file->AddChild(std::make_unique<PlatformMenu>(
MenuItem::Type::kString, Commands::IDC_FILE_OPEN, L"&Open"));
MenuItem::Type::kString, Commands::IDC_FILE_OPEN, L"&Open"));
main_menu_.AddChild(std::move(file));
auto debug = std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&Debug");
auto debug =
std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&Debug");
SetMenu(&main_menu_);
@ -89,9 +91,7 @@ void MainWindow::OnClose() {
exit(1);
}
void MainWindow::OnCommand(int id) {
}
void MainWindow::OnCommand(int id) {}
X_STATUS MainWindow::LaunchPath(std::wstring path) {
X_STATUS result;

View File

@ -15,8 +15,8 @@
// TODO(benvanik): only on windows.
#include "xenia/ui/win32/win32_loop.h"
#include "xenia/ui/win32/win32_window.h"
#include "xenia/ui/win32/win32_menu_item.h"
#include "xenia/ui/win32/win32_window.h"
namespace xe {
class Emulator;

View File

@ -14,8 +14,8 @@ namespace ui {
MenuItem::MenuItem(Type type) : type_(type), parent_item_(nullptr) {}
MenuItem::MenuItem(Type type, const std::wstring &text) :
type_(type), parent_item_(nullptr), text_(text) {}
MenuItem::MenuItem(Type type, const std::wstring& text)
: type_(type), parent_item_(nullptr), text_(text) {}
MenuItem::~MenuItem() = default;

View File

@ -24,17 +24,17 @@ class MenuItem {
typedef std::unique_ptr<MenuItem, void (*)(MenuItem*)> MenuItemPtr;
enum class Type {
kPopup, // Popup menu (submenu)
kPopup, // Popup menu (submenu)
kSeparator,
kNormal, // Root menu
kString, // Menu is just a string
kNormal, // Root menu
kString, // Menu is just a string
};
virtual ~MenuItem();
MenuItem* parent_item() const { return parent_item_; }
Type type() { return type_; }
const std::wstring &text() { return text_; }
const std::wstring& text() { return text_; }
void AddChild(MenuItem* child_item);
void AddChild(std::unique_ptr<MenuItem> child_item);
@ -45,7 +45,7 @@ class MenuItem {
protected:
MenuItem(Type type);
MenuItem(Type type, const std::wstring &text);
MenuItem(Type type, const std::wstring& text);
virtual void OnChildAdded(MenuItem* child_item) {}
virtual void OnChildRemoved(MenuItem* child_item) {}
@ -55,7 +55,7 @@ class MenuItem {
Type type_;
MenuItem* parent_item_;
std::vector<MenuItemPtr> children_;
std::wstring text_; // Text associated with this item (typically the title)
std::wstring text_; // Text associated with this item (typically the title)
};
} // namespace ui

View File

@ -182,7 +182,7 @@ LRESULT CALLBACK Win32Control::WndProcThunk(HWND hWnd, UINT message,
if (message == WM_NCCREATE) {
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
control = reinterpret_cast<Win32Control*>(create_struct->lpCreateParams);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (__int3264)(LONG_PTR) control);
SetWindowLongPtr(hWnd, GWLP_USERDATA, (__int3264)(LONG_PTR)control);
} else {
control =
reinterpret_cast<Win32Control*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));

View File

@ -52,7 +52,7 @@ class Win32Control : public Control {
void OnResize(UIEvent& e) override;
static LRESULT CALLBACK
WndProcThunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
WndProcThunk(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam);

View File

@ -27,8 +27,7 @@ Win32MenuItem::Win32MenuItem(Type type, int id, const std::wstring& text)
}
}
Win32MenuItem::Win32MenuItem(Type type)
: Win32MenuItem(type, 0, L"") {}
Win32MenuItem::Win32MenuItem(Type type) : Win32MenuItem(type, 0, L"") {}
Win32MenuItem::Win32MenuItem(Type type, const std::wstring& text)
: Win32MenuItem(type, 0, text) {}
@ -44,8 +43,9 @@ void Win32MenuItem::OnChildAdded(MenuItem* generic_child_item) {
switch (child_item->type()) {
case MenuItem::Type::kPopup:
AppendMenuW(handle_, MF_POPUP, (UINT)child_item->handle(),
child_item->text().c_str());
AppendMenuW(handle_, MF_POPUP,
reinterpret_cast<UINT_PTR>(child_item->handle()),
child_item->text().c_str());
break;
case MenuItem::Type::kSeparator:
AppendMenuW(handle_, MF_SEPARATOR, child_item->id(), 0);

View File

@ -22,8 +22,8 @@ namespace win32 {
class Win32MenuItem : public MenuItem {
public:
Win32MenuItem(Type type);
Win32MenuItem(Type type, const std::wstring &text);
Win32MenuItem(Type type, int id, const std::wstring &text);
Win32MenuItem(Type type, const std::wstring& text);
Win32MenuItem(Type type, int id, const std::wstring& text);
~Win32MenuItem() override;
HMENU handle() { return handle_; }
@ -34,9 +34,8 @@ class Win32MenuItem : public MenuItem {
void OnChildRemoved(MenuItem* child_item) override;
private:
HMENU handle_;
uint32_t position_; // Position within parent, if any
uint32_t position_; // Position within parent, if any
int id_;
};

View File

@ -203,10 +203,8 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA;
case WM_COMMAND: {
OnCommand(LOWORD(wParam));
break;
}
break;
OnCommand(LOWORD(wParam));
} break;
}
return Win32Control::WndProc(hWnd, message, wParam, lParam);

View File

@ -14,8 +14,8 @@
#include "xenia/base/delegate.h"
#include "xenia/ui/control.h"
#include "xenia/ui/ui_event.h"
#include "xenia/ui/menu_item.h"
#include "xenia/ui/ui_event.h"
namespace xe {
namespace ui {