Exemplo n.º 1
0
            inline void update(FT mFT) override
            {
                if(editing)
                {
                    green += mFT * 0.08f;
                    auto effect(std::abs(std::sin(green)));

                    cursorShape.refreshShape(cursor,
                        ssvs::getGlobalLeft(lblText.getText()), lblText.getY(),
                        getCursorSpacing());

                    lblText.getText().setColor(
                        sf::Color(255, effect * 255, 255, 255));
                    lblText.setString(editStr);
                }
                else
                {
                    lblText.setString(str);
                    lblText.getText().setColor(sf::Color::White);
                }

                for(const auto& e : getEventsToPoll())
                {
                    if(!editing) return;

                    auto modLShift(isKeyPressed(ssvs::KKey::LShift));
                    auto modLCtrl(isKeyPressed(ssvs::KKey::LControl));

                    if(e.type == sf::Event::TextEntered)
                    {
                        if(e.text.unicode == '\b' && !editStr.empty())
                            cursor.delStrBack(modLCtrl);
                        else if(e.text.unicode > 31 && e.text.unicode < 127)
                            cursor.insertStr(char(e.text.unicode));
                    }
                    else if(e.type == sf::Event::KeyPressed)
                    {
                        if(e.key.code == ssvs::KKey::Return)
                            finishEditing();
                        else if(e.key.code == ssvs::KKey::Escape)
                            finishEditing();
                        else if(e.key.code == ssvs::KKey::Left)
                            cursor.move(modLShift, modLCtrl, -1);
                        else if(e.key.code == ssvs::KKey::Right)
                            cursor.move(modLShift, modLCtrl, 1);
                        else if(e.key.code == ssvs::KKey::Home)
                            cursor.setBoth(0);
                        else if(e.key.code == ssvs::KKey::End)
                            cursor.setBoth(editStr.size());
                        else if(e.key.code == ssvs::KKey::Delete)
                            cursor.delStrFwd(modLCtrl);
                    }
                }

                if(editing && !isFocused()) finishEditing();
            }
