Browse Source

Debugger: Enable or disable selection of elements in user context.

Michael Ragazzon 6 years ago
parent
commit
b1d148e9d9

+ 1 - 1
Source/Debugger/BeaconSource.h

@@ -51,5 +51,5 @@ button
 )RCSS";
 
 static const char* beacon_rml = R"RML(
-<button class="error">!</button>;
+<button class="error">!</button>
 )RML";

+ 13 - 9
Source/Debugger/ElementInfo.cpp

@@ -108,6 +108,7 @@ ElementInfo::ElementInfo(const Core::String& tag) : Core::ElementDocument(tag)
 {
 	hover_element = nullptr;
 	source_element = nullptr;
+	enable_element_select = true;
 	show_source_element = true;
 	update_source_element = true;
 	force_update_once = false;
@@ -282,10 +283,10 @@ void ElementInfo::ProcessEvent(Core::Event& event)
 					show_source_element = !target_element->IsClassSet("active");;
 					target_element->SetClass("active", show_source_element);
 				}
-				else if (event.GetTargetElement()->GetId() == "update_source")
+				else if (id == "enable_element_select")
 				{
-					if (IsVisible())
-						SetProperty(Core::PropertyId::Visibility, Core::Property(Core::Style::Visibility::Hidden));
+					enable_element_select = !target_element->IsClassSet("active");;
+					target_element->SetClass("active", enable_element_select);
 				}
 				else if (target_element->GetTagName() == "pseudo" && source_element)
 				{
@@ -332,7 +333,7 @@ void ElementInfo::ProcessEvent(Core::Event& event)
 				event.StopPropagation();
 			}
 			// Otherwise we just want to focus on the clicked element (unless it's on a debug element)
-			else if (target_element->GetOwnerDocument() != nullptr && !IsDebuggerElement(target_element))
+			else if (enable_element_select && target_element->GetOwnerDocument() != nullptr && !IsDebuggerElement(target_element))
 			{
 				Core::Element* new_source_element = target_element;
 				if (new_source_element != source_element)
@@ -376,13 +377,13 @@ void ElementInfo::ProcessEvent(Core::Event& event)
 					show_source_element = true;
 				}
 
-				if (id == "show_source" || id == "update_source")
+				if (id == "show_source" || id == "update_source" || id == "enable_element_select")
 				{
 					title_dirty = true;
 				}
 			}
 			// Otherwise we just want to focus on the clicked element (unless it's on a debug element)
-			else if (owner_document != nullptr && owner_document->GetId().find("rmlui-debug-") != 0)
+			else if (enable_element_select && owner_document != nullptr && owner_document->GetId().find("rmlui-debug-") != 0)
 			{
 				hover_element = target_element;
 			}
@@ -401,7 +402,7 @@ void ElementInfo::ProcessEvent(Core::Event& event)
 						show_source_element = false;
 				}
 
-				if (id == "show_source" || id == "update_source")
+				if (id == "show_source" || id == "update_source" || id == "enable_element_select")
 				{
 					title_dirty = true;
 				}
@@ -728,12 +729,15 @@ void ElementInfo::BuildPropertyRML(Core::String& property_rml, const Core::Strin
 void ElementInfo::UpdateTitle()
 {
 	auto title_content = GetElementById("title-content");
+	auto enable_select = GetElementById("enable_element_select");
 	auto show_source = GetElementById("show_source");
 	auto update_source = GetElementById("update_source");
 
-	if (title_content && show_source && update_source)
+	if (title_content && enable_select && show_source && update_source)
 	{
-		if (show_source->IsPseudoClassSet("hover"))
+		if (enable_select->IsPseudoClassSet("hover"))
+			title_content->SetInnerRML("<em>(select elements)</em>");
+		else if (show_source->IsPseudoClassSet("hover"))
 			title_content->SetInnerRML("<em>(draw element dimensions)</em>");
 		else if (update_source->IsPseudoClassSet("hover"))
 			title_content->SetInnerRML("<em>(update info continuously)</em>");

+ 2 - 0
Source/Debugger/ElementInfo.h

@@ -80,6 +80,8 @@ private:
 
 	Core::String attributes_rml, properties_rml, events_rml, ancestors_rml, children_rml;
 
+	// Enables or disables the selection of elements in user context.
+	bool enable_element_select;
 	// Draws the dimensions of the source element.
 	bool show_source_element;
 	// Updates the source element information at regular intervals.

+ 1 - 0
Source/Debugger/InfoSource.h

@@ -122,6 +122,7 @@ static const char* info_rml = R"RML(
 	<div id="close_button">X</div>
 	<div id="update_source" class="header_button active">U</div>
 	<div id="show_source" class="header_button active">D</div>
+	<div id="enable_element_select" class="header_button active">*</div>
 	<div id="title-content">Element Information</div>
 </h1>
 <div id="content">