Skip to content

Commit

Permalink
Add no transition option
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Jun 15, 2024
1 parent 077237a commit 70d074d
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 31 deletions.
13 changes: 12 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "config",
"type": "process",
"command": "${workspaceFolder}\\build\\install\\MultiScreenSaver.scr",
"options": {
"cwd": "${workspaceFolder}\\gui"
}
},
{
"label": "run",
"type": "process",
"command": "${workspaceFolder}\\build\\install\\app.exe",
"command": "${workspaceFolder}\\build\\install\\MultiScreenSaver.scr",
"args": [
"-s"
],
"options": {
"cwd": "${workspaceFolder}\\gui"
}
Expand Down
4 changes: 4 additions & 0 deletions gui/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Config::Config()
portraitDir = reg.Read("portraitDir", "");
recursive = reg.ReadBool("recursive", true);
scale = static_cast<SCALE>(reg.ReadLong("scale", SCALE::FILL));
transition = static_cast<TRANSITION>(reg.ReadLong("transition", TRANSITION::BLEND));
period = reg.ReadLong("period", 10);
margins = reg.ReadLong("margins", 0);
stagger = reg.ReadBool("stagger", false);
Expand All @@ -41,6 +42,7 @@ void Config::SaveToRegistry()
reg.Write("portraitDir", portraitDir);
reg.Write("recursive", recursive);
reg.Write("scale", static_cast<long>(scale));
reg.Write("transition", static_cast<long>(transition));
reg.Write("period", period);
reg.Write("margins", margins);
reg.Write("stagger", stagger);
Expand All @@ -52,6 +54,7 @@ CONFIG_DIALOG::CONFIG_DIALOG(Config& config) : CONFIG_BASE(nullptr), m_config(co
m_portraitDir->SetPath(m_config.portraitDir);
m_recursiveScan->SetValue(m_config.recursive);
m_scale->SetSelection(static_cast<long>(m_config.scale));
m_transition->SetSelection(static_cast<long>(m_config.transition));
m_period->SetValue(m_config.period);
m_margins->SetValue(m_config.margins);
m_stagger->SetValue(m_config.stagger);
Expand All @@ -66,6 +69,7 @@ void CONFIG_DIALOG::OnClose(wxCloseEvent& e)
m_config.portraitDir = m_portraitDir->GetPath();
m_config.recursive = m_recursiveScan->GetValue();
m_config.scale = static_cast<Config::SCALE>(m_scale->GetSelection());
m_config.transition = static_cast<Config::TRANSITION>(m_transition->GetSelection());
m_config.period = m_period->GetValue();
m_config.margins = m_margins->GetValue();
m_config.stagger = m_stagger->GetValue();
Expand Down
121 changes: 113 additions & 8 deletions gui/config.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -676,22 +676,127 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Transition</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText9</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="width">0</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag"></property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<object class="wxChoice" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;None&quot; &quot;Blend&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_transition</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="width">0</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
Expand Down
5 changes: 5 additions & 0 deletions gui/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ struct Config
FIT,
ORIGINAL,
} scale;
enum TRANSITION
{
NONE,
BLEND,
} transition;
int period;
int margins;
bool stagger;
Expand Down
14 changes: 9 additions & 5 deletions gui/config_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ CONFIG_BASE::CONFIG_BASE( wxWindow* parent, wxWindowID id, const wxString& title
m_scale->SetSelection( 0 );
fgSizer2->Add( m_scale, 0, wxALL|wxEXPAND, 5 );


fgSizer2->Add( 0, 0, 0, 0, 5 );


fgSizer2->Add( 0, 0, 0, 0, 5 );
m_staticText9 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, wxT("Transition"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText9->Wrap( -1 );
fgSizer2->Add( m_staticText9, 0, wxALL, 5 );

wxString m_transitionChoices[] = { wxT("None"), wxT("Blend") };
int m_transitionNChoices = sizeof( m_transitionChoices ) / sizeof( wxString );
m_transition = new wxChoice( sbSizer2->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_transitionNChoices, m_transitionChoices, 0 );
m_transition->SetSelection( 1 );
fgSizer2->Add( m_transition, 0, wxALL|wxEXPAND, 5 );

m_staticText3 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, wxT("Update period (sec)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText3->Wrap( -1 );
Expand Down
2 changes: 2 additions & 0 deletions gui/config_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CONFIG_BASE : public wxFrame
wxCheckBox* m_recursiveScan;
wxStaticText* m_staticText5;
wxChoice* m_scale;
wxStaticText* m_staticText9;
wxChoice* m_transition;
wxStaticText* m_staticText3;
wxSpinCtrl* m_period;
wxStaticText* m_staticText4;
Expand Down
25 changes: 16 additions & 9 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ bool App::OnInit()
wnd->SetHWND((WXHWND)m_previewHwnd);
#pragma warning(pop)

RenderWindow* renderer = new RenderWindow(wnd, m_config.landscapeDir, m_config.recursive, m_config.scale);
RenderWindow* renderer =
new RenderWindow(wnd, m_config.landscapeDir, m_config.recursive, m_config.scale, m_config.transition);
m_renderers.push_back(renderer);
SetTopWindow(renderer);
renderer->Show();
Expand All @@ -111,7 +112,7 @@ bool App::OnInit()
(rect.right - rect.left > rect.bottom - rect.top) ? m_config.landscapeDir : m_config.portraitDir;

SaverFrame* frame = new SaverFrame(
path, m_config.recursive, m_config.scale,
path, m_config.recursive, m_config.scale, m_config.transition,
wxPoint(rect.left + m_config.margins, rect.top + m_config.margins),
wxSize(rect.right - rect.left - 2 * m_config.margins, rect.bottom - rect.top - 2 * m_config.margins));

Expand Down Expand Up @@ -169,10 +170,13 @@ void App::switchImage(bool forward)

RenderWindow* renderer = m_renderers[m_updateRenderer];

for (double tick = 0.02; tick < 1.0; tick += .02)
if (m_config.transition != Config::TRANSITION::NONE)
{
renderer->Transition(forward, tick);
wxMilliSleep(16);
for (double tick = 0.02; tick < 1.0; tick += .02)
{
renderer->Transition(forward, tick);
wxMilliSleep(16);
}
}

renderer->Increment(forward);
Expand All @@ -184,11 +188,14 @@ void App::switchImage(bool forward)
}
else
{
for (double tick = 0.02; tick < 1.0; tick += .02)
if (m_config.transition != Config::TRANSITION::NONE)
{
for (const auto& renderer : m_renderers)
renderer->Transition(forward, tick);
wxMilliSleep(16);
for (double tick = 0.02; tick < 1.0; tick += .02)
{
for (const auto& renderer : m_renderers)
renderer->Transition(forward, tick);
wxMilliSleep(16);
}
}
for (const auto& renderer : m_renderers)
{
Expand Down
12 changes: 7 additions & 5 deletions saverframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ class ImageScanner : public wxDirTraverser
wxArrayString& files;
};

RenderWindow::RenderWindow(wxWindow* parent, const wxString& aPath, const bool aRecursive, const Config::SCALE aScale)
: wxWindow(parent, wxID_ANY, wxPoint(0, 0), wxDefaultSize, wxBORDER_NONE), m_scaleMode(aScale)
RenderWindow::RenderWindow(wxWindow* parent, const wxString& aPath, const bool aRecursive, const Config::SCALE aScale,
const Config::TRANSITION aTransition)
: wxWindow(parent, wxID_ANY, wxPoint(0, 0), wxDefaultSize, wxBORDER_NONE), m_scaleMode(aScale),
m_transition(aTransition)
{
m_renderer = wxGraphicsRenderer::GetDirect2DRenderer();

Expand Down Expand Up @@ -174,12 +176,12 @@ void RenderWindow::LoadNextImage(bool forward)
m_originalImgSizes[bitmapIndex] = img.GetSize();
}

SaverFrame::SaverFrame(const wxString& aPath, const bool aRecursive, const Config::SCALE aScale, const wxPoint& aPos,
const wxSize& aSize)
SaverFrame::SaverFrame(const wxString& aPath, const bool aRecursive, const Config::SCALE aScale,
const Config::TRANSITION aTransition, const wxPoint& aPos, const wxSize& aSize)
: wxFrame(nullptr, wxID_ANY, "MultiScreenSaver", aPos, aSize, 0 /*wxSTAY_ON_TOP */)
{
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
renderer = new RenderWindow(this, aPath, aRecursive, aScale);
renderer = new RenderWindow(this, aPath, aRecursive, aScale, aTransition);
sizer->Add(renderer, 1, wxGROW, 0);
SetSizer(sizer);
Layout();
Expand Down
Loading

0 comments on commit 70d074d

Please sign in to comment.