Exemplo n.º 2
0
void DrawTextTool::setDrawingSymbol(const Symbol* symbol)
{
	// Avoid using deleted symbol
	if (map()->findSymbolIndex(drawing_symbol) == -1)
		symbol = NULL;
	
	// End current editing
	if (text_editor)
	{
		if (symbol)
			finishEditing();
		else
			abortEditing();
	}
	
	// Handle new symbol
	drawing_symbol = symbol;
	deletePreviewText();
	
	if (!symbol)
		deactivate();
	else if (symbol->isHidden())
		deactivate();
	else if (symbol->getType() != Symbol::Text)
		switchToDefaultDrawTool(symbol);
}
Exemplo n.º 3
0
QWidget *EditDelegate::createEditor(QWidget *parent,
    const QStyleOptionViewItem & option,
    const QModelIndex & index) const
{
	SceneTreeItem *item = static_cast<SceneTreeItem*>(index.internalPointer());
	QVariant value = index.model()->data(index, Qt::EditRole);
    QWidget *editor = 0;
	
	switch (item->valueType()) {
		case 0:
			editor = createIntEditor(index, parent);
			break;
		case 1:
			editor = createDoubleEditor(index, parent);
			break;
		case 2:
			editor = createBoolEditor(index, parent);
			break;
		default:
			editor = createColorEditor(index, parent, value.value<QColor>());
			break;
	}
	connect(editor, SIGNAL(editingFinished()),
            this, SLOT(finishEditing())); 
    return editor;
}
Exemplo n.º 4
0
void RotateTool::dragFinish()
{
	if (rotating)
	{
		rotating = false;
		finishEditing();
		updateDirtyRect();
		updateStatusText();
	}
}
Exemplo n.º 5
0
bool EditPointTool::mousePressEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	// TODO: port TextObjectEditorHelper to MapEditorToolBase
	if (text_editor)
	{
		if (!text_editor->mousePressEvent(event, map_coord, widget))
			finishEditing();
		return true;
	}
	else
		return MapEditorToolBase::mousePressEvent(event, map_coord, widget);
}
Exemplo n.º 6
0
void RotateTool::dragFinish()
{
	if (qAbs(current_rotation) > 0.0001)
	{
		for (auto object : map()->selectedObjects())
			object->rotateAround(rotation_center, -current_rotation);
	}
	original_rotation = current_rotation = 0;
	finishEditing();
	updateDirtyRect();
	updateStatusText();
}
Exemplo n.º 7
0
bool EditPointTool::keyPress(QKeyEvent* event)
{
	if (text_editor)
	{
		if (event->key() == Qt::Key_Escape)
		{
			finishEditing(); 
			return true;
		}
		return text_editor->keyPressEvent(event);
	}
	
	int num_selected_objects = map()->getNumSelectedObjects();
	
	if (num_selected_objects > 0 && event->key() == delete_object_key)
	{
		deleteSelectedObjects();
	}
	else if (num_selected_objects > 0 && event->key() == Qt::Key_Escape)
	{
		map()->clearObjectSelection(true);
	}
	else if (event->key() == Qt::Key_Control)
	{
		if (editingInProgress())
			activateAngleHelperWhileEditing();
	}
	else if (event->key() == Qt::Key_Shift && editingInProgress())
	{
		if (hover_state == OverObjectNode &&
			hover_object->getType() == Object::Path &&
			hover_object->asPath()->isCurveHandle(hover_point))
		{
			// In this case, Shift just activates deactivates
			// the opposite curve handle constraints
			return true;
		}
		activateSnapHelperWhileEditing();
	}
	else if (event->key() == Qt::Key_Space)
	{
		space_pressed = true;
	}
	else
	{
		return false;
	}
	
	updateStatusText();
	return true;
}
Exemplo n.º 8
0
bool EditPointTool::mouseReleaseEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	// TODO: port TextObjectEditorHelper to MapEditorToolBase
	if (text_editor)
	{
		if (event->button() == Qt::LeftButton)
		{
			box_selection = false;
		}
		if (!text_editor->mouseReleaseEvent(event, map_coord, widget))
			finishEditing();
		return true;
	}
	else
		return MapEditorToolBase::mouseReleaseEvent(event, map_coord, widget);
}
Exemplo n.º 9
0
void EditPointTool::objectSelectionChangedImpl()
{
	if (text_editor)
	{
		// This case can be reproduced by using "select all objects of symbol" for any symbol while editing a text.
		// Revert selection to text object in order to be able to finish editing. Not optimal, but better than crashing.
		map()->clearObjectSelection(false);
		map()->addObjectToSelection(text_editor->getObject(), false);
		finishEditing();
		map()->emitSelectionChanged();
		return;
	}
	
	updateHoverState(cur_pos_map);
	updateDirtyRect();
	updateStatusText();
}
Exemplo n.º 10
0
void EditPointTool::dragFinish()
{
	if (no_more_effect_on_click)
		no_more_effect_on_click = false;
	
	if (editingInProgress())
	{
		finishEditing();
		angle_helper->setActive(false);
		snap_helper->setFilter(SnappingToolHelper::NoSnapping);
	}
	else if (box_selection)
	{
		object_selector->selectBox(click_pos_map, cur_pos_map, active_modifiers & Qt::ShiftModifier);
	}
	box_selection = false;
}
Exemplo n.º 11
0
void osgMain::ToggleEditing(int ID)
{
	editMode=!editMode;
	///toggleEditing=true;?
	if(editMode)
	{
		editingID=ID;
		osg::Geode* geode=mNumGeodeMap.find(ID)->second;
		editing=geode->getDrawable(0);

		swapDrawbles(editing,editGeometry);
		//editTransform->setMatrix(transMat);
	}
	else
	{
		editHost=false;
		finishEditing();
	}
}
Exemplo n.º 12
0
bool DrawTextTool::mouseReleaseEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget)
{
	if (text_editor)
	{
		if (text_editor->mouseReleaseEvent(event, map_coord, widget))
			return true;
		else
		{
			cur_pos = event->pos();
			cur_pos_map = map_coord;
			finishEditing();
			return true;
		}
	}
	
	if (event->button() != Qt::LeftButton)
		return false;
	
	if (dragging)
	{
		// Create box text
		double width = qAbs(cur_pos_map.x() - click_pos_map.x());
		double height = qAbs(cur_pos_map.y() - click_pos_map.y());
		auto midpoint = MapCoord { 0.5 * (cur_pos_map + click_pos_map) };
		preview_text->setBox(midpoint.nativeX(), midpoint.nativeY(), width, height);
		
		dragging = false;
		updateDirtyRect();
	}
	else
		setPreviewLetter();
	
	preview_text->setText("");

	// Create the TextObjectEditor
	text_editor = new TextObjectEditorHelper(preview_text, editor);
	connect(text_editor, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
	
	updatePreviewText();
	updateStatusText();
	
	return true;
}
Exemplo n.º 13
0
void TodoEditor::setupGui()
{
    startDateEdit = new QDateTimeEdit;
    dueDateEdit = new QDateTimeEdit;
    subjectLineEdit = new QLineEdit;
    descriptionTextEdit = new QTextEdit;
    doneButton = new QPushButton(tr("Done"));

    setupCombos();

    connect(startDateEdit, SIGNAL(editingFinished()),
        this, SLOT(updateDates()));
    connect(dueDateEdit, SIGNAL(editingFinished()), this, SLOT(updateDates()));
    connect(subjectLineEdit, SIGNAL(editingFinished()),
        this, SLOT(updateSubject()));
    connect(descriptionTextEdit, SIGNAL(textChanged()),
        this, SLOT(updateDescription()));
    connect(statusCombo, SIGNAL(activated(int)), this, SLOT(updateStatus(int)));
    connect(priorityCombo, SIGNAL(activated(int)),
        this, SLOT(updatePriority(int)));
    connect(alarmCombo, SIGNAL(activated(int)), this, SLOT(updateAlarm(int)));
    connect(doneButton, SIGNAL(clicked()), this, SLOT(finishEditing()));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(new QLabel(tr("Subject:")));
    layout->addWidget(subjectLineEdit);
    layout->addWidget(new QLabel(tr("Start Date:")));
    layout->addWidget(startDateEdit);
    layout->addWidget(new QLabel(tr("Due Date:")));
    layout->addWidget(dueDateEdit);
    layout->addWidget(new QLabel(tr("Status:")));
    layout->addWidget(statusCombo);
    layout->addWidget(new QLabel(tr("Priority:")));
    layout->addWidget(priorityCombo);
    layout->addWidget(new QLabel(tr("Alarm:")));
    layout->addWidget(alarmCombo);
    layout->addWidget(new QLabel(tr("Description")));
    layout->addWidget(descriptionTextEdit);
    layout->addWidget(doneButton);

    setLayout(layout);
}
Exemplo n.º 14
0
void osgMain::ToggleEditing()
{
	editMode=!editMode;
	toggleEditing=true;

	if(editMode)
	{
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit start");
		editHost=true;
		editing=picker->currentSelectedDrawable;
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit OK1");
		osg::Geode* geode=editing->getParent(0)->asGeode();
		editingID=mRNumGeodeMap.find(geode)->second;
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit OK2");
		osg::BoundingBox bb=editing->getBound();

		//osg::Vec3 WorldCenter=bb.center()*osg::computeLocalToWorld(picker->currentInsersection.nodePath);
		editTransform->setMatrix(osg::Matrixd::identity());
		swapDrawbles(editing,editGeometry);
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit OK3");
		//editGeode->addDrawable(editing);
		editCenter=picker->currentSelectedDrawableWroldCenter;

		editRotation.set(osg::Matrixd::identity());
		editTranslation.set(osg::Matrixd::identity());
		editScale.set(osg::Matrixd::identity());
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit OK4");
		updateEditTransform();
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit OK5");
	}
	else
	{
		__android_log_print(ANDROID_LOG_ERROR,"jni client","toggle edit NOOOO");
		//editHost=false;
		justFinishEdit=true;
		finishEditing();
		__android_log_print(ANDROID_LOG_ERROR,"jni client","in toggle editing: edit mode %d", editMode);
		__android_log_print(ANDROID_LOG_ERROR,"jni client","in toggle editing: toggle edit %d", toggleEditing);
	}


}
Exemplo n.º 15
0
bool DrawTextTool::keyPressEvent(QKeyEvent* event)
{
	if (text_editor)
	{
		if (event->key() == Qt::Key_Escape)
		{
			finishEditing();
			return true;
		}
		else if (text_editor->keyPressEvent(event))
		{
			return true;
		}
	}
	else if (event->key() == Qt::Key_Tab)
	{
		deactivate();
		return true;
	}
	
	return false;
}
Exemplo n.º 16
0
DrawTextTool::~DrawTextTool()
{
	if (text_editor)
		finishEditing();
	deletePreviewText();
}
Exemplo n.º 17
0
// virtual
void MapEditorToolBase::finishEditing()
{
	finishEditing(false, true);
}
Exemplo n.º 18
0
void RotatePatternTool::dragFinish()
{
	finishEditing();
	angle_helper->setActive(false);
	updateStatusText();
}