Skip to content

Commit

Permalink
UX: set color/font tab based on current
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Sep 1, 2024
1 parent 261f1f7 commit dde0043
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
27 changes: 23 additions & 4 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ MainWindow::MainWindow(Document& document,
connect(&mDocument, &Document::sceneCreated,
this, &MainWindow::closeWelcomeDialog);
connect(&mDocument, &Document::openTextEditor,
this, [this] () {
mTabColorText->setCurrentIndex(mTabTextIndex);
mFontWidget->setTextFocus();
});
this, [this] () { focusFontWidget(true); });
connect(&mDocument, &Document::newVideo,
this, &MainWindow::handleNewVideoClip);

Expand Down Expand Up @@ -1677,6 +1674,17 @@ void MainWindow::setCurrentBox(BoundingBox *box)
{
mFillStrokeSettings->setCurrentBox(box);
mFontWidget->setCurrentBox(box);
setCurrentBoxFocus(box);
}

void MainWindow::setCurrentBoxFocus(BoundingBox *box)
{
if (!box) { return; }
if (const auto target = enve_cast<TextBox*>(box)) {
focusFontWidget(mDocument.fCanvasMode == CanvasMode::textCreate);
} else {
focusColorWidget();
}
}

FillStrokeSettingsWidget *MainWindow::getFillStrokeSettings()
Expand Down Expand Up @@ -2264,6 +2272,17 @@ TimelineDockWidget *MainWindow::getTimeLineWidget()
return mTimeline;
}

void MainWindow::focusFontWidget(const bool focus)
{
mTabColorText->setCurrentIndex(mTabTextIndex);
if (focus) { mFontWidget->setTextFocus(); }
}

void MainWindow::focusColorWidget()
{
mTabColorText->setCurrentIndex(mTabColorIndex);
}

stdsptr<void> MainWindow::lock()
{
if (mLock) { return mLock->ref<Lock>(); }
Expand Down
3 changes: 3 additions & 0 deletions src/app/GUI/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class MainWindow : public QMainWindow

//void addBoxAwaitingUpdate(BoundingBox *box);
void setCurrentBox(BoundingBox *box);
void setCurrentBoxFocus(BoundingBox *box);

// void nextSaveOutputFrame();
// void nextPlayPreviewFrame();
Expand Down Expand Up @@ -195,6 +196,8 @@ class MainWindow : public QMainWindow
void cmdAddAction(QAction *act);
LayoutHandler* getLayoutHandler();
TimelineDockWidget* getTimeLineWidget();
void focusFontWidget(const bool focus = true);
void focusColorWidget();

protected:
void lockFinished();
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void MainWindow::setupToolBoxMain()
this,
[this, textModeAct]() {
if (mDocument.fCanvasMode == CanvasMode::textCreate) {
mTabColorText->setCurrentIndex(mTabTextIndex);
focusFontWidget(true);
textModeAct->setChecked(true);
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/core/Boxes/textbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TextBox::TextBox() : PathBox("Text", eBoxType::text) {
#include <QDesktopWidget>

void TextBox::openTextEditor(QWidget* dialogParent) {
bool ok;
/*bool ok;
const QString text =
QInputDialog::getMultiLineText(
dialogParent, prp_getName() + " text",
Expand All @@ -88,7 +88,8 @@ void TextBox::openTextEditor(QWidget* dialogParent) {
mText->prp_startTransform();
mText->setCurrentValue(text);
mText->prp_finishTransform();
}
}*/
Q_UNUSED(dialogParent)
}

void TextBox::getMotionBlurProperties(QList<Property*> &list) const {
Expand Down
2 changes: 1 addition & 1 deletion src/core/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ class CORE_EXPORT Canvas : public CanvasBase

void clearGradientRWIds() const;
QList<SmartNodePoint*> getSortedSelectedNodes();
void openTextEditorForTextBox(TextBox *textBox);
//void openTextEditorForTextBox(TextBox *textBox);

void scaleSelected(const eMouseEvent &e);
void rotateSelected(const eMouseEvent &e);
Expand Down
5 changes: 0 additions & 5 deletions src/core/canvasmouseinteractions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,6 @@ void Canvas::handleLeftMouseRelease(const eMouseEvent &e) {
}
}
//mCanvasWindow->setCanvasMode(MOVE_PATH);
} else if(mCurrentMode == CanvasMode::textCreate) {
if(mCurrentTextBox) {
//mCurrentTextBox->openTextEditor(e.fWidget);
emit openTextEditor();
}
}
mValueInput.clearAndDisableInput();
mTransMode = TransformMode::none;
Expand Down

0 comments on commit dde0043

Please sign in to comment.