Ver Fonte

Remove EventIterators, replace by lambda.

Michael Ragazzon há 5 anos atrás
pai
commit
cd8dc968b4
3 ficheiros alterados com 5 adições e 89 exclusões
  1. 0 1
      CMake/FileList.cmake
  2. 5 6
      Source/Core/Context.cpp
  3. 0 82
      Source/Core/EventIterators.h

+ 0 - 1
CMake/FileList.cmake

@@ -47,7 +47,6 @@ set(Core_HDR_FILES
     ${PROJECT_SOURCE_DIR}/Source/Core/ElementTextDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventDispatcher.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventInstancerDefault.h
-    ${PROJECT_SOURCE_DIR}/Source/Core/EventIterators.h
     ${PROJECT_SOURCE_DIR}/Source/Core/EventSpecification.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FileInterfaceDefault.h
     ${PROJECT_SOURCE_DIR}/Source/Core/FontEffectBlur.h

+ 5 - 6
Source/Core/Context.cpp

@@ -39,7 +39,6 @@
 #include "../../Include/RmlUi/Core/DataModel.h"
 #include "../../Include/RmlUi/Core/StreamMemory.h"
 #include "EventDispatcher.h"
-#include "EventIterators.h"
 #include "PluginRegistry.h"
 #include "StreamFile.h"
 #include <algorithm>
@@ -651,12 +650,11 @@ void Context::ProcessMouseButtonDown(int button_index, int key_modifier_state)
 
 		last_click_mouse_position = mouse_position;
 
-		for (ElementSet::iterator itr = hover_chain.begin(); itr != hover_chain.end(); ++itr)
-			active_chain.push_back((*itr));
+		active_chain.insert(active_chain.end(), hover_chain.begin(), hover_chain.end());
 
 		if (propagate)
 		{
-			// Traverse down the hierarchy of the newly focussed element (if any), and see if we can begin dragging it.
+			// Traverse down the hierarchy of the newly focused element (if any), and see if we can begin dragging it.
 			drag_started = false;
 			drag = hover;
 			while (drag)
@@ -704,8 +702,9 @@ void Context::ProcessMouseButtonUp(int button_index, int key_modifier_state)
 
 		// Unset the 'active' pseudo-class on all the elements in the active chain; because they may not necessarily
 		// have had 'onmouseup' called on them, we can't guarantee this has happened already.
-		auto func = PseudoClassFunctor("active", false);
-		std::for_each(active_chain.begin(), active_chain.end(), func);
+		std::for_each(active_chain.begin(), active_chain.end(), [](Element* element) {
+			element->SetPseudoClass("active", false);
+		});
 		active_chain.clear();
 
 		if (drag)

+ 0 - 82
Source/Core/EventIterators.h

@@ -1,82 +0,0 @@
-/*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
-
-#ifndef RMLUI_CORE_EVENTITERATORS_H
-#define RMLUI_CORE_EVENTITERATORS_H
-
-#include "../../Include/RmlUi/Core/Element.h"
-
-namespace Rml {
-
-/**
-	An STL unary functor for dispatching an event to a Element.
-
-	@author Peter Curry
- */
-
-class RmlEventFunctor
-{
-public:
-	RmlEventFunctor(EventId id, const Dictionary& parameters) : id(id), parameters(&parameters) {}
-
-	void operator()(Element* element)
-	{
-		element->DispatchEvent(id, *parameters);
-	}
-
-private:
-	EventId id;
-	const Dictionary* parameters;
-};
-
-/**
-	An STL unary functor for setting or clearing a pseudo-class on a Element.
-
-	@author Pete
- */
-
-class PseudoClassFunctor
-{
-	public:
-		PseudoClassFunctor(const String& pseudo_class, bool set) : pseudo_class(pseudo_class)
-		{
-			this->set = set;
-		}
-
-		void operator()(Element* element)
-		{
-			element->SetPseudoClass(pseudo_class, set);
-		}
-
-	private:
-		String pseudo_class;
-		bool set;
-};
-
-} // namespace Rml
-#endif