| 217 | } |
| 218 | |
| 219 | void SpinButton::SetAdjustment( Adjustment::Ptr adjustment ) { |
| 220 | if( !adjustment ) { |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | if( m_adjustment ) { |
| 225 | m_adjustment->GetSignal( Adjustment::OnChange ).Disconnect( m_adjustment_signal_serial ); |
| 226 | } |
| 227 | |
| 228 | m_adjustment = adjustment; |
| 229 | |
| 230 | auto weak_this = std::weak_ptr<Widget>( shared_from_this() ); |
| 231 | |
| 232 | m_adjustment_signal_serial = m_adjustment->GetSignal( Adjustment::OnChange ).Connect( [weak_this] { |
| 233 | auto shared_this = weak_this.lock(); |
| 234 | |
| 235 | if( !shared_this ) { |
| 236 | return; |
| 237 | } |
| 238 | |
| 239 | auto spin_button = std::dynamic_pointer_cast<SpinButton>( shared_this ); |
| 240 | |
| 241 | if( !spin_button ) { |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | spin_button->UpdateTextFromAdjustment(); |
| 246 | } ); |
| 247 | |
| 248 | UpdateTextFromAdjustment(); |
| 249 | } |
| 250 | |
| 251 | float SpinButton::GetValue() const { |
| 252 | return m_adjustment->GetValue(); |
no test coverage detected