mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
Fixing warnings and style.
This commit is contained in:
parent
5954d23438
commit
21edd65354
|
|
@ -19,7 +19,8 @@ namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
MainWindow::MainWindow(Emulator* emulator)
|
MainWindow::MainWindow(Emulator* emulator)
|
||||||
: PlatformWindow(L"xenia"), emulator_(emulator),
|
: PlatformWindow(L"xenia"),
|
||||||
|
emulator_(emulator),
|
||||||
main_menu_(MenuItem::Type::kNormal) {}
|
main_menu_(MenuItem::Type::kNormal) {}
|
||||||
|
|
||||||
MainWindow::~MainWindow() = default;
|
MainWindow::~MainWindow() = default;
|
||||||
|
|
@ -70,11 +71,12 @@ bool MainWindow::Initialize() {
|
||||||
// FIXME: This code is really messy.
|
// FIXME: This code is really messy.
|
||||||
auto file = std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&File");
|
auto file = std::make_unique<PlatformMenu>(MenuItem::Type::kPopup, L"&File");
|
||||||
file->AddChild(std::make_unique<PlatformMenu>(
|
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));
|
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_);
|
SetMenu(&main_menu_);
|
||||||
|
|
||||||
|
|
@ -89,9 +91,7 @@ void MainWindow::OnClose() {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnCommand(int id) {
|
void MainWindow::OnCommand(int id) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
X_STATUS MainWindow::LaunchPath(std::wstring path) {
|
X_STATUS MainWindow::LaunchPath(std::wstring path) {
|
||||||
X_STATUS result;
|
X_STATUS result;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
// TODO(benvanik): only on windows.
|
// TODO(benvanik): only on windows.
|
||||||
#include "xenia/ui/win32/win32_loop.h"
|
#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_menu_item.h"
|
||||||
|
#include "xenia/ui/win32/win32_window.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
class Emulator;
|
class Emulator;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ namespace ui {
|
||||||
|
|
||||||
MenuItem::MenuItem(Type type) : type_(type), parent_item_(nullptr) {}
|
MenuItem::MenuItem(Type type) : type_(type), parent_item_(nullptr) {}
|
||||||
|
|
||||||
MenuItem::MenuItem(Type type, const std::wstring &text) :
|
MenuItem::MenuItem(Type type, const std::wstring& text)
|
||||||
type_(type), parent_item_(nullptr), text_(text) {}
|
: type_(type), parent_item_(nullptr), text_(text) {}
|
||||||
|
|
||||||
MenuItem::~MenuItem() = default;
|
MenuItem::~MenuItem() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,17 @@ class MenuItem {
|
||||||
typedef std::unique_ptr<MenuItem, void (*)(MenuItem*)> MenuItemPtr;
|
typedef std::unique_ptr<MenuItem, void (*)(MenuItem*)> MenuItemPtr;
|
||||||
|
|
||||||
enum class Type {
|
enum class Type {
|
||||||
kPopup, // Popup menu (submenu)
|
kPopup, // Popup menu (submenu)
|
||||||
kSeparator,
|
kSeparator,
|
||||||
kNormal, // Root menu
|
kNormal, // Root menu
|
||||||
kString, // Menu is just a string
|
kString, // Menu is just a string
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~MenuItem();
|
virtual ~MenuItem();
|
||||||
|
|
||||||
MenuItem* parent_item() const { return parent_item_; }
|
MenuItem* parent_item() const { return parent_item_; }
|
||||||
Type type() { return type_; }
|
Type type() { return type_; }
|
||||||
const std::wstring &text() { return text_; }
|
const std::wstring& text() { return text_; }
|
||||||
|
|
||||||
void AddChild(MenuItem* child_item);
|
void AddChild(MenuItem* child_item);
|
||||||
void AddChild(std::unique_ptr<MenuItem> child_item);
|
void AddChild(std::unique_ptr<MenuItem> child_item);
|
||||||
|
|
@ -45,7 +45,7 @@ class MenuItem {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MenuItem(Type type);
|
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 OnChildAdded(MenuItem* child_item) {}
|
||||||
virtual void OnChildRemoved(MenuItem* child_item) {}
|
virtual void OnChildRemoved(MenuItem* child_item) {}
|
||||||
|
|
@ -55,7 +55,7 @@ class MenuItem {
|
||||||
Type type_;
|
Type type_;
|
||||||
MenuItem* parent_item_;
|
MenuItem* parent_item_;
|
||||||
std::vector<MenuItemPtr> children_;
|
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
|
} // namespace ui
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ LRESULT CALLBACK Win32Control::WndProcThunk(HWND hWnd, UINT message,
|
||||||
if (message == WM_NCCREATE) {
|
if (message == WM_NCCREATE) {
|
||||||
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
||||||
control = reinterpret_cast<Win32Control*>(create_struct->lpCreateParams);
|
control = reinterpret_cast<Win32Control*>(create_struct->lpCreateParams);
|
||||||
SetWindowLongPtr(hWnd, GWLP_USERDATA, (__int3264)(LONG_PTR) control);
|
SetWindowLongPtr(hWnd, GWLP_USERDATA, (__int3264)(LONG_PTR)control);
|
||||||
} else {
|
} else {
|
||||||
control =
|
control =
|
||||||
reinterpret_cast<Win32Control*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
reinterpret_cast<Win32Control*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class Win32Control : public Control {
|
||||||
void OnResize(UIEvent& e) override;
|
void OnResize(UIEvent& e) override;
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
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,
|
virtual LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||||
LPARAM lParam);
|
LPARAM lParam);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ Win32MenuItem::Win32MenuItem(Type type, int id, const std::wstring& text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Win32MenuItem::Win32MenuItem(Type type)
|
Win32MenuItem::Win32MenuItem(Type type) : Win32MenuItem(type, 0, L"") {}
|
||||||
: Win32MenuItem(type, 0, L"") {}
|
|
||||||
|
|
||||||
Win32MenuItem::Win32MenuItem(Type type, const std::wstring& text)
|
Win32MenuItem::Win32MenuItem(Type type, const std::wstring& text)
|
||||||
: Win32MenuItem(type, 0, text) {}
|
: Win32MenuItem(type, 0, text) {}
|
||||||
|
|
@ -44,8 +43,9 @@ void Win32MenuItem::OnChildAdded(MenuItem* generic_child_item) {
|
||||||
|
|
||||||
switch (child_item->type()) {
|
switch (child_item->type()) {
|
||||||
case MenuItem::Type::kPopup:
|
case MenuItem::Type::kPopup:
|
||||||
AppendMenuW(handle_, MF_POPUP, (UINT)child_item->handle(),
|
AppendMenuW(handle_, MF_POPUP,
|
||||||
child_item->text().c_str());
|
reinterpret_cast<UINT_PTR>(child_item->handle()),
|
||||||
|
child_item->text().c_str());
|
||||||
break;
|
break;
|
||||||
case MenuItem::Type::kSeparator:
|
case MenuItem::Type::kSeparator:
|
||||||
AppendMenuW(handle_, MF_SEPARATOR, child_item->id(), 0);
|
AppendMenuW(handle_, MF_SEPARATOR, child_item->id(), 0);
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ namespace win32 {
|
||||||
class Win32MenuItem : public MenuItem {
|
class Win32MenuItem : public MenuItem {
|
||||||
public:
|
public:
|
||||||
Win32MenuItem(Type type);
|
Win32MenuItem(Type type);
|
||||||
Win32MenuItem(Type type, const std::wstring &text);
|
Win32MenuItem(Type type, const std::wstring& text);
|
||||||
Win32MenuItem(Type type, int id, const std::wstring &text);
|
Win32MenuItem(Type type, int id, const std::wstring& text);
|
||||||
~Win32MenuItem() override;
|
~Win32MenuItem() override;
|
||||||
|
|
||||||
HMENU handle() { return handle_; }
|
HMENU handle() { return handle_; }
|
||||||
|
|
@ -34,9 +34,8 @@ class Win32MenuItem : public MenuItem {
|
||||||
void OnChildRemoved(MenuItem* child_item) override;
|
void OnChildRemoved(MenuItem* child_item) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HMENU handle_;
|
HMENU handle_;
|
||||||
uint32_t position_; // Position within parent, if any
|
uint32_t position_; // Position within parent, if any
|
||||||
int id_;
|
int id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,10 +203,8 @@ LRESULT Win32Window::WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||||
TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA;
|
TABLET_DISABLE_TOUCHUIFORCEON | TABLET_ENABLE_MULTITOUCHDATA;
|
||||||
|
|
||||||
case WM_COMMAND: {
|
case WM_COMMAND: {
|
||||||
OnCommand(LOWORD(wParam));
|
OnCommand(LOWORD(wParam));
|
||||||
break;
|
} break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Win32Control::WndProc(hWnd, message, wParam, lParam);
|
return Win32Control::WndProc(hWnd, message, wParam, lParam);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
#include "xenia/base/delegate.h"
|
#include "xenia/base/delegate.h"
|
||||||
#include "xenia/ui/control.h"
|
#include "xenia/ui/control.h"
|
||||||
#include "xenia/ui/ui_event.h"
|
|
||||||
#include "xenia/ui/menu_item.h"
|
#include "xenia/ui/menu_item.h"
|
||||||
|
#include "xenia/ui/ui_event.h"
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue