예제 #1
0
bool ewol::widget::ParameterList::onEventInput(const ewol::event::Input& _event) {
	if (true == WidgetScrolled::onEventInput(_event)) {
		keepFocus();
		// nothing to do ... done on upper widet ...
		return true;
	}
	if (_event.getId() == 1 && _event.getStatus() == gale::key::status_single) {
		vec2 relativePos = relativePosition(_event.getPos());
		// corection for the openGl abstraction
		relativePos.setY(m_size.y() - relativePos.y());
		// TODO : Rework this ...
		/*
		int32_t fontId = getDefaultFontId();
		//int32_t minWidth = ewol::getWidth(fontId, m_label.c_str());
		int32_t minHeight = ewol::getHeight(fontId);
		*/
		int32_t minHeight = 20;
		int32_t rawID = (relativePos.y()+m_originScrooled.y()) / (minHeight + 2*m_paddingSizeY);
		// generate an event on a rawId if the element request change and Select it ...
		if (rawID >= 0 && (size_t)rawID < m_list.size()) {
			if (m_list[rawID]!=nullptr) {
				if (m_list[rawID]->m_refId >= 0) {
					signalSelect.emit(m_list[rawID]->m_refId);
					m_idSelected = rawID;
					markToRedraw();
					return true;
				}
			}
		}
	}
	return false;
}
예제 #2
0
파일: List.cpp 프로젝트: atria-soft/ewol
bool ewol::widget::List::onEventInput(const ewol::event::Input& _event) {
	vec2 relativePos = relativePosition(_event.getPos());
	
	if (true == WidgetScrolled::onEventInput(_event)) {
		keepFocus();
		// nothing to do ... done on upper widet ...
		return true;
	}
	// parse all the loged row position to find the good one...
	int32_t rawID = -1;
	for (size_t iii=0; iii<m_lineSize.size()-1; iii++) {
		if(    relativePos.y()<m_lineSize[iii].y()
		    && relativePos.y() >= m_lineSize[iii+1].y() ) {
			// we find the raw :
			rawID = m_lineSize[iii].x();
			break;
		}
	}
	
	//EWOL_DEBUG("List event : idInput=" << IdInput << " typeEvent=" << typeEvent << "  raw=" << rawID << " pos=" << pos << "");
	bool isUsed = onItemEvent(_event.getId(), _event.getStatus(), 0, rawID, _event.getPos().x(), _event.getPos().y());
	if (true == isUsed) {
		// TODO : this generate bugs ... I did not understand why ..
		//ewol::WidgetSharedManager::focusKeep(this);
	}
	return isUsed;
}
예제 #3
0
파일: Image.cpp 프로젝트: biddyweb/ewol
bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) {
	//EWOL_DEBUG("Event on BT ...");
	if (_event.getId() == 1) {
		if(gale::key::status_single == _event.getStatus()) {
			signalPressed.emit();
			return true;
		}
	}
	return false;
}
예제 #4
0
bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) {
	if (_event.getId() > 0) {
		if (nullptr != ewol::widget::Container::getWidgetAtPos(_event.getPos())) {
			return false;
		}
		if(    _event.getStatus() == gale::key::status_down
		    || _event.getStatus() == gale::key::status_move
		    || _event.getStatus() == gale::key::status_single
		    || _event.getStatus() == gale::key::status_up
		    || _event.getStatus() == gale::key::status_enter
		    || _event.getStatus() == gale::key::status_leave ) {
			// Auto-remove ...
			autoDestroy();
			return true;
		}
	}
	return false;
}
예제 #5
0
파일: Slider.cpp 프로젝트: biddyweb/ewol
bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) {
	vec2 relativePos = relativePosition(_event.getPos());
	//EWOL_DEBUG("Event on Slider ..." << _event);
	if (1 == _event.getId()) {
		if(    gale::key::status_single == _event.getStatus()
		    || gale::key::status_move   == _event.getStatus()) {
			// get the new position :
			EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")");
			float oldValue = m_value.get();
			updateValue(m_min + (float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (m_max-m_min));
			if (oldValue != m_value) {
				EWOL_VERBOSE(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
				signalChange.emit(m_value);
			}
			return true;
		}
	}
	return false;
}
예제 #6
0
bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
	bool previousHoverState = m_mouseHover;
	if(ewol::key::statusLeave == _event.getStatus()) {
		m_mouseHover = false;
		m_buttonPressed = false;
	} else {
		vec2 relativePos = relativePosition(_event.getPos());
		// prevent error from ouside the button
		if(    relativePos.x() < m_selectableAreaPos.x()
		    || relativePos.y() < m_selectableAreaPos.y()
		    || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x()
		    || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) {
			m_mouseHover = false;
			m_buttonPressed = false;
		} else {
			m_mouseHover = true;
		}
	}
	bool previousPressed = m_buttonPressed;
	//EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover);
	if (true == m_mouseHover) {
		if (1 == _event.getId()) {
			if(ewol::key::statusDown == _event.getStatus()) {
				m_buttonPressed = true;
				markToRedraw();
			}
			if(ewol::key::statusUp == _event.getStatus()) {
				m_buttonPressed = false;
				markToRedraw();
			}
			if(ewol::key::statusSingle == _event.getStatus()) {
				m_buttonPressed = false;
				m_mouseHover = false;
				// create a context menu : 
				m_widgetContextMenu = ewol::widget::ContextMenu::create();
				if (nullptr == m_widgetContextMenu) {
					EWOL_ERROR("Allocation Error");
					return true;
				}
				vec2 tmpPos = m_origin + m_selectableAreaPos + m_selectableAreaSize;
				tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0);
				m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos );
				
				std::shared_ptr<ewol::widget::ColorChooser> myColorChooser = widget::ColorChooser::create();
				myColorChooser->setColor(m_textColorFg.get());
				// set it in the pop-up-system : 
				m_widgetContextMenu->setSubWidget(myColorChooser);
				myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange);
				std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows();
				if (currentWindows == nullptr) {
					EWOL_ERROR("Can not get the curent Windows...");
					m_widgetContextMenu.reset();
				} else {
					currentWindows->popUpWidgetPush(m_widgetContextMenu);
				}
				markToRedraw();
			}
		}
	}
	if(    m_mouseHover != previousHoverState
	    || m_buttonPressed != previousPressed) {
		if (true == m_buttonPressed) {
			changeStatusIn(STATUS_PRESSED);
		} else {
			if (true == m_mouseHover) {
				changeStatusIn(STATUS_HOVER);
			} else {
				changeStatusIn(STATUS_UP);
			}
		}
	}
	return m_mouseHover;
}
예제 #7
0
파일: ColorBar.cpp 프로젝트: biddyweb/ewol
bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) {
	vec2 relativePos = relativePosition(_event.getPos());
	//EWOL_DEBUG("Event on BT ...");
	if (1 == _event.getId()) {
		relativePos.setValue( std::avg(0.0f, m_size.x(),relativePos.x()),
		                      std::avg(0.0f, m_size.y(),relativePos.y()) );
		if(    gale::key::status_single == _event.getStatus()
		    || gale::key::status_move   == _event.getStatus()) {
			// nothing to do ...
			m_currentUserPos.setValue( relativePos.x()/m_size.x(),
			                           relativePos.y()/m_size.y() );
			markToRedraw();
			// == > try to estimate color
			EWOL_VERBOSE("event on (" << relativePos.x() << "," << relativePos.y() << ")");
			int32_t bandID = (int32_t)(relativePos.x()/(m_size.x()/6));
			float localPos = relativePos.x() - (m_size.x()/6) * bandID;
			float poroportionnalPos = localPos/(m_size.x()/6);
			EWOL_VERBOSE("bandId=" << bandID << "  relative pos=" << localPos);
			etk::Color<> estimateColor = etk::color::white;
			if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) {
				estimateColor.setR(s_listColor[bandID].r());
			} else if (s_listColor[bandID].r() < s_listColor[bandID+1].r()) {
				estimateColor.setR(s_listColor[bandID].r() + (s_listColor[bandID+1].r()-s_listColor[bandID].r())*poroportionnalPos);
			} else {
				estimateColor.setR(s_listColor[bandID+1].r() + (s_listColor[bandID].r()-s_listColor[bandID+1].r())*(1-poroportionnalPos));
			}
			if (s_listColor[bandID].g() == s_listColor[bandID+1].g()) {
				estimateColor.setG(s_listColor[bandID].g());
			} else if (s_listColor[bandID].g() < s_listColor[bandID+1].g()) {
				estimateColor.setG(s_listColor[bandID].g() + (s_listColor[bandID+1].g()-s_listColor[bandID].g())*poroportionnalPos);
			} else {
				estimateColor.setG(s_listColor[bandID+1].g() + (s_listColor[bandID].g()-s_listColor[bandID+1].g())*(1-poroportionnalPos));
			}
			if (s_listColor[bandID].b() == s_listColor[bandID+1].b()) {
				estimateColor.setB(s_listColor[bandID].b());
			} else if (s_listColor[bandID].b() < s_listColor[bandID+1].b()) {
				estimateColor.setB(s_listColor[bandID].b() + (s_listColor[bandID+1].b()-s_listColor[bandID].b())*poroportionnalPos);
			} else {
				estimateColor.setB(s_listColor[bandID+1].b() + (s_listColor[bandID].b()-s_listColor[bandID+1].b())*(1-poroportionnalPos));
			}
			// step 2 generate the white and black ...
			if (m_currentUserPos.y() == 0.5) {
				// nothing to do ... just get the current color ...
			} else if (m_currentUserPos.y() < 0.5) {
				float poroportionnalWhite = (0.5-m_currentUserPos.y())*2.0;
				estimateColor.setR(estimateColor.r() + (0xFF-estimateColor.r())*poroportionnalWhite);
				estimateColor.setG(estimateColor.g() + (0xFF-estimateColor.g())*poroportionnalWhite);
				estimateColor.setB(estimateColor.b() + (0xFF-estimateColor.b())*poroportionnalWhite);
			} else {
				float poroportionnalBlack = (m_currentUserPos.y()-0.5)*2.0;
				estimateColor.setR(estimateColor.r() - estimateColor.r()*poroportionnalBlack);
				estimateColor.setG(estimateColor.g() - estimateColor.g()*poroportionnalBlack);
				estimateColor.setB(estimateColor.b() - estimateColor.b()*poroportionnalBlack);
			}
			if(m_currentColor != estimateColor) {
				m_currentColor = estimateColor;
				signalChange.emit(m_currentColor);
			}
			return true;
		}
	}
	return false;
}
예제 #8
0
파일: Button.cpp 프로젝트: atria-soft/ewol
bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
	EWOL_VERBOSE("Event on BT : " << _event);
	// disable event in the lock access mode :
	if(ewol::widget::Button::lockAccess == *propertyLock) {
		return false;
	}
	if(    gale::key::status::leave == _event.getStatus()
	    || gale::key::status::abort == _event.getStatus()) {
		m_mouseHover = false;
		m_buttonPressed = false;
	} else {
		vec2 relativePos = relativePosition(_event.getPos());
		// prevent error from ouside the button
		if(    relativePos.x() < m_selectableAreaPos.x()
		    || relativePos.y() < m_selectableAreaPos.y()
		    || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x()
		    || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) {
			m_mouseHover = false;
			m_buttonPressed = false;
		} else {
			m_mouseHover = true;
		}
	}
	EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover);
	if (true == m_mouseHover) {
		if (1 == _event.getId()) {
			if(gale::key::status::down == _event.getStatus()) {
				EWOL_VERBOSE(*propertyName << " : Generate event : " << signalDown);
				signalDown.emit();
				m_buttonPressed = true;
				markToRedraw();
			}
			if(gale::key::status::up == _event.getStatus()) {
				EWOL_VERBOSE(*propertyName << " : Generate event : " << signalUp);
				signalUp.emit();
				m_buttonPressed = false;
				markToRedraw();
			}
			if(gale::key::status::pressSingle == _event.getStatus()) {
				if(    (    *propertyValue == true
				         && ewol::widget::Button::lockWhenPressed == propertyLock)
				    || (    *propertyValue == false
				         && ewol::widget::Button::lockWhenReleased == propertyLock) ) {
					// nothing to do : Lock mode ...
					// user might set himself the new correct value with @ref setValue(xxx)
				} else {
					// inverse value :
					propertyValue.set((*propertyValue)?false:true);
					EWOL_VERBOSE(*propertyName << " : Generate event : " << signalPressed);
					signalPressed.emit();
					EWOL_VERBOSE(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue );
					signalValue.emit(*propertyValue);
					if(    *propertyToggleMode == false
					    && *propertyValue == true) {
						propertyValue.set(false);
						EWOL_VERBOSE(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue);
						signalValue.emit(*propertyValue);
					}
				}
				markToRedraw();
			}
		}
	}
	CheckStatus();
	return m_mouseHover;
}
예제 #9
0
파일: TextViewer.cpp 프로젝트: HeeroYui/edn
bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) {
	if (   _event.getId() != 0
	    && _event.getStatus() == gale::key::status::down) {
		keepFocus();
	}
	//tic();
	if (m_buffer == nullptr) {
		return false;
	}
	// First call the scrolling widget :
	if (ewol::widget::WidgetScrolled::onEventInput(_event) == true) {
		markToRedraw();
		return true;
	}
	// Second call plugin
	if (m_pluginManager->onEventInput(*this, _event) == true) {
		markToRedraw();
		return true;
	}
	vec2 relativePos = relativePosition(_event.getPos());
	// offset for the lineNumber:
	relativePos -= vec2(m_lastOffsetDisplay, 0);
	// offset for the scrolling:
	relativePos += vec2(m_originScrooled.x(), -m_originScrooled.y());
	// invert for the buffer event ...
	relativePos.setY(m_size.y()-relativePos.y());
	if (relativePos.x()<0) {
		relativePos.setX(0);
	}
	if (    _event.getId() == 12
	     && _event.getStatus() == gale::key::status::pressSingle) {
		APPL_TODO("RAT5 SAVE button ==> TODO implement");
		// Rat5 save event
		//sendMultiCast(ednMsgGuiSave, "current");
		return true;
	}
	// just forward event  == > manage directly in the buffer
	if (_event.getId() == 1) {
		// mouse selection :
		//if (_event.getType() == gale::key::typeMouse) {
			if (_event.getStatus() == gale::key::status::down) {
				//if (_event.getSpecialKey().isSetShift() == false) {
					appl::Buffer::Iterator newPos = getMousePosition(relativePos);
					m_buffer->setSelectMode(false);
					moveCursor(newPos);
					m_buffer->setSelectMode(true);
					markToRedraw();
					return true;
				//}
			} else if (_event.getStatus() == gale::key::status::up) {
				appl::Buffer::Iterator newPos = getMousePosition(relativePos);
				moveCursor(newPos);
				m_buffer->setSelectMode(false);
				// Copy selection :
				std::string value;
				m_buffer->copy(value);
				if (value.size() != 0) {
					gale::context::clipBoard::set(gale::context::clipBoard::clipboardSelection, value);
				}
				markToRedraw();
				return true;
			}
		//}
		if (_event.getStatus() == gale::key::status::pressSingle) {
			if (    _event.getType() == gale::key::type::mouse
			     || _event.getType() == gale::key::type::finger) {
				appl::Buffer::Iterator newPos = getMousePosition(relativePos);
				moveCursor(newPos);
				markToRedraw();
				return true;
			}
		} else if (_event.getStatus() == gale::key::status::pressDouble) {
			mouseEventDouble();
			// Copy selection :
			std::string value;
			m_buffer->copy(value);
			if (value.size() != 0) {
				gale::context::clipBoard::set(gale::context::clipBoard::clipboardSelection, value);
			}
			markToRedraw();
			return true;
		} else if (_event.getStatus() == gale::key::status::pressTriple) {
			mouseEventTriple();
			// Copy selection :
			std::string value;
			m_buffer->copy(value);
			if (value.size() != 0) {
				gale::context::clipBoard::set(gale::context::clipBoard::clipboardSelection, value);
			}
			markToRedraw();
			return true;
		} else if (_event.getStatus() == gale::key::status::move) {
			if (m_buffer->getSelectMode() == true) {
				//int64_t timeStart = ewol::getTime();
				appl::Buffer::Iterator newPos = getMousePosition(relativePos);
				//int64_t timeMedium1 = ewol::getTime();
				moveCursor(newPos);
				//int64_t timeMedium2 = ewol::getTime();
				markToRedraw();
				/*
				int64_t timeStop = ewol::getTime();
				APPL_DEBUG("Display selection=" << (timeStop-timeStart)/1000.0f << " ms");
				APPL_DEBUG("                1=" << (timeMedium1-timeStart)/1000.0f << " ms");
				APPL_DEBUG("                2=" << (timeMedium2-timeMedium1)/1000.0f << " ms");
				*/
				return true;
			}
		}
	} else if (2 == _event.getId()) {
		if (gale::key::status::pressSingle == _event.getStatus()) {
			appl::Buffer::Iterator newPos = getMousePosition(relativePos);
			moveCursor(newPos);
			gale::context::clipBoard::request(gale::context::clipBoard::clipboardSelection);
			markToRedraw();
			return true;
		}
	}
	return false;
}