mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	FIX: button focused state
Change-Id: Ieab02661c8f2e406b5bf5f156d9142efbe76d1cf
This commit is contained in:
		
							parent
							
								
									09d5651c39
								
							
						
					
					
						commit
						ec59446e44
					
				
					 5 changed files with 19 additions and 4 deletions
				
			
		|  | @ -26,8 +26,9 @@ Button::Button() | |||
|     , text_color(*wxBLACK) | ||||
| { | ||||
|     background_color = StateColor( | ||||
|         std::make_pair(*wxLIGHT_GREY, (int) StateColor::Checked), | ||||
|         std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered), | ||||
|         std::make_pair(0x00AE42, (int) StateColor::Checked), | ||||
|         std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),  | ||||
|         std::make_pair(0x37EE7C, (int) StateColor::Hovered | StateColor::Checked), | ||||
|         std::make_pair(*wxWHITE, (int) StateColor::Normal)); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -27,7 +27,6 @@ END_EVENT_TABLE() | |||
| SpinInput::SpinInput() | ||||
|     : state_handler(this) | ||||
|     , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), | ||||
|                    std::make_pair(0x00AE42, (int) StateColor::Focused), | ||||
|                    std::make_pair(0x00AE42, (int) StateColor::Hovered), | ||||
|                    std::make_pair(0xDBDBDB, (int) StateColor::Normal)) | ||||
|     , text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled), std::make_pair(*wxBLACK, (int) StateColor::Normal)) | ||||
|  |  | |||
|  | @ -36,6 +36,9 @@ int StateColor::states() const | |||
| { | ||||
|     int states = 0; | ||||
|     for (auto s : statesList_) states |= s; | ||||
|     states = (states & 0xffff) | (states >> 16); | ||||
|     if (takeFocusedAsHovered_ && (states & Hovered)) | ||||
|         states |= Focused; | ||||
|     return states; | ||||
| } | ||||
| 
 | ||||
|  | @ -45,6 +48,7 @@ wxColour StateColor::defaultColor() { | |||
| 
 | ||||
| wxColour StateColor::colorForStates(int states) | ||||
| { | ||||
|     bool focused = takeFocusedAsHovered_ && (states & Focused); | ||||
|     for (int i = 0; i < statesList_.size(); ++i) { | ||||
|         int s = statesList_[i]; | ||||
|         int on = s & 0xffff; | ||||
|  | @ -52,6 +56,13 @@ wxColour StateColor::colorForStates(int states) | |||
|         if ((on & states) == on && (off & ~states) == off) { | ||||
|             return colors_[i]; | ||||
|         } | ||||
|         if (focused && (on & Hovered)) { | ||||
|             on |= Focused; | ||||
|             on &= ~Hovered; | ||||
|             if ((on & states) == on && (off & ~states) == off) { | ||||
|                 return colors_[i]; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return wxColour(0, 0, 0, 0); | ||||
| } | ||||
|  | @ -78,3 +89,5 @@ bool StateColor::setColorForStates(wxColour const &color, int states) | |||
|     return false; | ||||
| } | ||||
| 
 | ||||
| void StateColor::setTakeFocusedAsHovered(bool set) { takeFocusedAsHovered_ = set; } | ||||
| 
 | ||||
|  |  | |||
|  | @ -58,6 +58,8 @@ public: | |||
| 
 | ||||
|     bool setColorForStates(wxColour const & color, int states); | ||||
| 
 | ||||
|     void setTakeFocusedAsHovered(bool set); | ||||
| 
 | ||||
| private: | ||||
|     template<typename Color, typename ...Colors> | ||||
|     void fill(std::pair<Color, int> color, std::pair<Colors, int>... colors) { | ||||
|  | @ -76,6 +78,7 @@ private: | |||
| private: | ||||
|     std::vector<int> statesList_; | ||||
|     std::vector<wxColour> colors_; | ||||
|     bool takeFocusedAsHovered_ = true; | ||||
| }; | ||||
| 
 | ||||
| #endif // !slic3r_GUI_StateColor_hpp_
 | ||||
|  |  | |||
|  | @ -26,7 +26,6 @@ END_EVENT_TABLE() | |||
| TextInput::TextInput() | ||||
|     : state_handler(this) | ||||
|     , border_color(std::make_pair(0xDBDBDB, (int) StateColor::Disabled), | ||||
|                    std::make_pair(0x00AE42, (int) StateColor::Focused), | ||||
|                    std::make_pair(0x00AE42, (int) StateColor::Hovered), | ||||
|                    std::make_pair(0xDBDBDB, (int) StateColor::Normal)) | ||||
|     , text_color(std::make_pair(0xACACAC, (int) StateColor::Disabled), | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 chunmao.guo
						chunmao.guo