Latest TB changes.

This commit is contained in:
Ben Vanik 2015-07-02 00:23:42 -07:00
parent c13abf3afa
commit fd50209760
6 changed files with 106 additions and 88 deletions

View File

@ -82,14 +82,14 @@ void Application::Quit() {
// This doesn't really belong here (it belongs in tb_system_[linux/windows].cpp. // This doesn't really belong here (it belongs in tb_system_[linux/windows].cpp.
// This is here since the proper implementations has not yet been done. // This is here since the proper implementations has not yet been done.
void tb::TBSystem::RescheduleTimer(uint64_t fire_time) { void tb::TBSystem::RescheduleTimer(uint64_t fire_time) {
if (fire_time == tb::TB_NOT_SOON) { if (fire_time == tb::kNotSoon) {
return; return;
} }
uint64_t now = tb::TBSystem::GetTimeMS(); uint64_t now = tb::TBSystem::GetTimeMS();
uint64_t delay_millis = fire_time >= now ? fire_time - now : 0; uint64_t delay_millis = fire_time >= now ? fire_time - now : 0;
xe::debug::ui::Application::current()->loop()->PostDelayed([]() { xe::debug::ui::Application::current()->loop()->PostDelayed([]() {
uint64_t next_fire_time = tb::TBMessageHandler::GetNextMessageFireTime(); uint64_t next_fire_time = tb::MessageHandler::GetNextMessageFireTime();
uint64_t now = tb::TBSystem::GetTimeMS(); uint64_t now = tb::TBSystem::GetTimeMS();
if (now < next_fire_time) { if (now < next_fire_time) {
// We timed out *before* we were supposed to (the OS is not playing nice). // We timed out *before* we were supposed to (the OS is not playing nice).
@ -99,12 +99,11 @@ void tb::TBSystem::RescheduleTimer(uint64_t fire_time) {
return; return;
} }
tb::TBMessageHandler::ProcessMessages(); tb::MessageHandler::ProcessMessages();
// If we still have things to do (because we didn't process all messages, // If we still have things to do (because we didn't process all messages,
// or because there are new messages), we need to rescedule, so call // or because there are new messages), we need to rescedule, so call
// RescheduleTimer. // RescheduleTimer.
tb::TBSystem::RescheduleTimer( tb::TBSystem::RescheduleTimer(tb::MessageHandler::GetNextMessageFireTime());
tb::TBMessageHandler::GetNextMessageFireTime());
}, delay_millis); }, delay_millis);
} }

View File

@ -9,6 +9,7 @@
#include "xenia/debug/ui/turbo_badger_control.h" #include "xenia/debug/ui/turbo_badger_control.h"
#include "xenia/base/assert.h"
#include "xenia/base/clock.h" #include "xenia/base/clock.h"
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
#include "xenia/debug/ui/turbo_badger_renderer.h" #include "xenia/debug/ui/turbo_badger_renderer.h"
@ -25,7 +26,7 @@ namespace xe {
namespace debug { namespace debug {
namespace ui { namespace ui {
constexpr bool kContinuousRepaint = true; constexpr bool kContinuousRepaint = false;
// Enables long press behaviors (context menu, etc). // Enables long press behaviors (context menu, etc).
constexpr bool kTouch = false; constexpr bool kTouch = false;
@ -35,7 +36,7 @@ constexpr double kDoubleClickDistance = 5;
constexpr int32_t kMouseWheelDetent = 120; constexpr int32_t kMouseWheelDetent = 120;
class RootWidget : public tb::TBWidget { class RootWidget : public tb::Widget {
public: public:
RootWidget(TurboBadgerControl* owner) : owner_(owner) {} RootWidget(TurboBadgerControl* owner) : owner_(owner) {}
void OnInvalid() override { owner_->Invalidate(); } void OnInvalid() override { owner_->Invalidate(); }
@ -44,7 +45,7 @@ class RootWidget : public tb::TBWidget {
TurboBadgerControl* owner_ = nullptr; TurboBadgerControl* owner_ = nullptr;
}; };
bool TurboBadgerControl::InitializeTurboBadger(tb::TBRenderer* renderer) { bool TurboBadgerControl::InitializeTurboBadger(tb::Renderer* renderer) {
static bool has_initialized = false; static bool has_initialized = false;
if (has_initialized) { if (has_initialized) {
return true; return true;
@ -95,7 +96,7 @@ bool TurboBadgerControl::InitializeTurboBadger(tb::TBRenderer* renderer) {
// Set the default font description for widgets to one of the fonts we just // Set the default font description for widgets to one of the fonts we just
// added. // added.
tb::TBFontDescription fd; tb::FontDescription fd;
fd.SetID(TBIDC("Default")); fd.SetID(TBIDC("Default"));
fd.SetSize(tb::g_tb_skin->GetDimensionConverter()->DpToPx(14)); fd.SetSize(tb::g_tb_skin->GetDimensionConverter()->DpToPx(14));
tb::g_font_manager->SetDefaultFontDescription(fd); tb::g_font_manager->SetDefaultFontDescription(fd);
@ -125,18 +126,18 @@ bool TurboBadgerControl::Create() {
return false; return false;
} }
tb::TBWidgetsAnimationManager::Init(); tb::WidgetAnimationManager::Init();
// TODO(benvanik): setup widgets. // TODO(benvanik): setup widgets.
root_widget_ = std::make_unique<RootWidget>(this); root_widget_ = std::make_unique<RootWidget>(this);
root_widget_->SetSkinBg(TBIDC("background")); root_widget_->SetSkinBg(TBIDC("background"));
root_widget_->SetRect(tb::TBRect(0, 0, 1000, 1000)); root_widget_->SetRect(tb::Rect(0, 0, 1000, 1000));
// Block animations during init. // Block animations during init.
tb::TBAnimationBlocker anim_blocker; tb::AnimationBlocker anim_blocker;
// TODO(benvanik): dummy UI. // TODO(benvanik): dummy UI.
auto message_window = new tb::TBMessageWindow(root_widget(), TBIDC("")); auto message_window = new tb::MessageWindow(root_widget(), TBIDC(""));
message_window->Show("Title", "Hello!"); message_window->Show("Title", "Hello!");
// tb::ShowDebugInfoSettingsWindow(root_widget()); // tb::ShowDebugInfoSettingsWindow(root_widget());
@ -145,7 +146,7 @@ bool TurboBadgerControl::Create() {
} }
void TurboBadgerControl::Destroy() { void TurboBadgerControl::Destroy() {
tb::TBWidgetsAnimationManager::Shutdown(); tb::WidgetAnimationManager::Shutdown();
super::Destroy(); super::Destroy();
} }
@ -155,11 +156,14 @@ void TurboBadgerControl::OnLayout(xe::ui::UIEvent& e) {
return; return;
} }
// TODO(benvanik): subregion? // TODO(benvanik): subregion?
root_widget()->SetRect(tb::TBRect(0, 0, width(), height())); root_widget()->SetRect(tb::Rect(0, 0, width(), height()));
} }
void TurboBadgerControl::OnPaint(xe::ui::UIEvent& e) { void TurboBadgerControl::OnPaint(xe::ui::UIEvent& e) {
super::OnPaint(e); super::OnPaint(e);
if (!root_widget()) {
return;
}
++frame_count_; ++frame_count_;
++fps_frame_count_; ++fps_frame_count_;
@ -172,28 +176,28 @@ void TurboBadgerControl::OnPaint(xe::ui::UIEvent& e) {
} }
// Update TB (run animations, handle deferred input, etc). // Update TB (run animations, handle deferred input, etc).
tb::TBAnimationManager::Update(); tb::AnimationManager::Update();
root_widget()->InvokeProcessStates(); root_widget()->InvokeProcessStates();
root_widget()->InvokeProcess(); root_widget()->InvokeProcess();
renderer()->BeginPaint(width(), height()); renderer()->BeginPaint(width(), height());
// Render entire control hierarchy. // Render entire control hierarchy.
root_widget()->InvokePaint(tb::TBWidget::PaintProps()); root_widget()->InvokePaint(tb::Widget::PaintProps());
// Render debug overlay. // Render debug overlay.
root_widget()->GetFont()->DrawString( root_widget()->GetFont()->DrawString(
5, 5, tb::TBColor(255, 0, 0), 5, 5, tb::Color(255, 0, 0),
tb::format_string("Frame %lld", frame_count_)); tb::format_string("Frame %lld", frame_count_));
if (kContinuousRepaint) { if (kContinuousRepaint) {
root_widget()->GetFont()->DrawString(5, 20, tb::TBColor(255, 0, 0), root_widget()->GetFont()->DrawString(5, 20, tb::Color(255, 0, 0),
tb::format_string("FPS: %d", fps_)); tb::format_string("FPS: %d", fps_));
} }
renderer()->EndPaint(); renderer()->EndPaint();
// If animations are running, reinvalidate immediately. // If animations are running, reinvalidate immediately.
if (tb::TBAnimationManager::HasAnimationsRunning()) { if (tb::AnimationManager::HasAnimationsRunning()) {
root_widget()->Invalidate(); root_widget()->Invalidate();
} }
if (kContinuousRepaint) { if (kContinuousRepaint) {
@ -215,109 +219,112 @@ void TurboBadgerControl::OnLostFocus(xe::ui::UIEvent& e) {
last_click_time_ = 0; last_click_time_ = 0;
} }
tb::MODIFIER_KEYS TurboBadgerControl::GetModifierKeys() { tb::ModifierKeys TurboBadgerControl::GetModifierKeys() {
auto modifiers = tb::TB_MODIFIER_NONE; auto modifiers = tb::ModifierKeys::kNone;
if (modifier_shift_pressed_) { if (modifier_shift_pressed_) {
modifiers |= tb::MODIFIER_KEYS::TB_SHIFT; modifiers |= tb::ModifierKeys::kShift;
} }
if (modifier_cntrl_pressed_) { if (modifier_cntrl_pressed_) {
modifiers |= tb::MODIFIER_KEYS::TB_CTRL; modifiers |= tb::ModifierKeys::kCtrl;
} }
if (modifier_alt_pressed_) { if (modifier_alt_pressed_) {
modifiers |= tb::MODIFIER_KEYS::TB_ALT; modifiers |= tb::ModifierKeys::kAlt;
} }
if (modifier_super_pressed_) { if (modifier_super_pressed_) {
modifiers |= tb::MODIFIER_KEYS::TB_SUPER; modifiers |= tb::ModifierKeys::kSuper;
} }
return modifiers; return modifiers;
} }
void TurboBadgerControl::OnKeyPress(xe::ui::KeyEvent& e, bool is_down) { void TurboBadgerControl::OnKeyPress(xe::ui::KeyEvent& e, bool is_down) {
tb::SPECIAL_KEY special_key = tb::SPECIAL_KEY::TB_KEY_UNDEFINED; if (!root_widget()) {
return;
}
auto special_key = tb::SpecialKey::kUndefined;
switch (e.key_code()) { switch (e.key_code()) {
case 38: case 38:
special_key = tb::SPECIAL_KEY::TB_KEY_UP; special_key = tb::SpecialKey::kUp;
break; break;
case 39: case 39:
special_key = tb::SPECIAL_KEY::TB_KEY_RIGHT; special_key = tb::SpecialKey::kRight;
break; break;
case 40: case 40:
special_key = tb::SPECIAL_KEY::TB_KEY_DOWN; special_key = tb::SpecialKey::kDown;
break; break;
case 37: case 37:
special_key = tb::SPECIAL_KEY::TB_KEY_LEFT; special_key = tb::SpecialKey::kLeft;
break; break;
case 112: case 112:
special_key = tb::SPECIAL_KEY::TB_KEY_F1; special_key = tb::SpecialKey::kF1;
break; break;
case 113: case 113:
special_key = tb::SPECIAL_KEY::TB_KEY_F2; special_key = tb::SpecialKey::kF2;
break; break;
case 114: case 114:
special_key = tb::SPECIAL_KEY::TB_KEY_F3; special_key = tb::SpecialKey::kF3;
break; break;
case 115: case 115:
special_key = tb::SPECIAL_KEY::TB_KEY_F4; special_key = tb::SpecialKey::kF4;
break; break;
case 116: case 116:
special_key = tb::SPECIAL_KEY::TB_KEY_F5; special_key = tb::SpecialKey::kF5;
break; break;
case 117: case 117:
special_key = tb::SPECIAL_KEY::TB_KEY_F6; special_key = tb::SpecialKey::kF6;
break; break;
case 118: case 118:
special_key = tb::SPECIAL_KEY::TB_KEY_F7; special_key = tb::SpecialKey::kF7;
break; break;
case 119: case 119:
special_key = tb::SPECIAL_KEY::TB_KEY_F8; special_key = tb::SpecialKey::kF8;
break; break;
case 120: case 120:
special_key = tb::SPECIAL_KEY::TB_KEY_F9; special_key = tb::SpecialKey::kF9;
break; break;
case 121: case 121:
special_key = tb::SPECIAL_KEY::TB_KEY_F10; special_key = tb::SpecialKey::kF10;
break; break;
case 122: case 122:
special_key = tb::SPECIAL_KEY::TB_KEY_F11; special_key = tb::SpecialKey::kF11;
break; break;
case 123: case 123:
special_key = tb::SPECIAL_KEY::TB_KEY_F12; special_key = tb::SpecialKey::kF12;
break; break;
case 33: case 33:
special_key = tb::SPECIAL_KEY::TB_KEY_PAGE_UP; special_key = tb::SpecialKey::kPageUp;
break; break;
case 34: case 34:
special_key = tb::SPECIAL_KEY::TB_KEY_PAGE_DOWN; special_key = tb::SpecialKey::kPageDown;
break; break;
case 36: case 36:
special_key = tb::SPECIAL_KEY::TB_KEY_HOME; special_key = tb::SpecialKey::kHome;
break; break;
case 35: case 35:
special_key = tb::SPECIAL_KEY::TB_KEY_END; special_key = tb::SpecialKey::kEnd;
break; break;
case 45: case 45:
special_key = tb::SPECIAL_KEY::TB_KEY_INSERT; special_key = tb::SpecialKey::kInsert;
break; break;
case 9: case 9:
special_key = tb::SPECIAL_KEY::TB_KEY_TAB; special_key = tb::SpecialKey::kTab;
break; break;
case 46: case 46:
special_key = tb::SPECIAL_KEY::TB_KEY_DELETE; special_key = tb::SpecialKey::kDelete;
break; break;
case 8: case 8:
special_key = tb::SPECIAL_KEY::TB_KEY_BACKSPACE; special_key = tb::SpecialKey::kBackspace;
break; break;
case 13: case 13:
special_key = tb::SPECIAL_KEY::TB_KEY_ENTER; special_key = tb::SpecialKey::kEnter;
break; break;
case 27: case 27:
special_key = tb::SPECIAL_KEY::TB_KEY_ESC; special_key = tb::SpecialKey::kEsc;
break; break;
case 93: case 93:
if (!is_down && tb::TBWidget::focused_widget) { if (!is_down && tb::Widget::focused_widget) {
tb::TBWidgetEvent ev(tb::EVENT_TYPE_CONTEXT_MENU); tb::WidgetEvent ev(tb::EventType::kContextMenu);
ev.modifierkeys = GetModifierKeys(); ev.modifierkeys = GetModifierKeys();
tb::TBWidget::focused_widget->InvokeEvent(ev); tb::Widget::focused_widget->InvokeEvent(ev);
e.set_handled(true); e.set_handled(true);
return; return;
} }
@ -339,16 +346,16 @@ void TurboBadgerControl::OnKeyPress(xe::ui::KeyEvent& e, bool is_down) {
if (!CheckShortcutKey(e, special_key, is_down)) { if (!CheckShortcutKey(e, special_key, is_down)) {
e.set_handled(root_widget()->InvokeKey( e.set_handled(root_widget()->InvokeKey(
special_key != tb::SPECIAL_KEY::TB_KEY_UNDEFINED ? e.key_code() : 0, special_key != tb::SpecialKey::kUndefined ? e.key_code() : 0,
special_key, GetModifierKeys(), is_down)); special_key, GetModifierKeys(), is_down));
} }
} }
bool TurboBadgerControl::CheckShortcutKey(xe::ui::KeyEvent& e, bool TurboBadgerControl::CheckShortcutKey(xe::ui::KeyEvent& e,
tb::SPECIAL_KEY special_key, tb::SpecialKey special_key,
bool is_down) { bool is_down) {
bool shortcut_key = modifier_cntrl_pressed_; bool shortcut_key = modifier_cntrl_pressed_;
if (!tb::TBWidget::focused_widget || !is_down || !shortcut_key) { if (!tb::Widget::focused_widget || !is_down || !shortcut_key) {
return false; return false;
} }
bool reverse_key = modifier_shift_pressed_; bool reverse_key = modifier_shift_pressed_;
@ -359,10 +366,10 @@ bool TurboBadgerControl::CheckShortcutKey(xe::ui::KeyEvent& e,
tb::TBID id; tb::TBID id;
if (upper_key == 'X') { if (upper_key == 'X') {
id = TBIDC("cut"); id = TBIDC("cut");
} else if (upper_key == 'C' || special_key == tb::TB_KEY_INSERT) { } else if (upper_key == 'C' || special_key == tb::SpecialKey::kInsert) {
id = TBIDC("copy"); id = TBIDC("copy");
} else if (upper_key == 'V' || } else if (upper_key == 'V' ||
(special_key == tb::TB_KEY_INSERT && reverse_key)) { (special_key == tb::SpecialKey::kInsert && reverse_key)) {
id = TBIDC("paste"); id = TBIDC("paste");
} else if (upper_key == 'A') { } else if (upper_key == 'A') {
id = TBIDC("selectall"); id = TBIDC("selectall");
@ -380,18 +387,18 @@ bool TurboBadgerControl::CheckShortcutKey(xe::ui::KeyEvent& e,
id = TBIDC("save"); id = TBIDC("save");
} else if (upper_key == 'W') { } else if (upper_key == 'W') {
id = TBIDC("close"); id = TBIDC("close");
} else if (special_key == tb::TB_KEY_PAGE_UP) { } else if (special_key == tb::SpecialKey::kPageUp) {
id = TBIDC("prev_doc"); id = TBIDC("prev_doc");
} else if (special_key == tb::TB_KEY_PAGE_DOWN) { } else if (special_key == tb::SpecialKey::kPageDown) {
id = TBIDC("next_doc"); id = TBIDC("next_doc");
} else { } else {
return false; return false;
} }
tb::TBWidgetEvent ev(tb::EVENT_TYPE_SHORTCUT); tb::WidgetEvent ev(tb::EventType::kShortcut);
ev.modifierkeys = GetModifierKeys(); ev.modifierkeys = GetModifierKeys();
ev.ref_id = id; ev.ref_id = id;
if (!tb::TBWidget::focused_widget->InvokeEvent(ev)) { if (!tb::Widget::focused_widget->InvokeEvent(ev)) {
return false; return false;
} }
e.set_handled(true); e.set_handled(true);
@ -410,6 +417,9 @@ void TurboBadgerControl::OnKeyUp(xe::ui::KeyEvent& e) {
void TurboBadgerControl::OnMouseDown(xe::ui::MouseEvent& e) { void TurboBadgerControl::OnMouseDown(xe::ui::MouseEvent& e) {
super::OnMouseDown(e); super::OnMouseDown(e);
if (!root_widget()) {
return;
}
// TODO(benvanik): more button types. // TODO(benvanik): more button types.
if (e.button() == xe::ui::MouseEvent::Button::kLeft) { if (e.button() == xe::ui::MouseEvent::Button::kLeft) {
// Simulated click count support. // Simulated click count support.
@ -437,24 +447,30 @@ void TurboBadgerControl::OnMouseDown(xe::ui::MouseEvent& e) {
void TurboBadgerControl::OnMouseMove(xe::ui::MouseEvent& e) { void TurboBadgerControl::OnMouseMove(xe::ui::MouseEvent& e) {
super::OnMouseMove(e); super::OnMouseMove(e);
if (!root_widget()) {
return;
}
root_widget()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch); root_widget()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch);
e.set_handled(true); e.set_handled(true);
} }
void TurboBadgerControl::OnMouseUp(xe::ui::MouseEvent& e) { void TurboBadgerControl::OnMouseUp(xe::ui::MouseEvent& e) {
super::OnMouseUp(e); super::OnMouseUp(e);
if (!root_widget()) {
return;
}
if (e.button() == xe::ui::MouseEvent::Button::kLeft) { if (e.button() == xe::ui::MouseEvent::Button::kLeft) {
e.set_handled(root_widget()->InvokePointerUp(e.x(), e.y(), e.set_handled(root_widget()->InvokePointerUp(e.x(), e.y(),
GetModifierKeys(), kTouch)); GetModifierKeys(), kTouch));
} else if (e.button() == xe::ui::MouseEvent::Button::kRight) { } else if (e.button() == xe::ui::MouseEvent::Button::kRight) {
root_widget()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch); root_widget()->InvokePointerMove(e.x(), e.y(), GetModifierKeys(), kTouch);
if (tb::TBWidget::hovered_widget) { if (tb::Widget::hovered_widget) {
int x = e.x(); int x = e.x();
int y = e.y(); int y = e.y();
tb::TBWidget::hovered_widget->ConvertFromRoot(x, y); tb::Widget::hovered_widget->ConvertFromRoot(x, y);
tb::TBWidgetEvent ev(tb::EVENT_TYPE_CONTEXT_MENU, x, y, kTouch, tb::WidgetEvent ev(tb::EventType::kContextMenu, x, y, kTouch,
GetModifierKeys()); GetModifierKeys());
tb::TBWidget::hovered_widget->InvokeEvent(ev); tb::Widget::hovered_widget->InvokeEvent(ev);
} }
e.set_handled(true); e.set_handled(true);
} }
@ -462,6 +478,9 @@ void TurboBadgerControl::OnMouseUp(xe::ui::MouseEvent& e) {
void TurboBadgerControl::OnMouseWheel(xe::ui::MouseEvent& e) { void TurboBadgerControl::OnMouseWheel(xe::ui::MouseEvent& e) {
super::OnMouseWheel(e); super::OnMouseWheel(e);
if (!root_widget()) {
return;
}
e.set_handled(root_widget()->InvokeWheel( e.set_handled(root_widget()->InvokeWheel(
e.x(), e.y(), e.dx(), -e.dy() / kMouseWheelDetent, GetModifierKeys())); e.x(), e.y(), e.dx(), -e.dy() / kMouseWheelDetent, GetModifierKeys()));
} }

View File

@ -27,11 +27,11 @@ class TurboBadgerControl : public xe::ui::gl::WGLControl {
TurboBadgerControl(xe::ui::Loop* loop); TurboBadgerControl(xe::ui::Loop* loop);
~TurboBadgerControl() override; ~TurboBadgerControl() override;
static bool InitializeTurboBadger(tb::TBRenderer* renderer); static bool InitializeTurboBadger(tb::Renderer* renderer);
static void ShutdownTurboBadger(); static void ShutdownTurboBadger();
tb::TBRenderer* renderer() const { return renderer_.get(); } tb::Renderer* renderer() const { return renderer_.get(); }
tb::TBWidget* root_widget() const { return root_widget_.get(); } tb::Widget* root_widget() const { return root_widget_.get(); }
protected: protected:
using super = xe::ui::gl::WGLControl; using super = xe::ui::gl::WGLControl;
@ -45,10 +45,10 @@ class TurboBadgerControl : public xe::ui::gl::WGLControl {
void OnGotFocus(xe::ui::UIEvent& e) override; void OnGotFocus(xe::ui::UIEvent& e) override;
void OnLostFocus(xe::ui::UIEvent& e) override; void OnLostFocus(xe::ui::UIEvent& e) override;
tb::MODIFIER_KEYS GetModifierKeys(); tb::ModifierKeys GetModifierKeys();
void OnKeyPress(xe::ui::KeyEvent& e, bool is_down); void OnKeyPress(xe::ui::KeyEvent& e, bool is_down);
bool CheckShortcutKey(xe::ui::KeyEvent& e, tb::SPECIAL_KEY special_key, bool CheckShortcutKey(xe::ui::KeyEvent& e, tb::SpecialKey special_key,
bool is_down); bool is_down);
void OnKeyDown(xe::ui::KeyEvent& e) override; void OnKeyDown(xe::ui::KeyEvent& e) override;
void OnKeyUp(xe::ui::KeyEvent& e) override; void OnKeyUp(xe::ui::KeyEvent& e) override;
@ -58,8 +58,8 @@ class TurboBadgerControl : public xe::ui::gl::WGLControl {
void OnMouseUp(xe::ui::MouseEvent& e) override; void OnMouseUp(xe::ui::MouseEvent& e) override;
void OnMouseWheel(xe::ui::MouseEvent& e) override; void OnMouseWheel(xe::ui::MouseEvent& e) override;
std::unique_ptr<tb::TBRenderer> renderer_; std::unique_ptr<tb::Renderer> renderer_;
std::unique_ptr<tb::TBWidget> root_widget_; std::unique_ptr<tb::Widget> root_widget_;
uint32_t frame_count_ = 0; uint32_t frame_count_ = 0;
uint32_t fps_ = 0; uint32_t fps_ = 0;

View File

@ -22,7 +22,7 @@ namespace ui {
using namespace tb; using namespace tb;
class TBRendererGL4::TBBitmapGL4 : public tb::TBBitmap { class TBRendererGL4::TBBitmapGL4 : public tb::Bitmap {
public: public:
TBBitmapGL4(TBRendererGL4* renderer); TBBitmapGL4(TBRendererGL4* renderer);
~TBBitmapGL4(); ~TBBitmapGL4();
@ -50,8 +50,8 @@ TBRendererGL4::TBBitmapGL4::~TBBitmapGL4() {
} }
bool TBRendererGL4::TBBitmapGL4::Init(int width, int height, uint32_t* data) { bool TBRendererGL4::TBBitmapGL4::Init(int width, int height, uint32_t* data) {
assert(width == TBGetNearestPowerOfTwo(width)); assert(width == GetNearestPowerOfTwo(width));
assert(height == TBGetNearestPowerOfTwo(height)); assert(height == GetNearestPowerOfTwo(height));
width_ = width; width_ = width;
height_ = height; height_ = height;
@ -181,7 +181,7 @@ void main() { \n\
return true; return true;
} }
TBBitmap* TBRendererGL4::CreateBitmap(int width, int height, uint32_t* data) { Bitmap* TBRendererGL4::CreateBitmap(int width, int height, uint32_t* data) {
auto bitmap = std::make_unique<TBBitmapGL4>(this); auto bitmap = std::make_unique<TBBitmapGL4>(this);
if (!bitmap->Init(width, height, data)) { if (!bitmap->Init(width, height, data)) {
return nullptr; return nullptr;
@ -189,14 +189,14 @@ TBBitmap* TBRendererGL4::CreateBitmap(int width, int height, uint32_t* data) {
return bitmap.release(); return bitmap.release();
} }
void TBRendererGL4::SetClipRect(const TBRect& rect) { void TBRendererGL4::SetClipRect(const Rect& rect) {
Flush(); Flush();
glScissor(m_clip_rect.x, m_screen_rect.h - (m_clip_rect.y + m_clip_rect.h), glScissor(m_clip_rect.x, m_screen_rect.h - (m_clip_rect.y + m_clip_rect.h),
m_clip_rect.w, m_clip_rect.h); m_clip_rect.w, m_clip_rect.h);
} }
void TBRendererGL4::BeginPaint(int render_target_w, int render_target_h) { void TBRendererGL4::BeginPaint(int render_target_w, int render_target_h) {
TBRendererBatcher::BeginPaint(render_target_w, render_target_h); RendererBatcher::BeginPaint(render_target_w, render_target_h);
glEnablei(GL_BLEND, 0); glEnablei(GL_BLEND, 0);
glBlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -230,7 +230,7 @@ void TBRendererGL4::BeginPaint(int render_target_w, int render_target_h) {
} }
void TBRendererGL4::EndPaint() { void TBRendererGL4::EndPaint() {
TBRendererBatcher::EndPaint(); RendererBatcher::EndPaint();
Flush(); Flush();

View File

@ -22,7 +22,7 @@ namespace xe {
namespace debug { namespace debug {
namespace ui { namespace ui {
class TBRendererGL4 : public tb::TBRendererBatcher { class TBRendererGL4 : public tb::RendererBatcher {
public: public:
TBRendererGL4(); TBRendererGL4();
~TBRendererGL4() override; ~TBRendererGL4() override;
@ -32,10 +32,10 @@ class TBRendererGL4 : public tb::TBRendererBatcher {
void BeginPaint(int render_target_w, int render_target_h) override; void BeginPaint(int render_target_w, int render_target_h) override;
void EndPaint() override; void EndPaint() override;
tb::TBBitmap* CreateBitmap(int width, int height, uint32_t* data) override; tb::Bitmap* CreateBitmap(int width, int height, uint32_t* data) override;
void RenderBatch(Batch* batch) override; void RenderBatch(Batch* batch) override;
void SetClipRect(const tb::TBRect& rect) override; void SetClipRect(const tb::Rect& rect) override;
private: private:
class TBBitmapGL4; class TBBitmapGL4;

@ -1 +1 @@
Subproject commit b5f4e50b9d8626a27ec111cc00fef1438062fbb8 Subproject commit 37c7b5d818a2e7a38a555e326ceb6cd4daf63a17