Browse Source

Fixes for choosed widget.

rsredsq 10 years ago
parent
commit
44d7c1b1f5

+ 9 - 3
Source/ThirdParty/TurboBadger/tb_widgets.cpp

@@ -73,7 +73,8 @@ TBWidget::TBWidget()
     , m_long_click_timer(nullptr)
     , m_long_click_timer(nullptr)
     , m_delegate(nullptr)
     , m_delegate(nullptr)
 	, m_packed_init(0)
 	, m_packed_init(0)
-    , capturing_(true)
+    , needCapturing_(true)
+    , captured_(false)
 {
 {
 #ifdef TB_RUNTIME_DEBUG_INFO
 #ifdef TB_RUNTIME_DEBUG_INFO
 	last_measure_time = 0;
 	last_measure_time = 0;
@@ -210,7 +211,7 @@ void TBWidget::SetState(WIDGET_STATE state, bool on)
 WIDGET_STATE TBWidget::GetAutoState() const
 WIDGET_STATE TBWidget::GetAutoState() const
 {
 {
 	WIDGET_STATE state = m_state;
 	WIDGET_STATE state = m_state;
-	bool add_pressed_state = !cancel_click && this == captured_widget && this == hovered_widget;
+	bool add_pressed_state = !cancel_click && (captured_ || this == captured_widget);
 	if (add_pressed_state)
 	if (add_pressed_state)
 		state |= WIDGET_STATE_PRESSED;
 		state |= WIDGET_STATE_PRESSED;
 	if (this == hovered_widget && (!m_packed.no_automatic_hover_state || add_pressed_state))
 	if (this == hovered_widget && (!m_packed.no_automatic_hover_state || add_pressed_state))
@@ -1276,7 +1277,7 @@ void TBWidget::StopLongClickTimer()
 void TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch)
 void TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS modifierkeys, bool touch)
 {
 {
     TBWidget* down_widget = GetWidgetAt(x, y, true);
     TBWidget* down_widget = GetWidgetAt(x, y, true);
-	if (!captured_widget && down_widget->capturing_)
+	if (!captured_widget && down_widget->needCapturing_)
 	{
 	{
 		SetCapturedWidget(down_widget);
 		SetCapturedWidget(down_widget);
 		SetHoveredWidget(captured_widget, touch);
 		SetHoveredWidget(captured_widget, touch);
@@ -1324,6 +1325,9 @@ void TBWidget::InvokePointerDown(int x, int y, int click_count, MODIFIER_KEYS mo
 	}
 	}
 	if (down_widget)
 	if (down_widget)
 	{
 	{
+        down_widget->Invalidate();
+        down_widget->InvalidateSkinStates();
+        down_widget->OnCaptureChanged(true);
 		down_widget->ConvertFromRoot(x, y);
 		down_widget->ConvertFromRoot(x, y);
 		pointer_move_widget_x = pointer_down_widget_x = x;
 		pointer_move_widget_x = pointer_down_widget_x = x;
 		pointer_move_widget_y = pointer_down_widget_y = y;
 		pointer_move_widget_y = pointer_down_widget_y = y;
@@ -1338,6 +1342,8 @@ void TBWidget::InvokePointerUp(int x, int y, MODIFIER_KEYS modifierkeys, bool to
     TBWidget* down_widget = GetWidgetAt(x, y, true);
     TBWidget* down_widget = GetWidgetAt(x, y, true);
 	if (down_widget)
 	if (down_widget)
 	{
 	{
+        down_widget->Invalidate();
+        down_widget->InvalidateSkinStates();
         down_widget->OnCaptureChanged(false);
         down_widget->OnCaptureChanged(false);
 		down_widget->ConvertFromRoot(x, y);
 		down_widget->ConvertFromRoot(x, y);
 		TBWidgetEvent ev_up(EVENT_TYPE_POINTER_UP, x, y, touch, modifierkeys);
 		TBWidgetEvent ev_up(EVENT_TYPE_POINTER_UP, x, y, touch, modifierkeys);

+ 10 - 4
Source/ThirdParty/TurboBadger/tb_widgets.h

@@ -684,7 +684,7 @@ public:
 	virtual void OnVisibilityChanged() {}
 	virtual void OnVisibilityChanged() {}
 
 
 	/** Called when the capture has changed. */
 	/** Called when the capture has changed. */
-	virtual void OnCaptureChanged(bool captured) {}
+    virtual void OnCaptureChanged(bool captured) { SetCaptured(captured); }
 
 
 	/** Called when a child widget has been added to this widget (before calling OnAdded on child). */
 	/** Called when a child widget has been added to this widget (before calling OnAdded on child). */
 	virtual void OnChildAdded(TBWidget *child) {}
 	virtual void OnChildAdded(TBWidget *child) {}
@@ -985,11 +985,17 @@ public:
 		by GetCalculatedFontDescription) */
 		by GetCalculatedFontDescription) */
 	TBFontFace *GetFont() const;
 	TBFontFace *GetFont() const;
 
 
-    void SetCapturing(bool capturing) { capturing_ = capturing; }
+    void SetCapturing(bool needCapturing) { needCapturing_ = needCapturing; }
 
 
-    bool GetCapturing() { return capturing_; }
+    bool GetCapturing() { return needCapturing_; }
 
 
-    bool capturing_;
+    void SetCaptured(bool captured) { captured_ = captured; }
+
+    bool IsCaptured() { return captured_; }
+
+    bool needCapturing_;
+
+    bool captured_;
 
 
 private:
 private:
 	friend class TBWidgetListener;	///< It does iteration of m_listeners for us.
 	friend class TBWidgetListener;	///< It does iteration of m_listeners for us.

+ 1 - 0
Source/ThirdParty/TurboBadger/tb_widgets_common.cpp

@@ -171,6 +171,7 @@ void TBButton::OnCaptureChanged(bool captured)
 		if (TBMessage *msg = GetMessageByID(TBIDC("auto_click")))
 		if (TBMessage *msg = GetMessageByID(TBIDC("auto_click")))
 			DeleteMessage(msg);
 			DeleteMessage(msg);
 	}
 	}
+    SetCaptured(captured);
 }
 }
 
 
 void TBButton::OnSkinChanged()
 void TBButton::OnSkinChanged()