Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

Issue #8: Finder toolbar and Downloads groups, Quick Look, Screenshot, Photos

Eternity0706288b4522839f71
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index 290a28f..bd9c43c 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -795,3 +795,9 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
[2026-11-20 22:30] Issue #5: mostrar arquivos ocultos no Finder. Ctrl+Shift+. (Cmd+Shift+. no Mac) ou o menu do fundo da pasta "Mostrar Arquivos Ocultos" (com ✓); guardado nas opções do Finder (ocultos=1). Mostra os ocultos e os nomes com ponto; os protegidos do sistema (ocultos E de sistema: desktop.ini, $Recycle.Bin) continuam escondidos, como no Explorador. 4 frases novas nos 12 idiomas. Compilado e instalado; não testado clicando (a janela do Finder aberta no PC ainda é a versão antiga).
[2026-11-20 23:25] Dock: arrastar atalhos e programas para fixar (Reddit, dougnite: "preciso abrir todos os programas e fixar"). Soltos no Dock (nos apps, no separador, no Launchpad ou no vão entre ícones; não na Lixeira nem nos Downloads), .lnk/.exe/.url/.appref-ms ficam fixos antes do app embaixo do mouse (apps::PinPath em apps.cpp; o destino e o AUMID do atalho como na primeira carga da barra de tarefas). Já no Dock (mesmo id ou mesmo .exe): só fixa. Atalho para pasta/documento não conta. Com qualquer arquivo que não é programa, vale o de antes (abrir com o app embaixo / apagar na Lixeira). Compilado e instalado; NÃO testado arrastando (sem SendInput no PC).
[2026-11-20 23:48] MODO "SÓ O DOCK E A BARRA DE MENUS" (Reddit, anybody001; ajuste modo=dock, Ajustes > Geral > Modo do WacOS). shell::SoDock() lido na partida: fica a barra de menus (Central de Controle, Notificações, Spotlight), o Dock (Launchpad, gênio, Mission Control), a Ilha (se ligada), o vigia (mesa::Start) e o limite das janelas. Fora: a nossa mesa (mesa.cpp força explorer=1: a área de trabalho e os ícones do Windows; sem Explorador ele é aberto), widgets, barras de título (janelas/dialogs/sombras/encaixe), Finder nas pastas (pastas::Start; o Ajustes desliga finder_padrao e guarda o de antes em finder_padrao_antes, que volta no modo completo), clique na mesa, ponteiro grande, Organizador Visual, tela de bloqueio, Cantos Ativos, Nota Rápida, janela de cópia, App Nap, e o gancho de teclado deixa passar tudo (tecla Windows = Iniciar, Alt+Tab e captura de tela do Windows; volume continua). Trocar o modo reinicia o Shell. Testado no PC: com modo=dock o log mostra "modo: só Dock", "mesa própria não" e nenhuma barra de título; voltou para o completo (modo= vazio, igual ao padrão) com a mesa e as barras de volta. Não testado: a troca pelo próprio Ajustes.
+[2026-11-21 00:40] Issue #8, Finder / Quick Look / Captura / Fotos (branch claude/issue8-finder-ql-06414b). Nada no registro do Windows; DESFAZER: reverter o commit.
+ Finder: (1) ícone Compartilhar redesenhado (caixa de cantos redondos, traço 1,4 como os vizinhos, centrado) e, no Golden Gate/Tahoe, Compartilhar e Etiquetas com 33 e o ⋯ com 41 (antes 37 cada: Compartilhar parecia longe da etiqueta). (2) Agrupar por "Data de Adição" (Hoje, Ontem, Últimos 7 Dias, Últimos 30 Dias, os meses deste ano, os anos; pela data de criação do arquivo): padrão na Downloads; escolher outro grupo ali fica só para a Downloads (grupoDownloads em %APPDATA%\Arquivos\opcoes.txt), as outras pastas seguem com o grupo de sempre.
+ Quick Look (Shell, src\shell\quicklook.cpp, e o painel próprio do Finder): (3) botão de tela cheia com o SF Symbol arrow.up.left.and.arrow.down.right (para dentro em tela cheia). (4) dica (tooltip) do Mac nos botões do painel e da barra de mídia (src\comum\dica.h, novo). (5) barra de mídia estreita (vídeo em pé): o volume encolhe, AirPlay/legendas somem e os tempos ficam curtos, nada mais um em cima do outro; painel de vídeo com pelo menos 420 de largura. (6) travamento: a miniatura de vídeo não é mais pedida na thread da interface do Shell (decodificava um quadro e travava a Dock/barra); a barra de controles só reordena as janelas quando aparece/o painel mexe (antes 15×/s, fazendo o vidro real remontar); PrintWindow do fundo borrado no máximo 10×/s (barra_video.h, vale para o QuickTime); vídeo que não abre (erro ou 8 s sem resposta) para o player e fica a prévia; no Finder o timer do vídeo para se o vídeo falhar. (7) zoom com a roda do mouse nas fotos (1 a 8×, em volta do ponteiro) e arrastar para mover com zoom, no Shell e no painel do Finder. (8) PDF (1ª página pelo Windows.Data.Pdf) e SVG (SVG do Direct2D) no Quick Look; Word/PowerPoint/Excel/fontes pelo preview handler do Windows numa janela por cima do painel, se o PC tiver um (o Office instala), senão o ícone. Nos temas sem Golden Gate o Finder manda PDF/SVG/Office para o Quick Look do Shell. ICNS: não feito.
+ Captura de Tela: (9) Opções › Salvar em ganhou "Imagens › Capturas de Tela" (FOLDERID_Screenshots, criada se faltar) e "Outro Local…" (escolhe a pasta; ela aparece com o nome no menu; captura.txt: destino=3/4 e outro=<pasta>). (10) abrir (clique na miniatura, Abrir e Editar) vai para a Pré-Visualização da instalação atual (CreateProcess), não para as Fotos. (11) barra de título: a Captura residente segue rodando de SequoiaBinariosAntigos depois de uma atualização; agora acha a pasta do exe pelo processo do Shell (ou Programs\WacOS\bin) para a Pré-Visualização e o Finder. As "Fotos" que perdiam a barra eram as Fotos do Windows (app padrão do .png), que não recebem a barra do Mac: com o item 10 elas não abrem mais.
+ Fotos: (12) a navegação ←/→ é da Pré-Visualização e já era só da mesma pasta (nada mudou). (13) ícone da barra lateral = SF Symbol sidebar.left em todos os apps do app2d.h (Fotos, Contatos, Tempo, Calendário, Lembretes). (14) barra de cima: ajustar/preencher os quadrados, menu de ordem (Mais Antigas/Recentes Primeiro) e menu ⋯ (Abrir, Mostrar no Finder, Mover para o Lixo, Mostrar/Ocultar Barra Lateral, Atualizar a Biblioteca); o 4º botão virou o lápis (abre o editor, onde estão Girar/Recortar); os quatro botões de foto ficam cinza sem foto escolhida.
+ 19 frases novas nos 12 idiomas. Testado: PDF e SVG renderizados por um programa de teste com o mesmo código (265 ms / 16 ms); Fotos pelo --foto; Finder da Downloads aberto (grupos e ícones da barra parcialmente visíveis). NÃO testado ao vivo: o Quick Look do Shell (outra sessão instalou o Shell dela logo depois do meu), dicas, zoom, vídeo em pé/CPU, preview handler (sem Office no PC), Captura (precisaria tirar print da tela do usuário).
diff --git a/src/captura/main.cpp b/src/captura/main.cpp
index a613405..c444cb4 100644
--- a/src/captura/main.cpp
+++ b/src/captura/main.cpp
@@ -42,7 +42,7 @@
#include "../comum/nomes.h"
#include "../comum/simbolos.h"
#include "../menu/context_menu.h"
-#include "../comum/idioma.h"
+#include "../comum/idioma.h"
#pragma comment(lib, "windowsapp.lib")
#pragma comment(lib, "winmm.lib")
@@ -79,7 +79,9 @@ template <class T> static void Rel(T*& p) { if (p) { p->Release(); p = nullptr;
// ---------------------------------------------------------------- opções (Shell\captura.txt)
struct Cfg {
- int dest = 0; // 0 Mesa, 1 Documentos, 2 Área de Transferência
+ // 0 Mesa, 1 Documentos, 2 Área de Transferência, 3 Imagens › Capturas de Tela, 4 Outro Local (pasta em "outro")
+ int dest = 0;
+ std::wstring other;
int timer = 0; // 0, 5, 10 segundos
int mode = 2; // última ferramenta da barra: 0 tela inteira, 1 janela, 2 região
bool thumb = true, remember = true, pointer = false, hasSel = false;
@@ -103,7 +105,8 @@ static void LoadCfg() {
if (eq == std::wstring::npos || s[0] == L'#') continue;
std::wstring k = s.substr(0, eq), v = s.substr(eq + 1);
int n = _wtoi(v.c_str());
- if (k == L"destino") g_cfg.dest = std::clamp(n, 0, 2);
+ if (k == L"destino") g_cfg.dest = std::clamp(n, 0, 4);
+ else if (k == L"outro") g_cfg.other = v;
else if (k == L"temporizador") g_cfg.timer = n == 5 || n == 10 ? n : 0;
else if (k == L"modo") g_cfg.mode = std::clamp(n, 0, 2);
else if (k == L"miniatura") g_cfg.thumb = n != 0;
@@ -126,6 +129,7 @@ static void SaveCfg() {
fwprintf(fp, L"# Captura de Tela (WacOSScreenshot.exe): opções do menu Opções da barra (Win+Shift+5)\n");
fwprintf(fp, L"destino=%d\ntemporizador=%d\nmodo=%d\nminiatura=%d\nlembrar=%d\nponteiro=%d\n", g_cfg.dest, g_cfg.timer, g_cfg.mode, g_cfg.thumb, g_cfg.remember, g_cfg.pointer);
if (g_cfg.hasSel) fwprintf(fp, L"selecao=%ld,%ld,%ld,%ld\n", g_cfg.sel.left, g_cfg.sel.top, g_cfg.sel.right, g_cfg.sel.bottom);
+ if (!g_cfg.other.empty()) fwprintf(fp, L"outro=%ls\n", g_cfg.other.c_str());
fclose(fp);
}
@@ -565,11 +569,88 @@ static void Shutter() {
PlaySoundW((g_root + L"\\sons\\mac\\Screen_Capture.wav").c_str(), nullptr, SND_FILENAME | SND_ASYNC | SND_NODEFAULT);
}
-static std::wstring DestFolder() {
+// Onde a captura vai (issue #8): Mesa, Documentos, Imagens › Capturas de Tela (a pasta "Screenshots" do Windows,
+// criada se não existir) ou a pasta escolhida em "Outro Local…" (se ela sumiu: Capturas de Tela)
+static std::wstring Known(REFKNOWNFOLDERID id, DWORD flags = 0) {
PWSTR p = nullptr; std::wstring d;
- if (SUCCEEDED(SHGetKnownFolderPath(g_cfg.dest == 1 ? FOLDERID_Documents : FOLDERID_Desktop, 0, nullptr, &p))) { d = p; CoTaskMemFree(p); }
+ if (SUCCEEDED(SHGetKnownFolderPath(id, flags, nullptr, &p))) d = p;
+ CoTaskMemFree(p);
+ return d;
+}
+static std::wstring ShotsFolder() {
+ std::wstring d = Known(FOLDERID_Screenshots, KF_FLAG_CREATE);
+ if (d.empty()) { d = Known(FOLDERID_Pictures); if (!d.empty()) { d += L"\\Screenshots"; CreateDirectoryW(d.c_str(), nullptr); } }
return d;
}
+static std::wstring DestFolder() {
+ if (g_cfg.dest == 4 && !g_cfg.other.empty()) {
+ DWORD a = GetFileAttributesW(g_cfg.other.c_str());
+ if (a != INVALID_FILE_ATTRIBUTES && (a & FILE_ATTRIBUTE_DIRECTORY)) return g_cfg.other;
+ Logf(L"Outro Local sumiu (%ls): vai para Capturas de Tela", g_cfg.other.c_str());
+ }
+ if (g_cfg.dest == 3 || g_cfg.dest == 4) { std::wstring d = ShotsFolder(); if (!d.empty()) return d; }
+ return Known(g_cfg.dest == 1 ? FOLDERID_Documents : FOLDERID_Desktop);
+}
+
+// "Outro Local…": escolher a pasta (o Abrir do Windows, que o WacOS troca pelo Finder quando ligado)
+static bool PickOtherFolder(HWND owner) {
+ IFileOpenDialog* d = nullptr;
+ if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&d))) || !d) return false;
+ DWORD o = 0; d->GetOptions(&o);
+ d->SetOptions(o | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST);
+ d->SetTitle(Tr(L"Salvar Capturas de Tela em"));
+ IShellItem* start = nullptr;
+ std::wstring cur = DestFolder();
+ if (!cur.empty() && SUCCEEDED(SHCreateItemFromParsingName(cur.c_str(), nullptr, IID_PPV_ARGS(&start))) && start) { d->SetFolder(start); start->Release(); }
+ bool ok = false;
+ if (SUCCEEDED(d->Show(owner))) {
+ IShellItem* it = nullptr;
+ if (SUCCEEDED(d->GetResult(&it)) && it) {
+ PWSTR p = nullptr;
+ if (SUCCEEDED(it->GetDisplayName(SIGDN_FILESYSPATH, &p)) && p) { g_cfg.other = p; CoTaskMemFree(p); ok = true; }
+ it->Release();
+ }
+ }
+ d->Release();
+ return ok;
+}
+
+// Abrir a captura na Pré-Visualização, como no Mac (antes ia para o app padrão de imagens: as Fotos do Windows).
+// O exe vem da pasta da instalação atual (o Shell sabe qual é: a janela de mensagens dele), não da pasta deste
+// processo: a Captura residente continua rodando depois de uma atualização, de dentro de SequoiaBinariosAntigos,
+// onde a Pré-Visualização não existe com o nome certo nem tem a WacOSWindow.dll ao lado (sem a barra do Mac)
+static std::wstring AppDir() {
+ if (HWND sh = FindWindowW(L"ShellMensagens", nullptr)) {
+ DWORD pid = 0; GetWindowThreadProcessId(sh, &pid);
+ if (HANDLE pr = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid)) {
+ wchar_t p[MAX_PATH]; DWORD n = MAX_PATH;
+ std::wstring d;
+ if (QueryFullProcessImageNameW(pr, 0, p, &n)) { d = p; d = d.substr(0, d.find_last_of(L'\\')); }
+ CloseHandle(pr);
+ if (!d.empty() && GetFileAttributesW((d + L"\\" EXE_PREVIEW).c_str()) != INVALID_FILE_ATTRIBUTES) return d;
+ }
+ }
+ if (GetFileAttributesW((g_dir + L"\\" EXE_PREVIEW).c_str()) != INVALID_FILE_ATTRIBUTES) return g_dir;
+ std::wstring inst = Known(FOLDERID_LocalAppData) + L"\\Programs\\WacOS\\bin"; // a instalação padrão
+ if (GetFileAttributesW((inst + L"\\" EXE_PREVIEW).c_str()) != INVALID_FILE_ATTRIBUTES) return inst;
+ return g_dir;
+}
+static void OpenShot(const std::wstring& path) {
+ std::wstring pv = AppDir() + L"\\" EXE_PREVIEW;
+ bool own = GetFileAttributesW(pv.c_str()) != INVALID_FILE_ATTRIBUTES;
+ Logf(L"abrir %ls em %ls", path.c_str(), own ? pv.c_str() : L"(app padrão)");
+ if (own) {
+ // pelo CreateProcess, com a pasta do exe como pasta atual (a DLL da barra do Mac é a do lado dele)
+ std::wstring cmd = L"\"" + pv + L"\" \"" + path + L"\"", dir = pv.substr(0, pv.find_last_of(L'\\'));
+ STARTUPINFOW si{ sizeof(si) }; PROCESS_INFORMATION pi{};
+ if (CreateProcessW(pv.c_str(), cmd.data(), nullptr, nullptr, FALSE, 0, nullptr, dir.c_str(), &si, &pi)) {
+ AllowSetForegroundWindow(pi.dwProcessId);
+ CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
+ return;
+ }
+ }
+ ShellExecuteW(nullptr, L"open", path.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+}
static void ShowThumb(const Img& im, const std::wstring& path, const Mon& m);
static void DismissThumb();
@@ -1103,7 +1184,12 @@ static void ShowOptions() {
items.push_back(header(Tr(L"Salvar em")));
items.push_back(item(Tr(L"Mesa"), 101, g_cfg.dest == 0));
items.push_back(item(Tr(L"Documentos"), 102, g_cfg.dest == 1));
+ items.push_back(item(Tr(L"Imagens › Capturas de Tela"), 104, g_cfg.dest == 3));
items.push_back(item(Tr(L"Área de Transferência"), 103, g_cfg.dest == 2));
+ std::wstring otherName; // a pasta escolhida em "Outro Local…" aparece com o nome dela, como no Mac
+ if (!g_cfg.other.empty()) { otherName = g_cfg.other.substr(g_cfg.other.find_last_of(L'\\') + 1); if (otherName.empty()) otherName = g_cfg.other; }
+ if (!otherName.empty()) items.push_back(item(otherName.c_str(), 106, g_cfg.dest == 4));
+ items.push_back(item(Tr(L"Outro Local…"), 105, false));
items.push_back(sep());
items.push_back(header(Tr(L"Temporizador")));
items.push_back(item(Tr(L"Nenhum"), 201, g_cfg.timer == 0));
@@ -1123,6 +1209,9 @@ static void ShowOptions() {
case 101: g_cfg.dest = 0; break;
case 102: g_cfg.dest = 1; break;
case 103: g_cfg.dest = 2; break;
+ case 104: g_cfg.dest = 3; break;
+ case 106: g_cfg.dest = 4; break;
+ case 105: if (PickOtherFolder(o.h)) g_cfg.dest = 4; else id = 0; break;
case 201: g_cfg.timer = 0; break;
case 202: g_cfg.timer = 5; break;
case 203: g_cfg.timer = 10; break;
@@ -1441,11 +1530,11 @@ static void ThumbMenu(HWND h) {
if (!g_thumb) return;
std::wstring path = g_thumb->path;
switch (id) {
- case 1: ShellExecuteW(nullptr, L"open", path.c_str(), nullptr, nullptr, SW_SHOWNORMAL); DestroyThumb(); return;
- case 2: if ((INT_PTR)ShellExecuteW(nullptr, L"edit", path.c_str(), nullptr, nullptr, SW_SHOWNORMAL) <= 32) ShellExecuteW(nullptr, L"open", path.c_str(), nullptr, nullptr, SW_SHOWNORMAL); DestroyThumb(); return;
+ case 1: OpenShot(path); DestroyThumb(); return;
+ case 2: OpenShot(path); DestroyThumb(); return; // Editar: a marcação é da Pré-Visualização, como no Mac
case 3: {
std::wstring folder = path.substr(0, path.find_last_of(L'\\'));
- std::wstring finder = g_dir + L"\\" EXE_FINDER;
+ std::wstring finder = AppDir() + L"\\" EXE_FINDER;
if (GetFileAttributesW(finder.c_str()) != INVALID_FILE_ATTRIBUTES) ShellExecuteW(nullptr, L"open", finder.c_str(), (L"\"" + folder + L"\"").c_str(), nullptr, SW_SHOWNORMAL);
else ShellExecuteW(nullptr, L"open", folder.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
ThumbOut();
@@ -1523,9 +1612,9 @@ static LRESULT CALLBACK ThumbProc(HWND h, UINT m, WPARAM w, LPARAM l) {
t.swipe = false;
if (t.off > 30 * t.sc) ThumbOut(); else t.off = 0;
ThumbPlace();
- } else if (!t.decided) { // clique: abre (Fotos) e a miniatura some
+ } else if (!t.decided) { // clique: abre na Pré-Visualização (como no Mac) e a miniatura some
Logf(L"miniatura: abrir %ls", t.path.c_str());
- ShellExecuteW(nullptr, L"open", t.path.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ OpenShot(t.path);
DestroyThumb();
}
return 0;
diff --git a/src/comum/app2d.h b/src/comum/app2d.h
index ff644b2..0997389 100644
--- a/src/comum/app2d.h
+++ b/src/comum/app2d.h
@@ -23,6 +23,7 @@
#include "idioma.h"
#include "semaforo.h" // semaforo::Aqua(): tema macOS Golden Gate
#include "barra_mac.h" // a WacOSWindow.dll carregada pelo próprio app (barra do Mac sem o Shell)
+#include "simbolos.h" // SF Symbols (icones\simbolos): o ícone da barra lateral igual ao do Notas e do Finder
#include <commctrl.h>
#include <shellapi.h>
#pragma comment(lib, "comctl32.lib")
@@ -162,8 +163,17 @@ inline void GlassField(D2D1_RECT_F r, bool dark) {
rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(r.left + 0.25f, r.top + 0.25f, r.right - 0.25f, r.bottom - 0.25f), rad - 0.25f, rad - 0.25f), br, 0.5f);
}
// ícone de "barra lateral" (retângulo com a coluna da esquerda e três tracinhos) e lupa, desenhados
+// o botão "barra lateral": o SF Symbol sidebar.left (18 × 14, o peso normal do Mac, o mesmo do Notas). O desenho
+// antigo, de traço 1,5, parecia em negrito ao lado dos outros apps (issue #8: Fotos, Contatos, Tempo); fica só
+// se o .svg não estiver na instalação
inline void IconSidebar(D2D1_POINT_2F c, D2D1_COLOR_F col) {
br->SetColor(col);
+ if (simbolo::Dir().empty()) {
+ wchar_t exe[MAX_PATH] = {}; GetModuleFileNameW(nullptr, exe, MAX_PATH);
+ std::wstring d = exe; d = d.substr(0, d.find_last_of(L'\\')); // ...\bin
+ simbolo::Dir() = d.substr(0, d.find_last_of(L'\\')) + L"\\icones\\simbolos";
+ }
+ if (simbolo::Draw(rt, L"sidebar.left", D2D1::RectF(c.x - 9, c.y - 7, c.x + 9, c.y + 7), br)) return;
D2D1_RECT_F r = D2D1::RectF(c.x - 9, c.y - 7, c.x + 9, c.y + 7);
rt->DrawRoundedRectangle(D2D1::RoundedRect(r, 3, 3), br, 1.5f);
rt->DrawLine({ c.x - 3, r.top }, { c.x - 3, r.bottom }, br, 1.5f);
diff --git a/src/comum/barra_video.h b/src/comum/barra_video.h
index b02029b..4543ec4 100644
--- a/src/comum/barra_video.h
+++ b/src/comum/barra_video.h
@@ -59,6 +59,13 @@ inline void Desenha(ID2D1RenderTarget* rt2, ID2D1SolidColorBrush* b, float W, fl
};
const D2D1_COLOR_F ic = D2D1::ColorF(1, 1, 1, 0.86f);
float cy = 30.5f, cx = W / 2;
+ // Barra mais estreita que os 458 do QuickTime (vídeo em pé, painel pequeno): as medidas do Mac são fixas a partir das
+ // bordas e o volume, o AirPlay e as legendas iam parar em cima de ⏪ ⏩ (issue #8: "ícones um em cima do outro").
+ // Agora o trilho do volume encolhe até o ⏪, e AirPlay/legendas somem quando não cabem antes do ⏩
+ const float midL = cx - 41 - 11 - 12, midR = cx + 39 + 11 + 12; // ⏪ ⏵ ⏩ com folga
+ const bool showAir = W - 124.5f - 10 > midR, showSub = W - 81 - 10 > midR;
+ const float volR = std::min(117.5f, midL);
+ const bool volOn = volR - 40.5f >= 24;
// alto-falante (corpo cheio) e as ondas conforme o volume
b->SetColor(ic);
fill([&](ID2D1GeometrySink* sk) {
@@ -75,9 +82,11 @@ inline void Desenha(ID2D1RenderTarget* rt2, ID2D1SolidColorBrush* b, float W, fl
sk->EndFigure(D2D1_FIGURE_END_OPEN);
}, 1.4f);
}
- D2D1_RECT_F vol = D2D1::RectF(40.5f, cy - 2.5f, 117.5f, cy + 2.5f);
- track(vol, volume);
- hits.push_back({ VOL, D2D1::RectF(vol.left - 6, cy - 12, vol.right + 6, cy + 12) });
+ if (volOn) {
+ D2D1_RECT_F vol = D2D1::RectF(40.5f, cy - 2.5f, volR, cy + 2.5f);
+ track(vol, volume);
+ hits.push_back({ VOL, D2D1::RectF(vol.left - 6, cy - 12, vol.right + 6, cy + 12) });
+ }
// ⏪ ⏵/⏸ ⏩: triângulos cheios
b->SetColor(ic);
float bx = cx - 41, fx = cx + 39;
@@ -104,12 +113,15 @@ inline void Desenha(ID2D1RenderTarget* rt2, ID2D1SolidColorBrush* b, float W, fl
// AirPlay (tela com o triângulo), legendas (balão com linhas) e » (mais / tela cheia)
b->SetColor(D2D1::ColorF(1, 1, 1, 0.78f));
float ax = W - 124.5f, sx = W - 81, mx = W - 26;
+ if (showAir) {
stroke([&](ID2D1GeometrySink* sk) {
sk->BeginFigure({ ax - 4.5f, cy + 5.5f }, D2D1_FIGURE_BEGIN_HOLLOW);
sk->AddLine({ ax - 9.f, cy + 5.5f }); sk->AddLine({ ax - 9.f, cy - 7.f }); sk->AddLine({ ax + 9.f, cy - 7.f }); sk->AddLine({ ax + 9.f, cy + 5.5f }); sk->AddLine({ ax + 4.5f, cy + 5.5f });
sk->EndFigure(D2D1_FIGURE_END_OPEN);
}, 1.3f);
tri({ ax, cy + 1.f }, { ax + 5.f, cy + 8.f }, { ax - 5.f, cy + 8.f });
+ }
+ if (showSub) {
stroke([&](ID2D1GeometrySink* sk) {
sk->BeginFigure({ sx - 6.f, cy + 5.f }, D2D1_FIGURE_BEGIN_HOLLOW);
sk->AddLine({ sx - 7.f, cy + 5.f });
@@ -125,6 +137,7 @@ inline void Desenha(ID2D1RenderTarget* rt2, ID2D1SolidColorBrush* b, float W, fl
}, 1.3f);
rt2->DrawLine({ sx - 5.f, cy - 1.5f }, { sx + 5.f, cy - 1.5f }, b, 1.2f);
rt2->DrawLine({ sx - 5.f, cy + 1.5f }, { sx + 2.f, cy + 1.5f }, b, 1.2f);
+ }
stroke([&](ID2D1GeometrySink* sk) {
for (float o : { -3.5f, 2.5f }) {
sk->BeginFigure({ mx + o - 2.5f, cy - 5.5f }, D2D1_FIGURE_BEGIN_HOLLOW);
@@ -138,10 +151,14 @@ inline void Desenha(ID2D1RenderTarget* rt2, ID2D1SolidColorBrush* b, float W, fl
auto tc = [](double v) { v = std::max(0.0, v); int t2 = (int)v, fr = (int)((v - t2) * 30); wchar_t s2[24]; swprintf_s(s2, L"%02d:%02d:%02d:%02d", t2 / 3600, t2 / 60 % 60, t2 % 60, fr); return std::wstring(s2); };
float by = 73;
b->SetColor(D2D1::ColorF(1, 1, 1, 0.72f));
- std::wstring a1 = tc(pos), a2 = tc(len);
- rt2->DrawTextW(a1.c_str(), (UINT32)a1.size(), tfL, D2D1::RectF(17, by - 10, 120, by + 10), b);
- rt2->DrawTextW(a2.c_str(), (UINT32)a2.size(), tfR, D2D1::RectF(W - 120, by - 10, W - 17, by + 10), b);
- D2D1_RECT_F bar = D2D1::RectF(113.5f, by - 2.5f, W - 113, by + 2.5f);
+ // estreita: os tempos curtos (m:ss) e a linha do tempo mais comprida, para ela não sumir entre eles
+ bool shortTc = W - 113 - 113.5f < 120;
+ auto mss = [](double v) { int t2 = (int)std::max(0.0, v); wchar_t s2[24]; swprintf_s(s2, L"%d:%02d", t2 / 60, t2 % 60); return std::wstring(s2); };
+ std::wstring a1 = shortTc ? mss(pos) : tc(pos), a2 = shortTc ? mss(len) : tc(len);
+ float tw = shortTc ? 44.f : 103.f;
+ rt2->DrawTextW(a1.c_str(), (UINT32)a1.size(), tfL, D2D1::RectF(17, by - 10, 17 + tw, by + 10), b);
+ rt2->DrawTextW(a2.c_str(), (UINT32)a2.size(), tfR, D2D1::RectF(W - 17 - tw, by - 10, W - 17, by + 10), b);
+ D2D1_RECT_F bar = shortTc ? D2D1::RectF(17 + tw + 8, by - 2.5f, W - 17 - tw - 8, by + 2.5f) : D2D1::RectF(113.5f, by - 2.5f, W - 113, by + 2.5f);
track(bar, len > 0 ? (float)std::clamp(pos / len, 0.0, 1.0) : 0.f);
hits.push_back({ SCRUB, D2D1::RectF(bar.left, by - 12, bar.right, by + 12) });
if (fac) fac->Release();
@@ -171,7 +188,9 @@ inline bool FundoBorrado(ID2D1RenderTarget* rt, HWND src, RECT scr, float sc, D2
SelectObject(mem, bmp); bw = ww; bh = wh; last = nullptr;
}
DWORD now = GetTickCount();
- if (last != src || now - at > 25) {
+ // a foto da janela (PrintWindow com PW_RENDERFULLCONTENT faz o DWM compor o vídeo) no máximo 10×/s: o fundo
+ // borrado não precisa de mais, e a 40×/s pesava na CPU com o vídeo tocando (issue #8)
+ if (last != src || now - at > 100) {
if (!PrintWindow(src, mem, 2 /*PW_RENDERFULLCONTENT*/)) return false;
GdiFlush(); last = src; at = now;
}
diff --git a/src/comum/dica.h b/src/comum/dica.h
new file mode 100644
index 0000000..9e30eb6
--- /dev/null
+++ b/src/comum/dica.h
@@ -0,0 +1,138 @@
+#pragma once
+// Dica (tooltip) do Mac ao parar o mouse num botão: um balão claro (escuro no tema escuro) de cantos 5, texto de 11,5
+// e sombra curta, logo abaixo do ponteiro, depois de ~0,7 s parado (ou na hora, passando de um botão a outro com a
+// dica já aberta). Janela em camadas própria (WacOSDica), sem foco e sem receber o mouse. Quem usa: o Quick Look do
+// Shell (src\shell\quicklook.cpp) e o do Finder (issue #8: "mostrar o texto do que o ícone faz").
+// no WM_MOUSEMOVE: dica::Quer(hwnd, Tr(L"Fechar"), escuro) (texto vazio = nenhum botão sob o mouse)
+// no WM_MOUSELEAVE / clique / fechar: dica::Esconde()
+#include <windows.h>
+#include <d2d1.h>
+#include <dwrite.h>
+#include <string>
+#include <algorithm>
+#include <cmath>
+#pragma comment(lib, "d2d1.lib")
+#pragma comment(lib, "dwrite.lib")
+
+namespace dica {
+
+struct Estado { HWND dono = nullptr, wnd = nullptr; std::wstring quer, mostra; bool escuro = false; };
+inline Estado& S() { static Estado s; return s; }
+const UINT_PTR TIMER = 0x51D1;
+
+inline void Esconde() {
+ Estado& s = S();
+ if (s.dono) KillTimer(s.dono, TIMER);
+ s.quer.clear(); s.mostra.clear();
+ if (s.wnd) ShowWindow(s.wnd, SW_HIDE);
+}
+
+inline IDWriteTextFormat* Fonte() {
+ static IDWriteTextFormat* tf = nullptr;
+ static bool feito = false;
+ if (feito) return tf;
+ feito = true;
+ IDWriteFactory* dw = nullptr;
+ if (FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&dw)) || !dw) return nullptr;
+ const wchar_t* fam = L"Segoe UI";
+ IDWriteFontCollection* c = nullptr;
+ if (SUCCEEDED(dw->GetSystemFontCollection(&c)) && c) {
+ for (const wchar_t* f : { L"SF Pro Text", L"Inter" }) { UINT32 i; BOOL ex = FALSE; c->FindFamilyName(f, &i, &ex); if (ex) { fam = f; break; } }
+ c->Release();
+ }
+ dw->CreateTextFormat(fam, nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11.5f, L"", &tf);
+ if (tf) { tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }
+ dw->Release();
+ return tf;
+}
+
+inline LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
+ if (m == WM_MOUSEACTIVATE) return MA_NOACTIVATE;
+ if (m == WM_NCHITTEST) return HTTRANSPARENT;
+ return DefWindowProcW(h, m, w, l);
+}
+
+inline void Mostra() {
+ Estado& s = S();
+ if (s.quer.empty()) return;
+ IDWriteTextFormat* tf = Fonte();
+ static ID2D1Factory* d2d = nullptr;
+ if (!d2d) D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &d2d);
+ if (!tf || !d2d) return;
+ if (!s.wnd) {
+ HINSTANCE hi = GetModuleHandleW(nullptr);
+ WNDCLASSW wc{}; wc.lpfnWndProc = Proc; wc.hInstance = hi; wc.lpszClassName = L"WacOSDica";
+ RegisterClassW(&wc);
+ s.wnd = CreateWindowExW(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE | WS_EX_TRANSPARENT | WS_EX_TOPMOST, L"WacOSDica", L"",
+ WS_POPUP, 0, 0, 10, 10, nullptr, nullptr, hi, nullptr);
+ if (!s.wnd) return;
+ }
+ POINT cur; GetCursorPos(&cur);
+ HMONITOR mon = MonitorFromPoint(cur, MONITOR_DEFAULTTONEAREST);
+ UINT dpi = s.dono ? GetDpiForWindow(s.dono) : 96;
+ float sc = (dpi ? dpi : 96) / 96.f;
+ // largura do texto
+ float tw = 60;
+ IDWriteFactory* dw = nullptr;
+ if (SUCCEEDED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&dw)) && dw) {
+ IDWriteTextLayout* lay = nullptr;
+ if (SUCCEEDED(dw->CreateTextLayout(s.quer.c_str(), (UINT32)s.quer.size(), tf, 2000, 40, &lay)) && lay) {
+ DWRITE_TEXT_METRICS tm{}; lay->GetMetrics(&tm); tw = tm.widthIncludingTrailingWhitespace; lay->Release();
+ }
+ dw->Release();
+ }
+ const float SOM = 5; // margem da sombra
+ float W = std::ceil(tw) + 14 + 2 * SOM, H = 19 + 2 * SOM;
+ int w = (int)std::lround(W * sc), h = (int)std::lround(H * sc);
+ MONITORINFO mi{ sizeof(mi) }; GetMonitorInfoW(mon, &mi);
+ int x = cur.x - (int)std::lround((SOM + 4) * sc), y = cur.y + (int)std::lround(20 * sc) - (int)std::lround(SOM * sc);
+ x = std::clamp(x, (int)mi.rcWork.left, (int)mi.rcWork.right - w);
+ if (y + h > mi.rcWork.bottom) y = cur.y - h - (int)std::lround(4 * sc); // sem lugar embaixo: em cima do ponteiro
+ HDC screen = GetDC(nullptr), mem = CreateCompatibleDC(screen);
+ BITMAPINFO bi{}; bi.bmiHeader = { sizeof(BITMAPINFOHEADER), w, -h, 1, 32, BI_RGB };
+ void* bits = nullptr; HBITMAP bmp = CreateDIBSection(mem, &bi, DIB_RGB_COLORS, &bits, nullptr, 0);
+ HGDIOBJ old = SelectObject(mem, bmp);
+ ID2D1DCRenderTarget* rt = nullptr;
+ auto props = D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED), 96 * sc, 96 * sc);
+ if (SUCCEEDED(d2d->CreateDCRenderTarget(&props, &rt)) && rt) {
+ RECT rb{ 0, 0, w, h }; rt->BindDC(mem, &rb);
+ rt->BeginDraw(); rt->Clear(D2D1::ColorF(0, 0, 0, 0));
+ ID2D1SolidColorBrush* b = nullptr; rt->CreateSolidColorBrush(D2D1::ColorF(0, 0, 0, 0.05f), &b);
+ if (b) {
+ D2D1_RECT_F r = D2D1::RectF(SOM, SOM, W - SOM, H - SOM);
+ for (int k = 4; k >= 1; k--) { // sombra curta, mais forte embaixo
+ b->SetColor(D2D1::ColorF(0, 0, 0, s.escuro ? 0.10f : 0.05f));
+ rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(r.left - k * 0.6f, r.top - k * 0.3f, r.right + k * 0.6f, r.bottom + k * 0.9f), 5 + k * 0.6f, 5 + k * 0.6f), b);
+ }
+ b->SetColor(s.escuro ? D2D1::ColorF(0.17f, 0.17f, 0.18f, 0.98f) : D2D1::ColorF(0.965f, 0.965f, 0.965f, 0.98f));
+ rt->FillRoundedRectangle(D2D1::RoundedRect(r, 5, 5), b);
+ b->SetColor(s.escuro ? D2D1::ColorF(1, 1, 1, 0.16f) : D2D1::ColorF(0, 0, 0, 0.14f));
+ rt->DrawRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(r.left + 0.25f, r.top + 0.25f, r.right - 0.25f, r.bottom - 0.25f), 4.75f, 4.75f), b, 0.5f);
+ b->SetColor(s.escuro ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.86f));
+ rt->DrawTextW(s.quer.c_str(), (UINT32)s.quer.size(), tf, D2D1::RectF(r.left + 7, r.top, r.right, r.bottom), b);
+ b->Release();
+ }
+ rt->EndDraw(); rt->Release();
+ }
+ POINT dst{ x, y }, src{ 0, 0 }; SIZE sz{ w, h };
+ BLENDFUNCTION bf{ AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
+ UpdateLayeredWindow(s.wnd, screen, &dst, &sz, mem, &src, 0, &bf, ULW_ALPHA);
+ SelectObject(mem, old); DeleteObject(bmp); DeleteDC(mem); ReleaseDC(nullptr, screen);
+ SetWindowPos(s.wnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ s.mostra = s.quer;
+}
+
+inline void CALLBACK Tempo(HWND h, UINT, UINT_PTR id, DWORD) { KillTimer(h, id); Mostra(); }
+
+// o botão sob o mouse mudou (ou continua o mesmo: não faz nada). Texto vazio esconde.
+inline void Quer(HWND dono, const std::wstring& texto, bool escuro) {
+ Estado& s = S();
+ if (texto == s.quer && dono == s.dono) return;
+ bool aberta = !s.mostra.empty();
+ Esconde();
+ s.dono = dono; s.quer = texto; s.escuro = escuro;
+ if (texto.empty() || !dono) return;
+ SetTimer(dono, TIMER, aberta ? 30 : 700, Tempo); // já tinha dica aberta: a do botão vizinho aparece na hora
+}
+
+} // namespace dica
diff --git a/src/comum/idioma_de.inc b/src/comum/idioma_de.inc
index 5ae437f..83d8ff7 100644
--- a/src/comum/idioma_de.inc
+++ b/src/comum/idioma_de.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Vollständig" },
{ L"Só o Dock e a barra de menus", L"Nur Dock und Menüleiste" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Nur Dock und Menüleiste: Schreibtisch, Ordner, Alt+Tab, Windows-Taste, Bildschirmfotos und Titelleisten bleiben bei Windows." },
+{ L"Últimos 7 Dias", L"Vorherige 7 Tage" },
+{ L"Últimos 30 Dias", L"Vorherige 30 Tage" },
+{ L"Sair da Tela Cheia", L"Vollbildmodus beenden" },
+{ L"Compartilhar", L"Teilen" },
+{ L"Girar para a Esquerda", L"Nach links drehen" },
+{ L"Marcação", L"Markierungen" },
+{ L"Volume", L"Lautstärke" },
+{ L"Voltar 15 Segundos", L"15 Sekunden zurück" },
+{ L"Avançar 15 Segundos", L"15 Sekunden vor" },
+{ L"Ativar Som", L"Ton ein" },
+{ L"Silenciar", L"Stummschalten" },
+{ L"Imagens › Capturas de Tela", L"Bilder › Bildschirmfotos" },
+{ L"Outro Local…", L"Anderer Ort …" },
+{ L"Salvar Capturas de Tela em", L"Bildschirmfotos sichern in" },
+{ L"Mais Antigas Primeiro", L"Älteste zuerst" },
+{ L"Mais Recentes Primeiro", L"Neueste zuerst" },
+{ L"Mostrar Barra Lateral", L"Seitenleiste einblenden" },
+{ L"Ocultar Barra Lateral", L"Seitenleiste ausblenden" },
+{ L"Atualizar a Biblioteca", L"Mediathek aktualisieren" },
diff --git a/src/comum/idioma_en.inc b/src/comum/idioma_en.inc
index 6d3d0ad..8d98b48 100644
--- a/src/comum/idioma_en.inc
+++ b/src/comum/idioma_en.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Full" },
{ L"Só o Dock e a barra de menus", L"Dock and menu bar only" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Dock and menu bar only: the desktop, folders, Alt+Tab, the Windows key, screenshots and title bars stay with Windows." },
+{ L"Últimos 7 Dias", L"Previous 7 Days" },
+{ L"Últimos 30 Dias", L"Previous 30 Days" },
+{ L"Sair da Tela Cheia", L"Exit Full Screen" },
+{ L"Compartilhar", L"Share" },
+{ L"Girar para a Esquerda", L"Rotate Left" },
+{ L"Marcação", L"Markup" },
+{ L"Volume", L"Volume" },
+{ L"Voltar 15 Segundos", L"Skip Back 15 Seconds" },
+{ L"Avançar 15 Segundos", L"Skip Forward 15 Seconds" },
+{ L"Ativar Som", L"Unmute" },
+{ L"Silenciar", L"Mute" },
+{ L"Imagens › Capturas de Tela", L"Pictures › Screenshots" },
+{ L"Outro Local…", L"Other Location…" },
+{ L"Salvar Capturas de Tela em", L"Save Screenshots To" },
+{ L"Mais Antigas Primeiro", L"Oldest First" },
+{ L"Mais Recentes Primeiro", L"Newest First" },
+{ L"Mostrar Barra Lateral", L"Show Sidebar" },
+{ L"Ocultar Barra Lateral", L"Hide Sidebar" },
+{ L"Atualizar a Biblioteca", L"Refresh Library" },
diff --git a/src/comum/idioma_es.inc b/src/comum/idioma_es.inc
index b81b103..a8df289 100644
--- a/src/comum/idioma_es.inc
+++ b/src/comum/idioma_es.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Completo" },
{ L"Só o Dock e a barra de menus", L"Solo el Dock y la barra de menús" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Solo el Dock y la barra de menús: el escritorio, las carpetas, Alt+Tab, la tecla Windows, las capturas y las barras de título quedan en manos de Windows." },
+{ L"Últimos 7 Dias", L"7 días anteriores" },
+{ L"Últimos 30 Dias", L"30 días anteriores" },
+{ L"Sair da Tela Cheia", L"Salir de pantalla completa" },
+{ L"Compartilhar", L"Compartir" },
+{ L"Girar para a Esquerda", L"Girar a la izquierda" },
+{ L"Marcação", L"Marcación" },
+{ L"Volume", L"Volumen" },
+{ L"Voltar 15 Segundos", L"Retroceder 15 segundos" },
+{ L"Avançar 15 Segundos", L"Avanzar 15 segundos" },
+{ L"Ativar Som", L"Activar sonido" },
+{ L"Silenciar", L"Silenciar" },
+{ L"Imagens › Capturas de Tela", L"Imágenes › Capturas de pantalla" },
+{ L"Outro Local…", L"Otra ubicación…" },
+{ L"Salvar Capturas de Tela em", L"Guardar capturas en" },
+{ L"Mais Antigas Primeiro", L"Más antiguas primero" },
+{ L"Mais Recentes Primeiro", L"Más recientes primero" },
+{ L"Mostrar Barra Lateral", L"Mostrar barra lateral" },
+{ L"Ocultar Barra Lateral", L"Ocultar barra lateral" },
+{ L"Atualizar a Biblioteca", L"Actualizar fototeca" },
diff --git a/src/comum/idioma_fr.inc b/src/comum/idioma_fr.inc
index 6bcba74..2dcb685 100644
--- a/src/comum/idioma_fr.inc
+++ b/src/comum/idioma_fr.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Complet" },
{ L"Só o Dock e a barra de menus", L"Dock et barre des menus uniquement" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Dock et barre des menus uniquement : le bureau, les dossiers, Alt+Tab, la touche Windows, les captures et les barres de titre restent ceux de Windows." },
+{ L"Últimos 7 Dias", L"7 jours précédents" },
+{ L"Últimos 30 Dias", L"30 jours précédents" },
+{ L"Sair da Tela Cheia", L"Quitter le plein écran" },
+{ L"Compartilhar", L"Partager" },
+{ L"Girar para a Esquerda", L"Faire pivoter à gauche" },
+{ L"Marcação", L"Annotation" },
+{ L"Volume", L"Volume" },
+{ L"Voltar 15 Segundos", L"Reculer de 15 secondes" },
+{ L"Avançar 15 Segundos", L"Avancer de 15 secondes" },
+{ L"Ativar Som", L"Réactiver le son" },
+{ L"Silenciar", L"Couper le son" },
+{ L"Imagens › Capturas de Tela", L"Images › Captures d’écran" },
+{ L"Outro Local…", L"Autre emplacement…" },
+{ L"Salvar Capturas de Tela em", L"Enregistrer les captures dans" },
+{ L"Mais Antigas Primeiro", L"Les plus anciennes en premier" },
+{ L"Mais Recentes Primeiro", L"Les plus récentes en premier" },
+{ L"Mostrar Barra Lateral", L"Afficher la barre latérale" },
+{ L"Ocultar Barra Lateral", L"Masquer la barre latérale" },
+{ L"Atualizar a Biblioteca", L"Actualiser la photothèque" },
diff --git a/src/comum/idioma_it.inc b/src/comum/idioma_it.inc
index df754ad..a4d8711 100644
--- a/src/comum/idioma_it.inc
+++ b/src/comum/idioma_it.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Completa" },
{ L"Só o Dock e a barra de menus", L"Solo Dock e barra dei menu" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Solo Dock e barra dei menu: scrivania, cartelle, Alt+Tab, tasto Windows, istantanee e barre del titolo restano di Windows." },
+{ L"Últimos 7 Dias", L"7 giorni precedenti" },
+{ L"Últimos 30 Dias", L"30 giorni precedenti" },
+{ L"Sair da Tela Cheia", L"Esci da schermo intero" },
+{ L"Compartilhar", L"Condividi" },
+{ L"Girar para a Esquerda", L"Ruota a sinistra" },
+{ L"Marcação", L"Modifica" },
+{ L"Volume", L"Volume" },
+{ L"Voltar 15 Segundos", L"Indietro di 15 secondi" },
+{ L"Avançar 15 Segundos", L"Avanti di 15 secondi" },
+{ L"Ativar Som", L"Riattiva audio" },
+{ L"Silenciar", L"Disattiva audio" },
+{ L"Imagens › Capturas de Tela", L"Immagini › Istantanee schermo" },
+{ L"Outro Local…", L"Altra posizione…" },
+{ L"Salvar Capturas de Tela em", L"Salva istantanee in" },
+{ L"Mais Antigas Primeiro", L"Prima le meno recenti" },
+{ L"Mais Recentes Primeiro", L"Prima le più recenti" },
+{ L"Mostrar Barra Lateral", L"Mostra barra laterale" },
+{ L"Ocultar Barra Lateral", L"Nascondi barra laterale" },
+{ L"Atualizar a Biblioteca", L"Aggiorna libreria" },
diff --git a/src/comum/idioma_ja.inc b/src/comum/idioma_ja.inc
index 05f7b59..9b9956d 100644
--- a/src/comum/idioma_ja.inc
+++ b/src/comum/idioma_ja.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"フル" },
{ L"Só o Dock e a barra de menus", L"Dockとメニューバーのみ" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Dockとメニューバーのみ:デスクトップ、フォルダ、Alt+Tab、Windowsキー、スクリーンショット、タイトルバーはWindowsのままです。" },
+{ L"Últimos 7 Dias", L"過去7日間" },
+{ L"Últimos 30 Dias", L"過去30日間" },
+{ L"Sair da Tela Cheia", L"フルスクリーンを解除" },
+{ L"Compartilhar", L"共有" },
+{ L"Girar para a Esquerda", L"左に回転" },
+{ L"Marcação", L"マークアップ" },
+{ L"Volume", L"音量" },
+{ L"Voltar 15 Segundos", L"15秒戻る" },
+{ L"Avançar 15 Segundos", L"15秒進む" },
+{ L"Ativar Som", L"消音解除" },
+{ L"Silenciar", L"消音" },
+{ L"Imagens › Capturas de Tela", L"ピクチャ › スクリーンショット" },
+{ L"Outro Local…", L"その他の場所…" },
+{ L"Salvar Capturas de Tela em", L"スクリーンショットの保存先" },
+{ L"Mais Antigas Primeiro", L"古い順" },
+{ L"Mais Recentes Primeiro", L"新しい順" },
+{ L"Mostrar Barra Lateral", L"サイドバーを表示" },
+{ L"Ocultar Barra Lateral", L"サイドバーを非表示" },
+{ L"Atualizar a Biblioteca", L"ライブラリを更新" },
diff --git a/src/comum/idioma_ko.inc b/src/comum/idioma_ko.inc
index 18b748e..2e64f66 100644
--- a/src/comum/idioma_ko.inc
+++ b/src/comum/idioma_ko.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"전체" },
{ L"Só o Dock e a barra de menus", L"Dock과 메뉴 막대만" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Dock과 메뉴 막대만: 데스크탑, 폴더, Alt+Tab, Windows 키, 스크린샷, 제목 막대는 Windows 그대로입니다." },
+{ L"Últimos 7 Dias", L"지난 7일" },
+{ L"Últimos 30 Dias", L"지난 30일" },
+{ L"Sair da Tela Cheia", L"전체 화면 종료" },
+{ L"Compartilhar", L"공유" },
+{ L"Girar para a Esquerda", L"왼쪽으로 회전" },
+{ L"Marcação", L"마크업" },
+{ L"Volume", L"음량" },
+{ L"Voltar 15 Segundos", L"15초 뒤로" },
+{ L"Avançar 15 Segundos", L"15초 앞으로" },
+{ L"Ativar Som", L"음소거 해제" },
+{ L"Silenciar", L"음소거" },
+{ L"Imagens › Capturas de Tela", L"사진 › 스크린샷" },
+{ L"Outro Local…", L"기타 위치…" },
+{ L"Salvar Capturas de Tela em", L"스크린샷 저장 위치" },
+{ L"Mais Antigas Primeiro", L"오래된 항목 먼저" },
+{ L"Mais Recentes Primeiro", L"최근 항목 먼저" },
+{ L"Mostrar Barra Lateral", L"사이드바 보기" },
+{ L"Ocultar Barra Lateral", L"사이드바 가리기" },
+{ L"Atualizar a Biblioteca", L"보관함 새로 고침" },
diff --git a/src/comum/idioma_pl.inc b/src/comum/idioma_pl.inc
index e3d092e..7cbf664 100644
--- a/src/comum/idioma_pl.inc
+++ b/src/comum/idioma_pl.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Pełny" },
{ L"Só o Dock e a barra de menus", L"Tylko Dock i pasek menu" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Tylko Dock i pasek menu: biurko, foldery, Alt+Tab, klawisz Windows, zrzuty ekranu i paski tytułu zostają z Windows." },
+{ L"Últimos 7 Dias", L"Poprzednie 7 dni" },
+{ L"Últimos 30 Dias", L"Poprzednie 30 dni" },
+{ L"Sair da Tela Cheia", L"Zakończ pełny ekran" },
+{ L"Compartilhar", L"Udostępnij" },
+{ L"Girar para a Esquerda", L"Obróć w lewo" },
+{ L"Marcação", L"Oznaczenia" },
+{ L"Volume", L"Głośność" },
+{ L"Voltar 15 Segundos", L"Cofnij o 15 sekund" },
+{ L"Avançar 15 Segundos", L"Przewiń o 15 sekund" },
+{ L"Ativar Som", L"Wyłącz wyciszenie" },
+{ L"Silenciar", L"Wycisz" },
+{ L"Imagens › Capturas de Tela", L"Obrazy › Zrzuty ekranu" },
+{ L"Outro Local…", L"Inne miejsce…" },
+{ L"Salvar Capturas de Tela em", L"Zapisuj zrzuty w" },
+{ L"Mais Antigas Primeiro", L"Najstarsze najpierw" },
+{ L"Mais Recentes Primeiro", L"Najnowsze najpierw" },
+{ L"Mostrar Barra Lateral", L"Pokaż pasek boczny" },
+{ L"Ocultar Barra Lateral", L"Ukryj pasek boczny" },
+{ L"Atualizar a Biblioteca", L"Odśwież bibliotekę" },
diff --git a/src/comum/idioma_ru.inc b/src/comum/idioma_ru.inc
index 5bd8039..5d27d76 100644
--- a/src/comum/idioma_ru.inc
+++ b/src/comum/idioma_ru.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Полный" },
{ L"Só o Dock e a barra de menus", L"Только Dock и строка меню" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Только Dock и строка меню: рабочий стол, папки, Alt+Tab, клавиша Windows, снимки экрана и заголовки окон остаются от Windows." },
+{ L"Últimos 7 Dias", L"Предыдущие 7 дней" },
+{ L"Últimos 30 Dias", L"Предыдущие 30 дней" },
+{ L"Sair da Tela Cheia", L"Выйти из полноэкранного режима" },
+{ L"Compartilhar", L"Поделиться" },
+{ L"Girar para a Esquerda", L"Повернуть влево" },
+{ L"Marcação", L"Разметка" },
+{ L"Volume", L"Громкость" },
+{ L"Voltar 15 Segundos", L"Назад на 15 секунд" },
+{ L"Avançar 15 Segundos", L"Вперёд на 15 секунд" },
+{ L"Ativar Som", L"Включить звук" },
+{ L"Silenciar", L"Выключить звук" },
+{ L"Imagens › Capturas de Tela", L"Изображения › Снимки экрана" },
+{ L"Outro Local…", L"Другое место…" },
+{ L"Salvar Capturas de Tela em", L"Сохранять снимки в" },
+{ L"Mais Antigas Primeiro", L"Сначала старые" },
+{ L"Mais Recentes Primeiro", L"Сначала новые" },
+{ L"Mostrar Barra Lateral", L"Показать боковое меню" },
+{ L"Ocultar Barra Lateral", L"Скрыть боковое меню" },
+{ L"Atualizar a Biblioteca", L"Обновить медиатеку" },
diff --git a/src/comum/idioma_tr.inc b/src/comum/idioma_tr.inc
index 5c0e0dd..f71f3fc 100644
--- a/src/comum/idioma_tr.inc
+++ b/src/comum/idioma_tr.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"Tam" },
{ L"Só o Dock e a barra de menus", L"Yalnızca Dock ve menü çubuğu" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"Yalnızca Dock ve menü çubuğu: masaüstü, klasörler, Alt+Tab, Windows tuşu, ekran görüntüleri ve başlık çubukları Windows'ta kalır." },
+{ L"Últimos 7 Dias", L"Önceki 7 Gün" },
+{ L"Últimos 30 Dias", L"Önceki 30 Gün" },
+{ L"Sair da Tela Cheia", L"Tam Ekrandan Çık" },
+{ L"Compartilhar", L"Paylaş" },
+{ L"Girar para a Esquerda", L"Sola Döndür" },
+{ L"Marcação", L"İşaretleme" },
+{ L"Volume", L"Ses Düzeyi" },
+{ L"Voltar 15 Segundos", L"15 Saniye Geri" },
+{ L"Avançar 15 Segundos", L"15 Saniye İleri" },
+{ L"Ativar Som", L"Sesi Aç" },
+{ L"Silenciar", L"Sesi Kapat" },
+{ L"Imagens › Capturas de Tela", L"Resimler › Ekran Görüntüleri" },
+{ L"Outro Local…", L"Başka Konum…" },
+{ L"Salvar Capturas de Tela em", L"Ekran Görüntülerini Kaydet" },
+{ L"Mais Antigas Primeiro", L"Önce En Eski" },
+{ L"Mais Recentes Primeiro", L"Önce En Yeni" },
+{ L"Mostrar Barra Lateral", L"Kenar Çubuğunu Göster" },
+{ L"Ocultar Barra Lateral", L"Kenar Çubuğunu Gizle" },
+{ L"Atualizar a Biblioteca", L"Arşivi Yenile" },
diff --git a/src/comum/idioma_zh.inc b/src/comum/idioma_zh.inc
index bd62e94..8aadc4f 100644
--- a/src/comum/idioma_zh.inc
+++ b/src/comum/idioma_zh.inc
@@ -1570,3 +1570,22 @@
{ L"Completo", L"完整" },
{ L"Só o Dock e a barra de menus", L"仅程序坞和菜单栏" },
{ L"Só o Dock e a barra de menus: a área de trabalho, as pastas, o Alt+Tab, a tecla Windows, a captura de tela e as barras de título ficam com o Windows.", L"仅程序坞和菜单栏:桌面、文件夹、Alt+Tab、Windows 键、截屏和标题栏都保留 Windows 的。" },
+{ L"Últimos 7 Dias", L"前 7 天" },
+{ L"Últimos 30 Dias", L"前 30 天" },
+{ L"Sair da Tela Cheia", L"退出全屏幕" },
+{ L"Compartilhar", L"共享" },
+{ L"Girar para a Esquerda", L"向左旋转" },
+{ L"Marcação", L"标记" },
+{ L"Volume", L"音量" },
+{ L"Voltar 15 Segundos", L"后退 15 秒" },
+{ L"Avançar 15 Segundos", L"前进 15 秒" },
+{ L"Ativar Som", L"取消静音" },
+{ L"Silenciar", L"静音" },
+{ L"Imagens › Capturas de Tela", L"图片 › 截屏" },
+{ L"Outro Local…", L"其他位置…" },
+{ L"Salvar Capturas de Tela em", L"截屏存储位置" },
+{ L"Mais Antigas Primeiro", L"最旧的优先" },
+{ L"Mais Recentes Primeiro", L"最新的优先" },
+{ L"Mostrar Barra Lateral", L"显示边栏" },
+{ L"Ocultar Barra Lateral", L"隐藏边栏" },
+{ L"Atualizar a Biblioteca", L"刷新图库" },
diff --git a/src/finder/main.cpp b/src/finder/main.cpp
index 2240218..e12713d 100644
--- a/src/finder/main.cpp
+++ b/src/finder/main.cpp
@@ -44,6 +44,7 @@
#include "../comum/abrircom.h" // áudio abre no Música
#include "../comum/semaforo.h"
#include "../comum/leopard.h" // tema Mac OS X Leopard: barra metálica unificada
+#include "../comum/dica.h" // dica (tooltip) dos botões do Quick Look
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
@@ -325,12 +326,18 @@ static D2D1_RECT_F Inflate(D2D1_RECT_F r, float d) { return { r.left - d, r.top
enum class View { Icons, List, Columns, Gallery };
enum SortCol { SORT_NAME, SORT_SIZE, SORT_KIND, SORT_DATE, SORT_CREATED };
-enum GroupBy { GROUP_NONE, GROUP_KIND, GROUP_DATE, GROUP_SIZE };
+enum GroupBy { GROUP_NONE, GROUP_KIND, GROUP_DATE, GROUP_SIZE, GROUP_ADDED };
static View g_view = View::Icons;
static SortCol g_sortCol = SORT_NAME;
static bool g_sortAsc = true;
static GroupBy g_groupBy = GROUP_NONE;
+// Downloads, como no Mac: agrupada por "Data de Adição" (Hoje, Ontem, Últimos 7/30 Dias, os meses do ano e os anos)
+// até o usuário escolher outro grupo ali; essa escolha fica só para a Downloads (grupoDownloads em opcoes.txt) e as
+// outras pastas seguem com o grupo de sempre (issue #8)
+static GroupBy g_groupMain = GROUP_NONE; // o grupo das outras pastas
+static int g_groupDl = -1; // o da Downloads (-1: o padrão do Mac, Data de Adição)
+static bool g_inDownloads;
// Colunas: as pastas à esquerda da ativa são fotografias (pasta, conteúdo, qual subpasta está
// aberta, rolagem). A coluna ativa é a pasta aberta de verdade (g_folder / g_items). À direita
@@ -449,6 +456,28 @@ static std::pair<int, std::wstring> GroupOf(const Entry& e) {
if (days < 365) return { 4, Tr(L"Este ano") };
return { 5, Tr(L"Mais antigos") };
}
+ if (g_groupBy == GROUP_ADDED) { // a data em que o arquivo chegou na pasta (criação; sem ela, a modificação)
+ ULONGLONG t = e.ctime ? e.ctime : e.mtime;
+ FILETIME ft{ (DWORD)t, (DWORD)(t >> 32) }, lf;
+ SYSTEMTIME st{}, now{};
+ FileTimeToLocalFileTime(&ft, &lf); FileTimeToSystemTime(&lf, &st); GetLocalTime(&now);
+ auto day = [](SYSTEMTIME s) { // número do dia no calendário local (o "Hoje" vira à meia-noite, não 24 h depois)
+ s.wHour = s.wMinute = s.wSecond = s.wMilliseconds = 0;
+ FILETIME f{}; SystemTimeToFileTime(&s, &f);
+ return (long long)((((ULONGLONG)f.dwHighDateTime << 32) | f.dwLowDateTime) / 864000000000ULL);
+ };
+ long long d = day(now) - day(st);
+ if (d <= 0) return { 0, Tr(L"Hoje") };
+ if (d == 1) return { 1, Tr(L"Ontem") };
+ if (d < 7) return { 2, Tr(L"Últimos 7 Dias") };
+ if (d < 30) return { 3, Tr(L"Últimos 30 Dias") };
+ if (st.wYear == now.wYear) { // este ano: um grupo por mês ("Outubro"), o mais novo primeiro
+ std::wstring m = idioma::MonthName(st.wMonth);
+ if (!m.empty()) m[0] = towupper(m[0]);
+ return { 4 + (now.wMonth - st.wMonth), m };
+ }
+ return { 100 + (now.wYear - st.wYear), std::to_wstring(st.wYear) }; // anos anteriores: "2025"
+ }
if (g_groupBy == GROUP_SIZE) {
if (e.dir) return { 0, Tr(L"Pastas") };
if (e.size < 1000 * 1000) return { 1, Tr(L"Pequenos (menos de 1 MB)") };
@@ -829,11 +858,13 @@ static D2D1_RECT_F ToolRect(int k) {
float sw = std::min(307.f, std::max(160.f, (s.width - Lay::SIDEBAR_W) * 0.35f));
D2D1_RECT_F search = SearchExpanded() ? D2D1_RECT_F{ right - sw, cy - B / 2, right, cy + B / 2 } : bx(right, 36);
if (k == TB_SEARCH) return search;
- D2D1_RECT_F action = bx(search.left - G, 37);
+ // ⋯ leva a setinha ▾ (o círculo fica 7,5 à esquerda do meio): ele ganha a largura e Compartilhar/Etiquetas
+ // ficam com 33, para os três ícones ficarem a distâncias parecidas (Compartilhar parecia longe da etiqueta)
+ D2D1_RECT_F action = bx(search.left - G, 41);
if (k == TB_ACTION) return action;
- D2D1_RECT_F tag = bx(action.left, 37);
+ D2D1_RECT_F tag = bx(action.left, 33);
if (k == TB_TAG) return tag;
- D2D1_RECT_F share = bx(tag.left, 37);
+ D2D1_RECT_F share = bx(tag.left, 33);
if (k == TB_SHARE) return share;
D2D1_RECT_F group = bx(share.left - G, 47);
if (k == TB_GROUP) return group;
@@ -853,11 +884,11 @@ static D2D1_RECT_F ToolRect(int k) {
float sw = std::min(307.f, std::max(160.f, (s.width - Lay::SIDEBAR_W) * 0.35f));
D2D1_RECT_F search = SearchExpanded() ? D2D1_RECT_F{ right - sw, cy - B / 2, right, cy + B / 2 } : D2D1_RECT_F{ right - 39, cy - 19, right, cy + 19 };
if (k == TB_SEARCH) return search;
- D2D1_RECT_F action = bx(search.left - G, B);
+ D2D1_RECT_F action = bx(search.left - G, B + 4); // como no Golden Gate: o ⋯ com a setinha é mais largo
if (k == TB_ACTION) return action;
- D2D1_RECT_F tag = bx(action.left, B);
+ D2D1_RECT_F tag = bx(action.left, B - 2);
if (k == TB_TAG) return tag;
- D2D1_RECT_F share = bx(tag.left, B);
+ D2D1_RECT_F share = bx(tag.left, B - 2);
if (k == TB_SHARE) return share;
D2D1_RECT_F group = bx(share.left - G, B);
if (k == TB_GROUP) return group;
@@ -1117,6 +1148,20 @@ static void Reload() {
static int g_navMs; // tempo da última leitura de pasta (medição)
// keepColumns: navegação feita pelas próprias colunas (não recomeça a fileira de colunas).
+// Entrando ou saindo da Downloads: troca para o grupo dela (Data de Adição, ou o que o usuário escolheu ali) e volta
+// para o das outras pastas ao sair. Chamado logo depois de g_folder mudar, antes de ler a pasta.
+static std::wstring KnownFolder(REFKNOWNFOLDERID id);
+static void ApplyFolderGroup() {
+ static std::wstring dl = KnownFolder(FOLDERID_Downloads);
+ bool in = !dl.empty() && !g_folder.empty() && SamePath(g_folder, dl);
+ if (in == g_inDownloads) return;
+ g_inDownloads = in;
+ g_groupBy = in ? (g_groupDl < 0 ? GROUP_ADDED : (GroupBy)g_groupDl) : g_groupMain;
+ g_rowsDirty = true;
+}
+// a escolha de grupo atual vale para a pasta em que ela foi feita (Downloads ou as outras)
+static void NoteGroupChoice() { if (g_inDownloads) g_groupDl = (int)g_groupBy; else g_groupMain = g_groupBy; }
+
static void Navigate(const std::wstring& path, bool push = true, const std::wstring& selectName = L"", bool keepColumns = false) {
DWORD a = GetFileAttributesW(path.c_str());
// raiz de unidade recém-conectada (pendrive, HD externo): o Windows ainda está montando o volume e a primeira leitura
@@ -1138,6 +1183,7 @@ static void Navigate(const std::wstring& path, bool push = true, const std::wstr
g_galleryX = 0;
g_renameIdx = -1;
g_folder = p;
+ ApplyFolderGroup();
g_search.SetText(L"", false);
g_searchFocus = false;
g_gen++;
@@ -1990,13 +2036,33 @@ static void DrawToolIcon(ID2D1DeviceContext* dc, int k, D2D1_RECT_F r, ID2D1Brus
dc->DrawEllipse(D2D1::Ellipse(P(-2.5f, 0), 1.3f, 1.3f), b, 1.2f);
break;
}
- case TB_SHARE: // caixa aberta com seta para cima
- Line(dc, b, cx - 3, cy - 2, cx - 6, cy - 2); Line(dc, b, cx - 6, cy - 2, cx - 6, cy + 8);
- Line(dc, b, cx - 6, cy + 8, cx + 6, cy + 8); Line(dc, b, cx + 6, cy + 8, cx + 6, cy - 2);
- Line(dc, b, cx + 6, cy - 2, cx + 3, cy - 2);
- Line(dc, b, cx, cy + 3, cx, cy - 9);
- Line(dc, b, cx - 3.5f, cy - 5.5f, cx, cy - 9); Line(dc, b, cx, cy - 9, cx + 3.5f, cy - 5.5f);
+ case TB_SHARE: { // caixa aberta com seta para cima (square.and.arrow.up): cantos redondos e o traço de 1,4 dos
+ // outros botões, centrada na altura como a etiqueta. Antes era um retângulo de cantos vivos, mais alto e de
+ // traço 1,5, e destoava dos vizinhos (issue #8)
+ const float L = cx - 6, R = cx + 6, T = cy - 2.5f, B = cy + 7.5f, rr = 2.2f, gap = 2.6f;
+ ID2D1Factory* f = nullptr; dc->GetFactory(&f);
+ ID2D1PathGeometry* g = nullptr;
+ if (f && SUCCEEDED(f->CreatePathGeometry(&g))) {
+ ID2D1GeometrySink* s = nullptr;
+ if (SUCCEEDED(g->Open(&s))) {
+ auto arc = [&](float x, float y) { s->AddArc(D2D1::ArcSegment({ x, y }, { rr, rr }, 0, D2D1_SWEEP_DIRECTION_COUNTER_CLOCKWISE, D2D1_ARC_SIZE_SMALL)); };
+ s->BeginFigure({ cx - gap, T }, D2D1_FIGURE_BEGIN_HOLLOW);
+ s->AddLine({ L + rr, T }); arc(L, T + rr);
+ s->AddLine({ L, B - rr }); arc(L + rr, B);
+ s->AddLine({ R - rr, B }); arc(R, B - rr);
+ s->AddLine({ R, T + rr }); arc(R - rr, T);
+ s->AddLine({ cx + gap, T });
+ s->EndFigure(D2D1_FIGURE_END_OPEN);
+ s->Close(); s->Release();
+ dc->DrawGeometry(g, b, 1.4f, g_round);
+ }
+ g->Release();
+ }
+ if (f) f->Release();
+ Line(dc, b, cx, cy + 2.5f, cx, cy - 8.5f, 1.4f);
+ Line(dc, b, cx - 3.3f, cy - 5.2f, cx, cy - 8.5f, 1.4f); Line(dc, b, cx, cy - 8.5f, cx + 3.3f, cy - 5.2f, 1.4f);
break;
+ }
case TB_ACTION: { // círculo com reticências + seta (Leopard: a engrenagem ▾)
if (!g_tahoe && tahoe::Leopard()) {
float gx = cx - 6, gr = 5.2f;
@@ -3577,6 +3643,23 @@ static bool IsMediaFile(const Entry& e, bool* video = nullptr) {
static std::wstring g_qlMediaPath, g_qlMediaTitle, g_qlMediaArtist;
static DWORD g_qlMouseAt; // controles do vídeo somem ~2,5 s depois do último movimento
static bool g_qlSeekDrag;
+// Zoom da foto no Quick Look (issue #8): a roda amplia em volta do ponteiro (1 a 8×); ampliada, arrastar move a foto
+static float g_qlZoom = 1, g_qlPanX, g_qlPanY, g_qlPanX0, g_qlPanY0;
+static bool g_qlPanning, g_qlZoomFill;
+static D2D1_POINT_2F g_qlPanFrom;
+static D2D1_RECT_F g_qlBody; // onde a foto foi desenhada (DIP), para o zoom saber o ponto sob o mouse
+static UINT g_qlZoomW, g_qlZoomH;
+static std::wstring g_qlZoomPath;
+static void QlZoomReset() { g_qlZoom = 1; g_qlPanX = g_qlPanY = 0; g_qlPanning = false; }
+static D2D1_RECT_F QlPhotoRect(D2D1_RECT_F body, UINT iw, UINT ih, bool fill) {
+ float bw = body.right - body.left, bh = body.bottom - body.top;
+ if (!iw || !ih || bw <= 0 || bh <= 0) return body;
+ float k = (fill ? std::max(bw / iw, bh / ih) : std::min(bw / iw, bh / ih)) * g_qlZoom, w = iw * k, h = ih * k;
+ float mx = std::max(0.f, (w - bw) / 2), my = std::max(0.f, (h - bh) / 2);
+ g_qlPanX = std::clamp(g_qlPanX, -mx, mx); g_qlPanY = std::clamp(g_qlPanY, -my, my);
+ float x = body.left + (bw - w) / 2 + g_qlPanX, y = body.top + (bh - h) / 2 + g_qlPanY;
+ return D2D1::RectF(x, y, x + w, y + h);
+}
// Abre/fecha o player conforme o item do Quick Look (chamado antes de cada quadro).
static void QlSyncMedia() {
@@ -3735,11 +3818,22 @@ static void QlSyncShell() { // a seleção mudou com o Quick Look do Shell aber
QlSend(g_items[i].path); // vídeo e música também tocam no Quick Look do Shell
}
+// PDF, SVG, Word/PowerPoint/Excel e fontes: o painel daqui só teria a miniatura (ou nem isso); o Quick Look do Shell
+// desenha a página do PDF, o SVG e a prévia do Office (preview handler do Windows) em qualquer tema (issue #8)
+static bool QlNeedsShell(const Entry& e) {
+ if (e.dir) return false;
+ std::wstring x = ExtOf(e);
+ for (auto v : { L"pdf", L"svg", L"svgz", L"doc", L"docx", L"docm", L"dot", L"dotx", L"odt", L"ppt", L"pptx", L"pptm", L"pps", L"ppsx", L"odp",
+ L"xls", L"xlsx", L"xlsm", L"ods", L"vsd", L"vsdx", L"pub", L"ttf", L"otf", L"ttc" })
+ if (x == v) return true;
+ return false;
+}
+
static void QlToggle() {
if (!g_qlExtPath.empty() && QlShellWnd()) { QlSend(L""); return; }
if (g_ql) { QlClose(); return; }
if (QlItem() < 0) return;
- if (Golden() && QlSend(g_items[QlItem()].path)) return; // tudo no Quick Look do Shell (vídeo e música também)
+ if ((Golden() || QlNeedsShell(g_items[QlItem()])) && QlSend(g_items[QlItem()].path)) return; // tudo no Quick Look do Shell (vídeo e música também)
g_ql = true;
g_qlClosing = false;
g_qlFrom = IconDoc(QlItem());
@@ -3994,10 +4088,10 @@ static void DrawQuickLook(ID2D1DeviceContext* dc, const Palette& pal, ID2D1Solid
ID2D1Layer* cl = nullptr; dc->CreateLayer(nullptr, &cl);
dc->PushLayer(D2D1::LayerParameters(D2D1::InfiniteRect(), clip), cl);
auto sz = bmp->GetPixelSize();
- float k = gg ? std::max((body.right - body.left) / sz.width, (body.bottom - body.top) / sz.height) // macOS 27: a foto preenche a moldura
- : std::min((body.right - body.left) / sz.width, (body.bottom - body.top) / sz.height);
- float w = sz.width * k, h = sz.height * k, cx = (body.left + body.right) / 2, cy = (body.top + body.bottom) / 2;
- DrawBigIcon(dc, e, D2D1::RectF(cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2), br);
+ // macOS 27: a foto preenche a moldura; nos outros, cabe nela. Com zoom (roda do mouse), amplia e o arrasto move
+ if (g_qlZoomPath != e.path) { QlZoomReset(); g_qlZoomPath = e.path; }
+ g_qlBody = body; g_qlZoomFill = gg; g_qlZoomW = sz.width; g_qlZoomH = sz.height;
+ DrawBigIcon(dc, e, QlPhotoRect(body, sz.width, sz.height, gg), br);
dc->PopLayer(); cl->Release(); clip->Release(); f->Release();
} else if (text) { // texto: folha clara com fonte monoespaçada
LoadQlText(e.path);
@@ -4077,10 +4171,40 @@ static void DrawQuickLook(ID2D1DeviceContext* dc, const Palette& pal, ID2D1Solid
dc->SetTransform(old);
}
+// a foto do Quick Look aberta agora (não texto, vídeo, ícone): a roda amplia
+static bool QlZoomable() {
+ if (!g_ql || g_qlClosing || (!g_tahoe && tahoe::Leopard())) return false;
+ int i = QlItem();
+ if (i < 0) return false;
+ const Entry& e = g_items[i];
+ return !e.dir && !IsTextFile(e) && !QlMediaOn(e) && !IsMediaFile(e) && QlImage(e) && g_qlZoomPath == e.path && g_qlZoomW && g_qlBody.right > g_qlBody.left;
+}
+static bool QlWheel(D2D1_POINT_2F p, int delta) { // true: a roda foi do zoom
+ if (!QlZoomable() || !In(QlPanel(), p)) return false;
+ float z0 = g_qlZoom, z1 = std::clamp(z0 * std::pow(1.0018f, (float)delta), 1.f, 8.f);
+ if (z1 == z0) return true;
+ D2D1_RECT_F a = QlPhotoRect(g_qlBody, g_qlZoomW, g_qlZoomH, g_qlZoomFill);
+ float fx = (p.x - a.left) / std::max(1.f, a.right - a.left), fy = (p.y - a.top) / std::max(1.f, a.bottom - a.top);
+ g_qlZoom = z1;
+ D2D1_RECT_F b = QlPhotoRect(g_qlBody, g_qlZoomW, g_qlZoomH, g_qlZoomFill); // o ponto sob o mouse fica parado
+ g_qlPanX += (p.x - fx * (b.right - b.left)) - b.left;
+ g_qlPanY += (p.y - fy * (b.bottom - b.top)) - b.top;
+ if (g_qlZoom <= 1.001f) QlZoomReset();
+ dica::Esconde();
+ Invalidate();
+ return true;
+}
+
// Clique com o Quick Look aberto: true quando o clique foi no painel (consumido).
static bool QlClick(D2D1_POINT_2F p) {
if (!g_ql) return false;
if (!In(QlPanel(), p)) return false; // fora do painel: o Arquivos segue normal (como no Mac)
+ dica::Esconde();
+ if (QlZoomable() && g_qlZoom > 1.001f && In(g_qlBody, p)) { // ampliada: arrastar move a foto
+ g_qlPanning = true; g_qlPanFrom = p; g_qlPanX0 = g_qlPanX; g_qlPanY0 = g_qlPanY;
+ SetCapture(g_hwnd);
+ return true;
+ }
int i = QlItem();
if (i >= 0 && QlMediaOn(g_items[i]) && !In(D2D1::RectF(QlPanel().left, QlPanel().top, QlPanel().right, QlPanel().top + QL_TITLE_H), p)) {
bool vid = QlVideoOn(g_items[i]);
@@ -4958,7 +5082,7 @@ static void SetIconSizeFromSlider(float x) {
// Reordena depois de trocar coluna, sentido ou grupo, mantendo a seleção.
static void ResortImpl();
-static void Resort() { ResortImpl(); if (!g_reserva) SaveOptions(); }
+static void Resort() { NoteGroupChoice(); ResortImpl(); if (!g_reserva) SaveOptions(); }
static void ResortImpl() {
SortItems();
g_rowsDirty = true;
@@ -5001,7 +5125,8 @@ static POINT BelowTool(int k) { // canto de baixo à esquerda do botão, em pix
static std::vector<ctxmenu::Item> GroupItems(int base) {
auto it = [&](const wchar_t* t, GroupBy g) { ctxmenu::Item m; m.label = t; m.id = base + g; m.checked = g_groupBy == g; return m; };
ctxmenu::Item sep; sep.separator = true;
- return { it(Tr(L"Nenhum"), GROUP_NONE), sep, it(Tr(L"Tipo"), GROUP_KIND), it(Tr(L"Data de Modificação"), GROUP_DATE), it(Tr(L"Tamanho"), GROUP_SIZE) };
+ return { it(Tr(L"Nenhum"), GROUP_NONE), sep, it(Tr(L"Tipo"), GROUP_KIND), it(Tr(L"Data de Modificação"), GROUP_DATE),
+ it(Tr(L"Data de Adição"), GROUP_ADDED), it(Tr(L"Tamanho"), GROUP_SIZE) };
}
// Menu ⋯ sem seleção: o do próprio Finder (com seleção, continua o menu dos itens).
@@ -5087,10 +5212,11 @@ static void SaveOptions() {
if (_wfopen_s(&f, OptionsFile().c_str(), L"w, ccs=UTF-8") || !f) return;
fwprintf(f, L"visao=%d\nordem=%d\nascendente=%d\ngrupo=%d\nicone=%g\ntextoIcones=%g\ntextoLista=%g\nprevia=%d\n"
L"listaGrande=%d\ncolTamanho=%d\ncolTipo=%d\ncolData=%d\ncolCriacao=%d\ndatasRelativas=%d\ncolunasIcones=%d\ncolunasPrevia=%d\nbarraCaminho=%d\n",
- (int)g_defaultView, (int)g_sortCol, g_sortAsc, (int)g_groupBy, g_icon, g_labelSize, g_rowTextSize, g_showThumbs,
+ (int)g_defaultView, (int)g_sortCol, g_sortAsc, (int)g_groupMain, g_icon, g_labelSize, g_rowTextSize, g_showThumbs,
g_listLarge, g_colSize, g_colKind, g_colDate, g_colCreated, g_relDates, g_colIcons, g_colPreview, g_pick.on ? g_pathBarUser : g_pathBar);
if (g_sideWidthSet) fwprintf(f, L"larguraLateral=%g\n", Lay::SIDEBAR_W);
fwprintf(f, L"ocultos=%d\n", g_showHidden ? 1 : 0);
+ if (g_groupDl >= 0) fwprintf(f, L"grupoDownloads=%d\n", g_groupDl);
if (g_hwnd && !g_reserva && !g_pick.on && IsWindowVisible(g_hwnd)) {
// retângulo de tela de verdade (o da colocação é relativo à área de trabalho: vinha 24 px acima)
if (!IsZoomed(g_hwnd) && !IsIconic(g_hwnd)) GetWindowRect(g_hwnd, &g_savedWin);
@@ -5118,7 +5244,8 @@ static void LoadOptions() {
if (k == L"visao") g_view = g_defaultView = (View)std::clamp((int)v, 0, 3);
else if (k == L"ordem") g_sortCol = (SortCol)std::clamp((int)v, 0, (int)SORT_CREATED);
else if (k == L"ascendente") g_sortAsc = v != 0;
- else if (k == L"grupo") g_groupBy = (GroupBy)std::clamp((int)v, 0, (int)GROUP_SIZE);
+ else if (k == L"grupo") g_groupBy = g_groupMain = (GroupBy)std::clamp((int)v, 0, (int)GROUP_ADDED);
+ else if (k == L"grupoDownloads") g_groupDl = std::clamp((int)v, 0, (int)GROUP_ADDED);
else if (k == L"icone") g_icon = std::clamp((float)v, Lay::ICON_MIN, Lay::ICON_MAX);
else if (k == L"textoIcones") g_labelSize = std::clamp((float)v, 10.f, 16.f);
else if (k == L"textoLista") g_rowTextSize = std::clamp((float)v, 10.f, 16.f);
@@ -5153,6 +5280,7 @@ static const wchar_t* GroupName(GroupBy g) {
case GROUP_KIND: return Tr(L"Tipo");
case GROUP_DATE: return Tr(L"Data de Modificação");
case GROUP_SIZE: return Tr(L"Tamanho");
+ case GROUP_ADDED: return Tr(L"Data de Adição");
default: return Tr(L"Nenhum");
}
}
@@ -6200,7 +6328,25 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (g_tahoe && (ht >= 0 || g_hoverTool >= 0)) { g_toolMouse = p; Invalidate(); }
if (hs != g_hoverSide || ht != g_hoverTool || hl != g_hoverLights) { g_hoverSide = hs; g_hoverTool = ht; g_hoverLights = hl; Invalidate(); }
if (g_ql && In(QlPanel(), p)) g_qlMouseAt = GetTickCount(); // mostra os controles do vídeo
- if (g_qlSeekDrag) {
+ { // dica do botão do Quick Look sob o mouse (issue #8)
+ std::wstring tip;
+ int qi = g_ql && !g_qlClosing && !g_qlPanning ? QlItem() : -1;
+ if (qi >= 0) {
+ const Entry& e = g_items[qi];
+ if (In(QlCloseRect(), p)) tip = Tr(L"Fechar");
+ else if (In(QlShareRect(), p)) tip = Tr(L"Compartilhar");
+ else if (In(QlOpenRect(), p)) { std::wstring app = DefaultAppName(e); tip = e.dir || app.empty() ? std::wstring(Tr(L"Abrir")) : std::wstring(Tr(L"Abrir com ")) + app; }
+ else if (QlMediaOn(e) && In(QlCtlBar(), p) && (!QlVideoOn(e) || QlControlsVisible())) {
+ if (In(QlPlayRect(), p)) tip = media::Paused() ? Tr(L"Reproduzir") : Tr(L"Pausar");
+ else if (In(QlMuteRect(), p)) tip = media::Muted() ? Tr(L"Ativar Som") : Tr(L"Silenciar");
+ }
+ }
+ dica::Quer(h, tip, g_dark);
+ }
+ if (g_qlPanning) {
+ g_qlPanX = g_qlPanX0 + (p.x - g_qlPanFrom.x); g_qlPanY = g_qlPanY0 + (p.y - g_qlPanFrom.y);
+ Invalidate();
+ } else if (g_qlSeekDrag) {
QlSeekAt(p.x);
} else if (g_optSliderDrag) {
OptSlider(p.x);
@@ -6224,6 +6370,7 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
return 0;
}
case WM_MOUSELEAVE:
+ dica::Esconde();
if (g_scrollHover) { g_scrollHover = false; g_scrollShownAt = GetTickCount(); SetTimer(h, T_SCROLLBAR, 50, nullptr); Invalidate(); }
if (g_hoverSide >= 0 || g_hoverTool >= 0 || g_hoverLights) { g_hoverSide = g_hoverTool = -1; g_hoverLights = false; Invalidate(); }
return 0;
@@ -6349,6 +6496,7 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (g_sideResize) { g_sideResize = false; ReleaseCapture(); g_sideWidthSet = true; SaveOptions(); return 0; }
if (g_scrollDrag) { g_scrollDrag = false; ReleaseCapture(); g_scrollShownAt = GetTickCount(); SetTimer(h, T_SCROLLBAR, 50, nullptr); Invalidate(); return 0; }
if (g_optSliderDrag) { g_optSliderDrag = false; ReleaseCapture(); return 0; }
+ if (g_qlPanning) { g_qlPanning = false; ReleaseCapture(); return 0; }
if (g_qlSeekDrag) { g_qlSeekDrag = false; ReleaseCapture(); return 0; }
if (g_sidePress >= 0) {
int row = g_sidePress;
@@ -6430,6 +6578,7 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
int delta = GET_WHEEL_DELTA_WPARAM(w);
POINT mp{ GET_X_LPARAM(l), GET_Y_LPARAM(l) }; // em coordenadas de tela
ScreenToClient(h, &mp);
+ if (QlWheel(ToDip(mp.x, mp.y), delta)) return 0; // foto do Quick Look: zoom
if (ToDip(mp.x, mp.y).x < Lay::SIDEBAR_W) { // sobre a barra lateral: rola só ela
g_sideScroll = std::clamp(g_sideScroll - delta / (float)WHEEL_DELTA * 52.f, 0.f, SideMaxScroll());
Invalidate();
@@ -6525,7 +6674,8 @@ static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
}
case T_MEDIA: { // quadros do vídeo; tempo da música ~5x por segundo
static DWORD last;
- if (!media::Active()) { KillTimer(h, T_MEDIA); break; }
+ // sem player, ou o vídeo não abriu (sem codec): o timer para (antes seguia redesenhando a janela à toa)
+ if (!media::Active() || media::Failed()) { KillTimer(h, T_MEDIA); Invalidate(); break; }
bool fresh = media::UpdateFrame();
if (fresh || GetTickCount() - last > 200) { last = GetTickCount(); Render(); }
break;
@@ -6931,7 +7081,7 @@ static void ParseLaunch(int argc, wchar_t** argv, Launch& L) {
if (!_wcsicmp(argv[a], L"--lista")) g_view = View::List;
else if (!_wcsicmp(argv[a], L"--colunas")) g_view = View::Columns;
else if (!_wcsicmp(argv[a], L"--galeria")) g_view = View::Gallery;
- else if (!_wcsicmp(argv[a], L"--grupos")) g_groupBy = GROUP_KIND;
+ else if (!_wcsicmp(argv[a], L"--grupos")) g_groupBy = g_groupMain = GROUP_KIND;
else if (!_wcsicmp(argv[a], L"--opcoes")) g_viewOpts = true; // abre as Opções de Visualização
else if (!_wcsicmp(argv[a], L"--info")) L.info = true; // Obter Informações da pasta aberta
else if (!_wcsicmp(argv[a], L"--aba") && a + 1 < argc) L.extraTabs.push_back(argv[++a]); // abre outra aba
diff --git a/src/fotos/main.cpp b/src/fotos/main.cpp
index 276d67f..1cdd1fd 100644
--- a/src/fotos/main.cpp
+++ b/src/fotos/main.cpp
@@ -114,6 +114,10 @@ void SaveFav() { std::vector<std::wstring> v{ L"# Fotos favoritas" }; for (auto&
std::wstring g_search; // macOS 27: a lupa filtra pelo nome do arquivo
int g_showMode = 2; // 0 anos, 1 meses, 2 todas: a grade ganha um cabeçalho por ano ou por mês
+// botões da barra (issue #8: "vários não faziam nada"): ajustar/preencher os quadrados, a ordem e o menu ⋯
+bool g_fillSq; // as fotos preenchem o quadrado (cortadas) em vez de aparecerem inteiras
+bool g_newest; // as mais novas primeiro (o Mac abre com as mais antigas em cima e rola até o fim)
+float ScrollStart() { return g_newest ? 0.f : 1e9f; } // onde a grade abre: nas mais novas
void Filter() {
g_shown.clear();
std::wstring q = g_search; for (auto& c : q) c = towlower(c);
@@ -127,6 +131,7 @@ void Filter() {
if (ok && !q.empty()) { std::wstring nm = it.path.substr(it.path.find_last_of(L"\\/") + 1); for (auto& c : nm) c = towlower(c); ok = nm.find(q) != std::wstring::npos; }
if (ok) g_shown.push_back(i);
}
+ if (g_newest) std::reverse(g_shown.begin(), g_shown.end());
if (g_sel >= (int)g_shown.size()) g_sel = -1;
}
@@ -205,18 +210,20 @@ void PaintGolden2(D2D1_SIZE_F sz, bool dark) {
t.used = now;
if (!t.bmp && !t.asked) { t.asked = true; std::lock_guard<std::mutex> q(g_qmx); g_queue.push_back(it.path); g_qcv.notify_one(); }
D2D1_RECT_F ir = r;
- if (t.bmp) { // a foto inteira dentro do quadrado (como no Mac 27)
+ if (t.bmp) { // a foto inteira dentro do quadrado (como no Mac 27); "Preencher": cortada, ocupando o quadrado
D2D1_SIZE_F bs = t.bmp->GetSize();
- float k = std::min((r.right - r.left) / bs.width, (r.bottom - r.top) / bs.height);
+ float k = g_fillSq ? std::max((r.right - r.left) / bs.width, (r.bottom - r.top) / bs.height)
+ : std::min((r.right - r.left) / bs.width, (r.bottom - r.top) / bs.height);
float w = bs.width * k, hh = bs.height * k, cx = (r.left + r.right) / 2, cy = (r.top + r.bottom) / 2;
ir = D2D1::RectF(cx - w / 2, cy - hh / 2, cx + w / 2, cy + hh / 2);
ID2D1BitmapBrush* bb = nullptr;
rt->CreateBitmapBrush(t.bmp, D2D1::BitmapBrushProperties(D2D1_EXTEND_MODE_CLAMP, D2D1_EXTEND_MODE_CLAMP, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR), &bb);
if (bb) {
bb->SetTransform(D2D1::Matrix3x2F::Scale(k, k) * D2D1::Matrix3x2F::Translation(ir.left, ir.top));
- rt->FillRoundedRectangle(D2D1::RoundedRect(ir, 8, 8), bb);
+ rt->FillRoundedRectangle(D2D1::RoundedRect(g_fillSq ? r : ir, 8, 8), bb); // preenchendo: o quadrado corta
bb->Release();
}
+ if (g_fillSq) ir = r;
} else {
float cx = (r.left + r.right) / 2, cy = (r.top + r.bottom) / 2, w = (r.right - r.left), hh = w * 0.66f;
ir = D2D1::RectF(r.left, cy - hh / 2, r.right, cy + hh / 2);
@@ -256,7 +263,8 @@ void PaintGolden2(D2D1_SIZE_F sz, bool dark) {
SYSTEMTIME st; FILETIME loc; FileTimeToLocalFileTime(&f, &loc); FileTimeToSystemTime(&loc, &st);
return idioma::Date(st, idioma::D_SHORT); // "20 de nov. de 2026", "Nov 20, 2026"
};
- range = fmt(g_all[g_shown.front()].time) + L" – " + fmt(g_all[g_shown.back()].time);
+ const FILETIME& a = g_all[g_shown.front()].time; const FILETIME& z = g_all[g_shown.back()].time;
+ range = CompareFileTime(&a, &z) <= 0 ? fmt(a) + L" – " + fmt(z) : fmt(z) + L" – " + fmt(a); // da mais antiga à mais nova
}
Text(range, g_tfSmall, D2D1::RectF(tx, 27, tx + 320, 42), gray);
}
@@ -272,19 +280,25 @@ void PaintGolden2(D2D1_SIZE_F sz, bool dark) {
}
{ // info, compartilhar, favoritar, girar/editar
D2D1_RECT_F r = group(146);
- wchar_t gl[4] = { 0xE946, 0xE72D, (wchar_t)(g_sel >= 0 && g_fav.count(SelPath()) ? 0xEB52 : 0xEB51), 0xE7AD };
+ // info, compartilhar, favoritar e editar (o lápis: o botão abre o editor, onde ficam Girar e Recortar; antes
+ // tinha o desenho de girar e confundia)
+ wchar_t gl[4] = { 0xE946, 0xE72D, (wchar_t)(g_sel >= 0 && g_fav.count(SelPath()) ? 0xEB52 : 0xEB51), 0xE70F };
int kinds[4] = { 7, 6, 5, 8 };
for (int i = 0; i < 4; i++) {
D2D1_RECT_F c = D2D1::RectF(r.left + 6 + i * 33.5f, r.top, r.left + 6 + (i + 1) * 33.5f, r.bottom);
- Glyph(gl[i], c, i == 0 || g_sel >= 0 ? text : gray);
+ Glyph(gl[i], c, g_sel >= 0 ? text : gray); // os quatro pedem uma foto escolhida (cinza sem ela)
g_gh.push_back({ kinds[i], 0, c });
}
R -= 7;
}
- { // tamanho, ordem, mais
+ { // ajustar/preencher os quadrados, ordem e ⋯ (antes só desenhados, sem fazer nada)
D2D1_RECT_F r = group(110);
- wchar_t gl[3] = { 0xE9A6, 0xE8CB, 0xE712 };
- for (int i = 0; i < 3; i++) Glyph(gl[i], D2D1::RectF(r.left + 6 + i * 32.6f, r.top, r.left + 6 + (i + 1) * 32.6f, r.bottom), text);
+ wchar_t gl[3] = { (wchar_t)(g_fillSq ? 0xE9A6 : 0xE740), 0xE8CB, 0xE712 };
+ for (int i = 0; i < 3; i++) {
+ D2D1_RECT_F c = D2D1::RectF(r.left + 6 + i * 32.6f, r.top, r.left + 6 + (i + 1) * 32.6f, r.bottom);
+ Glyph(gl[i], c, text);
+ g_gh.push_back({ 12 + i, 0, c });
+ }
R -= 12;
}
if (R - 253 - 16 - 73 > tx + 160) {
@@ -653,7 +667,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
case WM_SIZE: OnSize(l); return 0;
case WM_DPICHANGED: OnDpi(w, l); return 0;
case WM_SETTINGCHANGE: InvalidateRect(h, nullptr, FALSE); return 0;
- case WM_SCAN: g_scanning = false; Filter(); g_scroll = 1e9f; InvalidateRect(h, nullptr, FALSE); return 0; // abre no fim (as mais novas), como no Mac
+ case WM_SCAN: g_scanning = false; Filter(); g_scroll = ScrollStart(); InvalidateRect(h, nullptr, FALSE); return 0; // abre no fim (as mais novas), como no Mac
case WM_THUMB: {
auto* d = (ThumbData*)l;
auto it = g_thumbs.find(d->path);
@@ -680,7 +694,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
for (auto& gh : g_gh) if (In(gh.r, x, y)) {
if (m == WM_RBUTTONUP) return 0;
switch (gh.kind) {
- case 1: g_view = gh.arg; g_sel = -1; Filter(); g_scroll = 1e9f; break;
+ case 1: g_view = gh.arg; g_sel = -1; Filter(); g_scroll = ScrollStart(); break;
case 2: g_sbHidden = !g_sbHidden; SB = g_sbHidden ? 0.f : 216.f; break;
case 3: Zoom(1 / 1.2f); break;
case 4: Zoom(1.2f); break;
@@ -689,6 +703,32 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
case 7: { std::wstring p = SelPath(); if (!p.empty()) { SHELLEXECUTEINFOW se{ sizeof(se) }; se.fMask = SEE_MASK_INVOKEIDLIST; se.lpVerb = L"properties"; se.lpFile = p.c_str(); se.nShow = SW_SHOWNORMAL; ShellExecuteExW(&se); } break; }
case 8: EditOpen(SelPath()); break;
case 10: g_showMode = gh.arg; g_scroll = 0; break;
+ case 12: g_fillSq = !g_fillSq; break; // fotos inteiras / preenchendo os quadrados
+ case 13: case 14: { // ordem / ⋯: menus pequenos, embaixo do botão
+ POINT scr{ (LONG)(gh.r.left * Sc()), (LONG)(gh.r.bottom * Sc() + 4) }; ClientToScreen(h, &scr);
+ HMENU mm = CreatePopupMenu();
+ bool sel = !SelPath().empty();
+ if (gh.kind == 13) {
+ AppendMenuW(mm, MF_STRING | (g_newest ? 0 : MF_CHECKED), 1, Tr(L"Mais Antigas Primeiro"));
+ AppendMenuW(mm, MF_STRING | (g_newest ? MF_CHECKED : 0), 2, Tr(L"Mais Recentes Primeiro"));
+ } else {
+ AppendMenuW(mm, MF_STRING | (sel ? 0 : MF_GRAYED), 3, Tr(L"Abrir"));
+ AppendMenuW(mm, MF_STRING | (sel ? 0 : MF_GRAYED), 4, Tr(L"Mostrar no Finder"));
+ AppendMenuW(mm, MF_STRING | (sel ? 0 : MF_GRAYED), 5, Tr(L"Mover para o Lixo"));
+ AppendMenuW(mm, MF_SEPARATOR, 0, nullptr);
+ AppendMenuW(mm, MF_STRING, 6, g_sbHidden ? Tr(L"Mostrar Barra Lateral") : Tr(L"Ocultar Barra Lateral"));
+ AppendMenuW(mm, MF_STRING, 7, Tr(L"Atualizar a Biblioteca"));
+ }
+ int k = TrackPopupMenu(mm, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN, scr.x, scr.y, 0, h, nullptr);
+ DestroyMenu(mm);
+ if (k == 1 || k == 2) { g_newest = k == 2; g_sel = -1; Filter(); g_scroll = ScrollStart(); }
+ else if (k == 3) OpenSel();
+ else if (k == 4) { std::wstring p = SelPath(); PIDLIST_ABSOLUTE pidl = ILCreateFromPathW(p.c_str()); if (pidl) { SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0); ILFree(pidl); } }
+ else if (k == 5) Trash();
+ else if (k == 6) { g_sbHidden = !g_sbHidden; SB = g_sbHidden ? 0.f : 216.f; }
+ else if (k == 7) { g_scanning = true; Scan(); }
+ break;
+ }
case 11: { // busca: o campo abre na barra e filtra pelo nome enquanto digita
D2D1_RECT_F fr = D2D1::RectF(gh.r.right - 200 + 32, gh.r.top + 9, gh.r.right - 10, gh.r.bottom - 9);
FieldOpen(fr, g_search, 13, false, [](const std::wstring& q, int key) {
@@ -703,7 +743,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (x < SB || y < TB) return 0;
} else if (x < SB) {
int i = (int)((y - 48) / 34);
- if (y >= 48 && i >= 0 && i < 5) { g_view = i; g_sel = -1; Filter(); g_scroll = 1e9f; InvalidateRect(h, nullptr, FALSE); }
+ if (y >= 48 && i >= 0 && i < 5) { g_view = i; g_sel = -1; Filter(); g_scroll = ScrollStart(); InvalidateRect(h, nullptr, FALSE); }
return 0;
}
int c = HitCell(x, y);
diff --git a/src/shell/quicklook.cpp b/src/shell/quicklook.cpp
index 7d2a8b4..edcb19a 100644
--- a/src/shell/quicklook.cpp
+++ b/src/shell/quicklook.cpp
@@ -14,6 +14,16 @@
#include <thread>
#include "../comum/idioma.h"
#include "../comum/barra_video.h"
+#include "../comum/dica.h"
+#include <d2d1_3.h>
+#include <wincodec.h>
+#include <shcore.h>
+#include <winrt/Windows.Foundation.h>
+#include <winrt/Windows.Data.Pdf.h>
+#include <winrt/Windows.Storage.h>
+#include <winrt/Windows.Storage.Streams.h>
+#pragma comment(lib, "windowsapp.lib")
+#pragma comment(lib, "windowscodecs.lib")
#include <mfplay.h>
#include <mfapi.h>
#pragma comment(lib, "mfplay.lib")
@@ -41,6 +51,23 @@ HWND g_back;
bool g_glass, g_hoverShare, g_hoverFull, g_hoverRot, g_hoverMark;
bool g_full; // botão de tela cheia: a prévia ocupa o monitor
D2D1_RECT_F g_fullR, g_rotR, g_markR;
+// Zoom das fotos (issue #8): a roda do mouse amplia em volta do ponteiro (1 = a foto cabe no painel, até 8×) e,
+// ampliada, arrastar move a foto em vez do painel
+float g_zoom = 1, g_panX, g_panY;
+bool g_panning; POINT g_panFrom; float g_panX0, g_panY0;
+D2D1_RECT_F g_bodyR; // onde a foto foi desenhada por último (DIP da janela)
+bool g_bodyFill; // a foto preenche a moldura (Golden Gate fora da tela cheia) ou cabe nela
+// o retângulo da foto no corpo, com o zoom e o deslocamento (que fica preso: a foto não sai da moldura)
+D2D1_RECT_F PhotoRect(D2D1_RECT_F body, UINT iw, UINT ih, bool fill) {
+ float bw = body.right - body.left, bh = body.bottom - body.top;
+ if (!iw || !ih || bw <= 0 || bh <= 0) return body;
+ float k = (fill ? std::max(bw / iw, bh / ih) : std::min(bw / iw, bh / ih)) * g_zoom, w = iw * k, h = ih * k;
+ float mx = std::max(0.f, (w - bw) / 2), my = std::max(0.f, (h - bh) / 2);
+ g_panX = std::clamp(g_panX, -mx, mx); g_panY = std::clamp(g_panY, -my, my);
+ float x = body.left + (bw - w) / 2 + g_panX, y = body.top + (bh - h) / 2 + g_panY;
+ return D2D1::RectF(x, y, x + w, y + h);
+}
+void ZoomReset() { g_zoom = 1; g_panX = g_panY = 0; g_panning = false; }
bool g_dragging; POINT g_dragFrom, g_dragOrg; // arrastar o painel
// Vídeo e música (Golden Gate, como no Mac): o MFPlay toca numa janela própria por cima do vidro (g_vid, na moldura
// de 5, cantos 15) e a barra do QuickTime (barra_video.h) fica numa janela em camadas (g_ctl) com o vidro fosco
@@ -48,7 +75,7 @@ bool g_dragging; POINT g_dragFrom, g_dragOrg; // arrastar o painel
// a barra sempre visível embaixo.
IMFPMediaPlayer* g_mp;
HWND g_vid, g_ctl, g_ctlBack;
-bool g_media, g_hasVideo, g_scrub, g_ended;
+bool g_media, g_hasVideo, g_scrub, g_ended, g_mpVideo;
float g_vol = 1;
DWORD g_ctlMoveAt;
std::vector<barravideo::Hit> g_vhits;
@@ -98,7 +125,7 @@ void MediaStop() {
if (g_vid) ShowWindow(g_vid, SW_HIDE);
if (g_ctl) ShowWindow(g_ctl, SW_HIDE);
if (g_ctlBack) ShowWindow(g_ctlBack, SW_HIDE);
- if (g_wnd) KillTimer(g_wnd, 7);
+ if (g_wnd) { KillTimer(g_wnd, 7); KillTimer(g_wnd, 11); }
}
const float GG_R = 20; // cantos do painel (a foto: 15, concêntrica com a moldura de 5)
bool g_isIcon; // sem prévia (pasta, arquivo sem miniatura): ícone grande e informações
@@ -188,6 +215,142 @@ std::wstring ReadText(const std::wstring& p) {
return w;
}
+// ---- PDF e SVG (issue #8): o Mac mostra a página/o desenho no Quick Look; aqui eles viram a "foto" da prévia
+std::wstring LowerExt(const std::wstring& p) {
+ std::wstring x = PathFindExtensionW(p.c_str());
+ for (auto& c : x) c = towlower(c);
+ return x;
+}
+bool IsPdf(const std::wstring& p) { return LowerExt(p) == L".pdf"; }
+bool IsSvg(const std::wstring& p) { std::wstring x = LowerExt(p); return x == L".svg" || x == L".svgz"; }
+
+// PNG/BMP de um IStream -> BGRA pré-multiplicado
+bool DecodeStream(IStream* st, UINT& w, UINT& h, std::vector<BYTE>& px) {
+ IWICImagingFactory* wic = nullptr;
+ if (FAILED(CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&wic))) || !wic) return false;
+ IWICBitmapDecoder* dec = nullptr; IWICBitmapFrameDecode* fr = nullptr; IWICFormatConverter* cv = nullptr;
+ bool ok = SUCCEEDED(wic->CreateDecoderFromStream(st, nullptr, WICDecodeMetadataCacheOnDemand, &dec)) && SUCCEEDED(dec->GetFrame(0, &fr)) &&
+ SUCCEEDED(wic->CreateFormatConverter(&cv)) &&
+ SUCCEEDED(cv->Initialize(fr, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeCustom)) &&
+ SUCCEEDED(cv->GetSize(&w, &h)) && w && h;
+ if (ok) { px.resize((size_t)w * h * 4); ok = SUCCEEDED(cv->CopyPixels(nullptr, w * 4, (UINT)px.size(), px.data())); }
+ if (cv) cv->Release(); if (fr) fr->Release(); if (dec) dec->Release(); wic->Release();
+ return ok;
+}
+
+// 1ª página do PDF pelo Windows.Data.Pdf (o mesmo da Pré-Visualização), com o lado maior em maxSide px, fundo branco.
+// O WinRT espera com .get(): roda numa thread MTA própria (a do Quick Look é STA)
+bool LoadPdf(const std::wstring& path, UINT maxSide, UINT& w, UINT& h, std::vector<BYTE>& px, UINT& pages) {
+ bool ok = false;
+ std::thread([&] {
+ try {
+ winrt::init_apartment(winrt::apartment_type::multi_threaded);
+ namespace wdp = winrt::Windows::Data::Pdf;
+ namespace wss = winrt::Windows::Storage::Streams;
+ auto file = winrt::Windows::Storage::StorageFile::GetFileFromPathAsync(path).get();
+ auto doc = wdp::PdfDocument::LoadFromFileAsync(file).get();
+ pages = doc.PageCount();
+ if (!pages) return;
+ auto page = doc.GetPage(0);
+ auto s = page.Size();
+ wss::InMemoryRandomAccessStream ms;
+ wdp::PdfPageRenderOptions opt;
+ if (s.Width >= s.Height) opt.DestinationWidth(maxSide); else opt.DestinationHeight(maxSide);
+ opt.BackgroundColor(winrt::Windows::UI::Color{ 255, 255, 255, 255 });
+ page.RenderToStreamAsync(ms, opt).get();
+ ms.Seek(0);
+ IStream* st = nullptr;
+ if (SUCCEEDED(CreateStreamOverRandomAccessStream(winrt::get_unknown(ms), IID_PPV_ARGS(&st))) && st) {
+ CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+ ok = DecodeStream(st, w, h, px);
+ st->Release();
+ }
+ } catch (...) { ok = false; }
+ }).join();
+ return ok;
+}
+
+// SVG pelo SVG do Direct2D (ID2D1DeviceContext5), desenhado num bitmap WIC com o lado maior em maxSide px
+bool LoadSvg(const std::wstring& path, UINT maxSide, UINT& w, UINT& h, std::vector<BYTE>& px) {
+ IStream* st = nullptr;
+ if (FAILED(SHCreateStreamOnFileEx(path.c_str(), STGM_READ | STGM_SHARE_DENY_NONE, 0, FALSE, nullptr, &st)) || !st) return false;
+ IWICImagingFactory* wic = nullptr;
+ ID2D1Factory* fac = nullptr;
+ CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&wic));
+ D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &fac);
+ bool ok = false;
+ // o tamanho: viewBox, ou width/height; sem nada, 512 × 512
+ auto measure = [&](float& vw, float& vh) {
+ vw = vh = 512;
+ IWICBitmap* b1 = nullptr; ID2D1RenderTarget* rt1 = nullptr; ID2D1DeviceContext5* dc = nullptr; ID2D1SvgDocument* doc = nullptr;
+ if (wic && fac && SUCCEEDED(wic->CreateBitmap(8, 8, GUID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnLoad, &b1)) &&
+ SUCCEEDED(fac->CreateWicBitmapRenderTarget(b1, D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_SOFTWARE, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)), &rt1)) &&
+ SUCCEEDED(rt1->QueryInterface(IID_PPV_ARGS(&dc))) && SUCCEEDED(dc->CreateSvgDocument(st, D2D1::SizeF(512, 512), &doc))) {
+ ID2D1SvgElement* root = nullptr; doc->GetRoot(&root);
+ if (root) {
+ D2D1_SVG_VIEWBOX vb{};
+ if (SUCCEEDED(root->GetAttributeValue(L"viewBox", D2D1_SVG_ATTRIBUTE_POD_TYPE_VIEWBOX, &vb, sizeof(vb))) && vb.width > 0 && vb.height > 0) { vw = vb.width; vh = vb.height; }
+ else {
+ D2D1_SVG_LENGTH lw{}, lh{};
+ if (SUCCEEDED(root->GetAttributeValue(L"width", D2D1_SVG_ATTRIBUTE_POD_TYPE_LENGTH, &lw, sizeof(lw))) && lw.units == D2D1_SVG_LENGTH_UNITS_NUMBER && lw.value > 0 &&
+ SUCCEEDED(root->GetAttributeValue(L"height", D2D1_SVG_ATTRIBUTE_POD_TYPE_LENGTH, &lh, sizeof(lh))) && lh.units == D2D1_SVG_LENGTH_UNITS_NUMBER && lh.value > 0) { vw = lw.value; vh = lh.value; }
+ }
+ root->Release();
+ }
+ ok = true;
+ }
+ if (doc) doc->Release(); if (dc) dc->Release(); if (rt1) rt1->Release(); if (b1) b1->Release();
+ };
+ float vw = 512, vh = 512;
+ measure(vw, vh);
+ if (ok) {
+ ok = false;
+ LARGE_INTEGER z{}; st->Seek(z, STREAM_SEEK_SET, nullptr);
+ float k = maxSide / std::max(vw, vh);
+ w = std::max(1u, (UINT)std::lround(vw * k)); h = std::max(1u, (UINT)std::lround(vh * k));
+ IWICBitmap* b = nullptr; ID2D1RenderTarget* rt = nullptr; ID2D1DeviceContext5* dc = nullptr; ID2D1SvgDocument* doc = nullptr;
+ if (SUCCEEDED(wic->CreateBitmap(w, h, GUID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnLoad, &b)) &&
+ SUCCEEDED(fac->CreateWicBitmapRenderTarget(b, D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_SOFTWARE, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)), &rt)) &&
+ SUCCEEDED(rt->QueryInterface(IID_PPV_ARGS(&dc))) && SUCCEEDED(dc->CreateSvgDocument(st, D2D1::SizeF((float)w, (float)h), &doc))) {
+ dc->BeginDraw();
+ dc->Clear(D2D1::ColorF(0, 0, 0, 0));
+ dc->DrawSvgDocument(doc);
+ ok = SUCCEEDED(dc->EndDraw());
+ }
+ if (ok) { px.resize((size_t)w * h * 4); ok = SUCCEEDED(b->CopyPixels(nullptr, w * 4, (UINT)px.size(), px.data())); }
+ if (doc) doc->Release(); if (dc) dc->Release(); if (rt) rt->Release(); if (b) b->Release();
+ }
+ if (fac) fac->Release(); if (wic) wic->Release(); st->Release();
+ return ok;
+}
+
+// ---- Word, PowerPoint, Excel (e fontes): o "preview handler" do Windows, se o PC tiver um para o tipo (o Office
+// instala os dele). Ele desenha numa janela comum por cima do vidro (g_ph), como o vídeo; sem handler, fica o ícone.
+IPreviewHandler* g_ph;
+HWND g_phWnd;
+bool g_handler; // a prévia atual é de um preview handler
+bool g_skipHandler; // o handler falhou no DoPreview: carrega de novo sem ele (ícone)
+bool WantsHandler(const std::wstring& p, CLSID* out) {
+ std::wstring x = LowerExt(p);
+ bool want = false;
+ for (auto e : { L".doc", L".docx", L".docm", L".dot", L".dotx", L".odt", L".rtf", L".ppt", L".pptx", L".pptm", L".pps", L".ppsx", L".odp",
+ L".xls", L".xlsx", L".xlsm", L".ods", L".vsd", L".vsdx", L".pub", L".ttf", L".otf", L".ttc" })
+ if (x == e) want = true;
+ if (!want) return false;
+ wchar_t s[64] = {}; DWORD n = 64;
+ if (FAILED(AssocQueryStringW(ASSOCF_INIT_DEFAULTTOSTAR, ASSOCSTR_SHELLEXTENSION, x.c_str(), L"{8895b1c6-b41f-4c1c-a562-0d564250836f}", s, &n)) || !s[0]) return false;
+ return SUCCEEDED(CLSIDFromString(s, out));
+}
+void HandlerStop() {
+ if (g_ph) { g_ph->Unload(); g_ph->Release(); g_ph = nullptr; }
+ if (g_phWnd) ShowWindow(g_phWnd, SW_HIDE);
+ g_handler = false;
+}
+LRESULT CALLBACK PhProc(HWND h, UINT m, WPARAM w, LPARAM l) {
+ if (m == WM_ERASEBKGND) { RECT r; GetClientRect(h, &r); FillRect((HDC)w, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); return 1; }
+ return DefWindowProcW(h, m, w, l);
+}
+
// os apps do Mac do projeto para o tipo (como no Mac: Pré-Visualização abre imagens e PDF, TextEdit o texto)
std::wstring g_openExe;
std::wstring OwnApp(const std::wstring& p, std::wstring& name) {
@@ -225,10 +388,12 @@ SIZE PanelSize(float sc) {
float W = (mi.rcWork.right - mi.rcWork.left) / sc * 0.62f, H = (mi.rcWork.bottom - mi.rcWork.top) / sc * 0.72f - BAR;
float w = 560, h = 420;
if (!g_text.empty()) { w = std::min(W, 720.f); h = std::min(H, 760.f); }
+ else if (g_handler) { w = std::min(W, 760.f); h = std::min(H, 580.f); } // Word/PowerPoint: folha de tamanho fixo
else if (g_iw && g_ih) {
float k = std::min(W / g_iw, H / g_ih);
k = std::min(k, 1.6f / sc); // imagem pequena não estoura
- w = std::max(360.f, g_iw * k); h = std::max(240.f, g_ih * k);
+ // vídeo: pelo menos 420 de largura, para a barra do QuickTime caber (vídeo em pé deixava o painel estreito)
+ w = std::max(g_media ? 420.f : 360.f, g_iw * k); h = std::max(240.f, g_ih * k);
}
if (liquid::Golden() && g_isIcon && g_media) return { 540, 520 }; // música: o ícone e a barra embaixo
if (liquid::Golden() && g_isIcon) return { 540, 440 }; // medido na captura do usuário (19/11/2026)
@@ -324,7 +489,18 @@ void DrawGolden(ID2D1RenderTarget* rt, float W, float H, bool dark, bool glass)
D2D1_POINT_2F fc{ 38, cy };
g_fullR = D2D1::RectF(fc.x - 10, fc.y - 10, fc.x + 10, fc.y + 10);
roundBtn(fc, g_hoverFull);
- rt->DrawLine({ fc.x - 2.6f, fc.y + 2.6f }, { fc.x + 2.6f, fc.y - 2.6f }, br, 2.4f); // a barra em diagonal
+ // arrow.up.left.and.arrow.down.right (o SF Symbol do Mac): duas setinhas em diagonal, as pontas em "L" nos
+ // cantos; em tela cheia, viradas para dentro (arrow.down.right.and.arrow.up.left). Antes era uma barra só
+ ID2D1StrokeStyle* ss = nullptr;
+ fac->CreateStrokeStyle(D2D1::StrokeStyleProperties(D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_CAP_STYLE_ROUND, D2D1_LINE_JOIN_ROUND), nullptr, 0, &ss);
+ for (int s = -1; s <= 1; s += 2) { // -1: a de cima à esquerda; 1: a de baixo à direita
+ float fora = 3.3f * s, perto = 0.9f * s; // ponta e base da seta, a partir do centro
+ float tip = g_full ? perto : fora, base = g_full ? fora : perto, d = 2.3f * (g_full ? -s : s);
+ rt->DrawLine({ fc.x + base, fc.y + base }, { fc.x + tip, fc.y + tip }, br, 1.25f, ss);
+ rt->DrawLine({ fc.x + tip, fc.y + tip }, { fc.x + tip - d, fc.y + tip }, br, 1.25f, ss);
+ rt->DrawLine({ fc.x + tip, fc.y + tip }, { fc.x + tip, fc.y + tip - d }, br, 1.25f, ss);
+ }
+ if (ss) ss->Release();
}
// "Abrir com <app>": cápsula de 24 a 7,5 da borda, texto normal de 13 com 12,5 de cada lado
static IDWriteTextFormat* tfBtn = ui::Format(13, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_CENTER);
@@ -413,8 +589,8 @@ void DrawGolden(ID2D1RenderTarget* rt, float W, float H, bool dark, bool glass)
}
if (g_bmpRt != rt && g_bmp) { g_bmp->Release(); g_bmp = nullptr; }
if (!g_bmp && !g_px.empty()) { g_bmp = ui::Bitmap(rt, g_iw, g_ih, g_px); g_bmpRt = rt; }
- if (g_hasVideo) { // vídeo: a moldura preta; o MFPlay desenha na janela g_vid por cima
- br->SetColor(D2D1::ColorF(0, 0, 0, 1));
+ if (g_hasVideo || g_handler) { // vídeo: a moldura preta (o MFPlay desenha em g_vid por cima); Office: a folha branca
+ br->SetColor(g_handler ? D2D1::ColorF(1, 1, 1, 1) : D2D1::ColorF(0, 0, 0, 1));
rt->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(M, BAR, W - M, H - M), RR - M, RR - M), br);
br->Release(); fac->Release();
return;
@@ -450,11 +626,10 @@ void DrawGolden(ID2D1RenderTarget* rt, float W, float H, bool dark, bool glass)
br->SetColor(text);
rt->DrawTextW(g_text.c_str(), (UINT32)std::min<size_t>(g_text.size(), 20000), g_tfText, D2D1::RectF(body.left + 18, body.top + 14, body.right - 18, body.bottom), br, D2D1_DRAW_TEXT_OPTIONS_CLIP);
} else if (g_bmp) { // a foto preenche a moldura
- float bwid = body.right - body.left, bh = body.bottom - body.top;
- // tela cheia: a foto inteira (o vidro aparece nas sobras); normal: o painel já tem a proporção da foto
- float k = g_full ? std::min(bwid / g_iw, bh / g_ih) : std::max(bwid / g_iw, bh / g_ih), w = g_iw * k, h = g_ih * k;
- float x = body.left + (bwid - w) / 2, y = body.top + (bh - h) / 2;
- rt->DrawBitmap(g_bmp, D2D1::RectF(x, y, x + w, y + h), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
+ // tela cheia: a foto inteira (o vidro aparece nas sobras); normal: o painel já tem a proporção da foto.
+ // Com zoom, amplia em volta do ponteiro e o arrasto move (PhotoRect)
+ g_bodyR = body; g_bodyFill = !g_full;
+ rt->DrawBitmap(g_bmp, PhotoRect(body, g_iw, g_ih, !g_full), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
}
if (clip) { rt->PopLayer(); clip->Release(); }
br->Release();
@@ -486,6 +661,7 @@ void PaintGolden(ID2D1RenderTarget* rt, RECT wr, int wpx, int hpx, float sc, boo
}
void PaintCtl();
+bool g_ctlRestack = true; // a barra precisa voltar para cima do vídeo (o painel mexeu): só aí mexe na ordem das janelas
// o vídeo e a barra ficam por cima do painel no mesmo "sempre visível" dele (por cima do Finder, o painel é
// sempre visível; um HWND_TOP comum deixava o vídeo atrás do painel, só com a moldura preta à vista)
UINT PlaceOver(HWND x) {
@@ -495,8 +671,24 @@ UINT PlaceOver(HWND x) {
return 0;
}
HWND OverAfter() { return (GetWindowLongW(g_wnd, GWL_EXSTYLE) & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP; }
+void PlaceHandler() { // a folha do Word/PowerPoint por cima do corpo do painel (como o vídeo)
+ if (!g_handler || !g_phWnd || !g_wnd || !IsWindowVisible(g_wnd)) return;
+ float sc = Sc();
+ RECT wr; GetWindowRect(g_wnd, &wr);
+ bool gg = liquid::Golden();
+ int m = gg ? (int)std::lround(5 * sc) : 0, top = (int)std::lround(BAR * sc);
+ int w = wr.right - wr.left - 2 * m, h = wr.bottom - wr.top - top - m;
+ if (w <= 0 || h <= 0) return;
+ int rr = (int)std::lround(2 * ((gg ? GG_R : R) - (gg ? 5 : 0)) * sc);
+ SetWindowRgn(g_phWnd, CreateRoundRectRgn(0, 0, w + 1, h + 1, gg ? rr : 0, gg ? rr : 0), FALSE);
+ PlaceOver(g_phWnd);
+ SetWindowPos(g_phWnd, OverAfter(), wr.left + m, wr.top + top, w, h, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ if (g_ph) { RECT rc{ 0, 0, w, h }; g_ph->SetRect(&rc); }
+}
void PlaceMedia() {
+ PlaceHandler();
if (!g_media || !g_wnd || !IsWindowVisible(g_wnd)) return;
+ g_ctlRestack = true;
float sc = Sc();
RECT wr; GetWindowRect(g_wnd, &wr);
int m = (int)std::lround(5 * sc), top = (int)std::lround(BAR * sc);
@@ -559,12 +751,17 @@ void PaintCtl() {
BLENDFUNCTION bf{ AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
UpdateLayeredWindow(g_ctl, screen, &dst, &sz, mem, &src, 0, &bf, ULW_ALPHA);
SelectObject(mem, old); DeleteObject(bmp); DeleteDC(mem); ReleaseDC(nullptr, screen);
- if (g_ctlBack) { // o vidro fosco de trás, 4,5 pt para dentro (o acrílico não aceita recorte)
- int in = (int)std::lround(4.5f * sc);
- SetWindowPos(g_ctlBack, HWND_TOP, x + in, y + in, w - 2 * in, h - 2 * in, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ // A ordem das janelas só muda quando a barra aparece ou o painel mexeu. Antes ia para cima a cada quadro (15×/s),
+ // e cada troca de ordem fazia o Shell remontar o vidro real e as sombras: CPU alta com o vídeo aberto (issue #8)
+ if (!IsWindowVisible(g_ctl) || g_ctlRestack) {
+ g_ctlRestack = false;
+ if (g_ctlBack) { // o vidro fosco de trás, 4,5 pt para dentro (o acrílico não aceita recorte)
+ int in = (int)std::lround(4.5f * sc);
+ SetWindowPos(g_ctlBack, HWND_TOP, x + in, y + in, w - 2 * in, h - 2 * in, SWP_NOACTIVATE | SWP_SHOWWINDOW);
+ }
+ PlaceOver(g_ctl);
+ SetWindowPos(g_ctl, OverAfter(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
- PlaceOver(g_ctl);
- SetWindowPos(g_ctl, OverAfter(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
void Paint() {
@@ -611,10 +808,8 @@ void Paint() {
if (g_bmpRt != rt && g_bmp) { g_bmp->Release(); g_bmp = nullptr; }
if (!g_bmp && !g_px.empty()) { g_bmp = ui::Bitmap(rt, g_iw, g_ih, g_px); g_bmpRt = rt; }
if (g_bmp) {
- float bwid = body.right - body.left, bh = body.bottom - body.top;
- float k = std::min(bwid / g_iw, bh / g_ih), w = g_iw * k, h = g_ih * k;
- float x = body.left + (bwid - w) / 2, y = body.top + (bh - h) / 2;
- rt->DrawBitmap(g_bmp, D2D1::RectF(x, y, x + w, y + h), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
+ g_bodyR = body; g_bodyFill = false;
+ rt->DrawBitmap(g_bmp, PhotoRect(body, g_iw, g_ih, false), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
} else {
br->SetColor(D2D1::ColorF(1, 1, 1, 0.55f));
const wchar_t* t = g_loading ? Tr(L"Carregando…") : Tr(L"Sem prévia");
@@ -661,11 +856,12 @@ void Paint() {
} else {
if (g_bmpRt != rt && g_bmp) { g_bmp->Release(); g_bmp = nullptr; }
if (!g_bmp && !g_px.empty()) { g_bmp = ui::Bitmap(rt, g_iw, g_ih, g_px); g_bmpRt = rt; }
- if (g_bmp) {
- float bwid = body.right - body.left, bh = body.bottom - body.top;
- float k = std::min(bwid / g_iw, bh / g_ih), w = g_iw * k, h = g_ih * k;
- float x = body.left + (bwid - w) / 2, y = body.top + (bh - h) / 2;
- rt->DrawBitmap(g_bmp, D2D1::RectF(x, y, x + w, y + h), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
+ if (g_handler) { // Office: a folha branca (o preview handler desenha por cima, em g_phWnd)
+ br->SetColor(D2D1::ColorF(1, 1, 1, 1));
+ rt->FillRectangle(body, br);
+ } else if (g_bmp) {
+ g_bodyR = body; g_bodyFill = false;
+ rt->DrawBitmap(g_bmp, PhotoRect(body, g_iw, g_ih, false), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR);
} else {
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.45f) : D2D1::ColorF(0, 0, 0, 0.45f));
const wchar_t* t = g_loading ? Tr(L"Carregando…") : Tr(L"Sem prévia");
@@ -701,6 +897,9 @@ void Place() {
void MediaStart(const std::wstring& path);
void Load(const std::wstring& path) {
MediaStop();
+ HandlerStop();
+ ZoomReset();
+ dica::Esconde();
g_path = path;
g_name = path.substr(path.find_last_of(L"\\/") + 1);
g_app = DefaultAppName(path);
@@ -712,7 +911,37 @@ void Load(const std::wstring& path) {
bool dir = at != INVALID_FILE_ATTRIBUTES && (at & FILE_ATTRIBUTE_DIRECTORY);
// Golden Gate: o que não tem miniatura (pasta, arquivo comum) mostra o ícone grande; sabe antes de abrir
g_isIcon = false;
- if (liquid::Golden() && !IsTextFile(path)) {
+ // Vídeo e música não passam por aqui: pedir a miniatura de um vídeo decodifica um quadro e, nesta thread (a da
+ // interface do Shell), travava a Dock e a barra por segundos com a CPU alta, e o vídeo demorava a abrir ou nem
+ // abria (issue #8). PDF e SVG têm a prévia própria (abaixo)
+ bool mediaFile = IsMediaPath(path), ownPreview = !dir && (IsPdf(path) || IsSvg(path));
+ CLSID phClsid{};
+ if (!g_skipHandler && !dir && !mediaFile && !ownPreview && WantsHandler(path, &phClsid)) { // Word/PowerPoint/Excel com o handler do Windows
+ if (!g_phWnd) {
+ HINSTANCE hi = GetModuleHandleW(nullptr);
+ WNDCLASSW pc{}; pc.lpfnWndProc = PhProc; pc.hInstance = hi; pc.lpszClassName = L"ShellQuickLookPrevia"; pc.hCursor = LoadCursorW(nullptr, IDC_ARROW);
+ RegisterClassW(&pc);
+ g_phWnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE, pc.lpszClassName, L"", WS_POPUP | WS_CLIPCHILDREN, 0, 0, 10, 10, g_wnd, nullptr, hi, nullptr);
+ if (g_phWnd) apps::ours.push_back(g_phWnd);
+ }
+ IPreviewHandler* ph = nullptr;
+ HRESULT hr = g_phWnd ? CoCreateInstance(phClsid, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&ph)) : E_FAIL;
+ if (FAILED(hr) && g_phWnd) hr = CoCreateInstance(phClsid, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ph));
+ if (SUCCEEDED(hr) && ph) {
+ IInitializeWithFile* iwf = nullptr; IInitializeWithStream* iws = nullptr;
+ if (SUCCEEDED(ph->QueryInterface(IID_PPV_ARGS(&iwf))) && iwf) { hr = iwf->Initialize(path.c_str(), STGM_READ); iwf->Release(); }
+ else if (SUCCEEDED(ph->QueryInterface(IID_PPV_ARGS(&iws))) && iws) {
+ IStream* st = nullptr;
+ hr = SHCreateStreamOnFileEx(path.c_str(), STGM_READ | STGM_SHARE_DENY_NONE, 0, FALSE, nullptr, &st);
+ if (SUCCEEDED(hr)) { hr = iws->Initialize(st, STGM_READ); st->Release(); }
+ iws->Release();
+ } else hr = E_NOINTERFACE;
+ if (SUCCEEDED(hr)) { g_ph = ph; g_handler = true; } else ph->Release();
+ }
+ Log(L"quick look: preview handler %ls (0x%08X)", g_handler ? L"ok" : L"falhou", (unsigned)hr);
+ if (g_handler) { g_loading = false; return; } // Toggle mostra a janela e chama StartHandler
+ }
+ if (liquid::Golden() && !IsTextFile(path) && !mediaFile && !ownPreview) {
g_isIcon = true;
IShellItemImageFactory* f = nullptr;
HBITMAP hb = nullptr;
@@ -744,11 +973,15 @@ void Load(const std::wstring& path) {
if (ext == e) photo = true;
}
UINT screen = (UINT)std::max({ GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 1600 });
- std::thread([path, gen, w, px, icon, dir, photo, screen] {
+ bool pdf = ownPreview && IsPdf(path), svg = ownPreview && IsSvg(path);
+ std::thread([path, gen, w, px, icon, dir, photo, screen, pdf, svg] {
HRESULT co = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
auto* r = new std::tuple<int, UINT, UINT, std::vector<BYTE>>(gen, 0, 0, std::vector<BYTE>{});
auto& [g, iw, ih, px2] = *r;
bool got = photo && ui::LoadPhoto(path, screen, iw, ih, px2); // sem codec (HEIC sem a extensão): a miniatura
+ UINT pages = 0;
+ if (!got && pdf) { got = LoadPdf(path, std::min(screen, 2400u), iw, ih, px2, pages); if (!got) Log(L"quick look: PDF não abriu (%ls)", path.c_str()); }
+ if (!got && svg) { got = LoadSvg(path, std::min(screen, 2400u), iw, ih, px2); if (!got) Log(L"quick look: SVG não abriu (%ls)", path.c_str()); }
if (icon && dir && GetFileAttributesW((path + L"\\desktop.ini").c_str()) == INVALID_FILE_ATTRIBUTES) { // a pasta do Mac (pacote de ícones)
std::wstring png = ui::PackIcon(L"folder default");
got = !png.empty() && ui::LoadPng(png, iw, ih, px2);
@@ -762,6 +995,9 @@ void Load(const std::wstring& path) {
}).detach();
}
+// foto na prévia (não ícone, texto, vídeo nem Office): a roda do mouse amplia
+bool Zoomable() { return g_bmp && g_text.empty() && !g_media && !g_handler && !g_isIcon && g_iw && g_ih && g_bodyR.right > g_bodyR.left; }
+
LRESULT CALLBACK VidProc(HWND h, UINT m, WPARAM w, LPARAM l) {
switch (m) {
case WM_MOUSEACTIVATE: return MA_NOACTIVATE;
@@ -779,10 +1015,27 @@ LRESULT CALLBACK CtlProc(HWND h, UINT m, WPARAM w, LPARAM l) {
case WM_MOUSEACTIVATE: return MA_NOACTIVATE;
case WM_MOUSEMOVE: {
g_ctlMoveAt = GetTickCount();
- if (g_scrub) { float x = GET_X_LPARAM(l) / sc; for (auto& ht : g_vhits) if (ht.id == barravideo::SCRUB) MSeek(barravideo::PosicaoEm(ht.r, x) * MLen()); PaintCtl(); }
+ if (g_scrub) { float x = GET_X_LPARAM(l) / sc; for (auto& ht : g_vhits) if (ht.id == barravideo::SCRUB) MSeek(barravideo::PosicaoEm(ht.r, x) * MLen()); PaintCtl(); return 0; }
+ float x = GET_X_LPARAM(l) / sc, y = GET_Y_LPARAM(l) / sc;
+ std::wstring tip;
+ for (auto& ht : g_vhits) {
+ if (x < ht.r.left || x >= ht.r.right || y < ht.r.top || y >= ht.r.bottom) continue;
+ switch (ht.id) {
+ case barravideo::VOL: tip = Tr(L"Volume"); break;
+ case barravideo::BACK: tip = Tr(L"Voltar 15 Segundos"); break;
+ case barravideo::PLAY: tip = MPlaying() ? Tr(L"Pausar") : Tr(L"Reproduzir"); break;
+ case barravideo::FWD: tip = Tr(L"Avançar 15 Segundos"); break;
+ case barravideo::FULL: tip = g_full ? Tr(L"Sair da Tela Cheia") : Tr(L"Tela Cheia"); break;
+ }
+ break;
+ }
+ dica::Quer(h, tip, ui::Dark());
+ TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 }; TrackMouseEvent(&t);
return 0;
}
+ case WM_MOUSELEAVE: dica::Esconde(); return 0;
case WM_LBUTTONDOWN: {
+ dica::Esconde();
float x = GET_X_LPARAM(l) / sc, y = GET_Y_LPARAM(l) / sc;
for (auto& ht : g_vhits) {
if (x < ht.r.left || x >= ht.r.right || y < ht.r.top || y >= ht.r.bottom) continue;
@@ -824,7 +1077,9 @@ void MediaStart(const std::wstring& path) {
g_mp->SetVolume(g_vol);
g_mp->SetBorderColor(RGB(0, 0, 0));
g_ctlMoveAt = GetTickCount();
+ g_ctlRestack = true;
SetTimer(g_wnd, 7, 66, nullptr); // a barra acompanha o vídeo (o desfoque de trás anda junto)
+ if (IsMediaPath(path, &g_mpVideo) && g_mpVideo) SetTimer(g_wnd, 11, 8000, nullptr); // vídeo que não abre: desiste (WM_TIMER 11)
}
LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
@@ -839,13 +1094,25 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
g_px.clear(); if (g_bmp) { g_bmp->Release(); g_bmp = nullptr; }
g_iw = vs.cx; g_ih = vs.cy; g_loading = false;
}
+ KillTimer(h, 11);
g_mp->Play();
Place(); Paint(); SyncBack();
} else if (w == 2) { g_ended = true; PaintCtl(); }
- else if (w == 1 || w == 3) { g_hasVideo = false; PaintCtl(); } // não deu para tocar: fica a prévia
+ else if (w == 1 || w == 3) { // não deu para tocar (sem o codec, arquivo estragado): para o player e fica a prévia
+ Log(L"quick look: o vídeo não abriu (0x%08X) %ls", (unsigned)l, g_path.c_str());
+ bool icon = !g_hasVideo && g_px.empty();
+ MediaStop();
+ if (icon && liquid::Golden()) g_isIcon = true;
+ Place(); Paint(); SyncBack();
+ }
return 0;
case WM_TIMER:
if (w == 7) { if (g_media) PaintCtl(); return 0; }
+ if (w == 11) { // o Media Foundation não respondeu em 8 s: desiste (antes ficava girando, com a CPU alta)
+ KillTimer(h, 11);
+ if (g_mp && !g_hasVideo) { Log(L"quick look: o vídeo não abriu em 8 s %ls", g_path.c_str()); MediaStop(); Place(); Paint(); SyncBack(); }
+ return 0;
+ }
if (w == 8) { KeepTop(); return 0; }
if (w == T_QLANIM) { AnimStep(); return 0; }
break;
@@ -867,7 +1134,33 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (y < BAR && !(x >= g_closeR.left && x < g_closeR.right) && !(x >= g_openR.left && x < g_openR.right)) return HTCAPTION;
return HTCLIENT;
}
+ case WM_MOUSEWHEEL: { // zoom da foto em volta do ponteiro (issue #8)
+ if (!Zoomable()) return 0;
+ POINT p{ (short)LOWORD(l), (short)HIWORD(l) }; ScreenToClient(h, &p);
+ float sc = Sc(), x = p.x / sc, y = p.y / sc;
+ float z0 = g_zoom, z1 = std::clamp(z0 * std::pow(1.0018f, (float)GET_WHEEL_DELTA_WPARAM(w)), 1.f, 8.f);
+ if (z1 == z0) return 0;
+ D2D1_RECT_F a = PhotoRect(g_bodyR, g_iw, g_ih, g_bodyFill);
+ float fx = (x - a.left) / std::max(1.f, a.right - a.left), fy = (y - a.top) / std::max(1.f, a.bottom - a.top);
+ g_zoom = z1;
+ D2D1_RECT_F b = PhotoRect(g_bodyR, g_iw, g_ih, g_bodyFill); // tamanho novo; o ponto sob o mouse fica parado
+ g_panX += (x - fx * (b.right - b.left)) - b.left;
+ g_panY += (y - fy * (b.bottom - b.top)) - b.top;
+ if (g_zoom <= 1.001f) ZoomReset();
+ dica::Esconde();
+ Paint();
+ return 0;
+ }
case WM_LBUTTONDOWN:
+ dica::Esconde();
+ { // foto ampliada: arrastar move a foto
+ float sc = Sc(), x = (short)LOWORD(l) / sc, y = (short)HIWORD(l) / sc;
+ if (Zoomable() && g_zoom > 1.001f && x >= g_bodyR.left && x < g_bodyR.right && y >= g_bodyR.top && y < g_bodyR.bottom) {
+ GetCursorPos(&g_panFrom); g_panX0 = g_panX; g_panY0 = g_panY;
+ g_panning = true; SetCapture(h);
+ return 0;
+ }
+ }
// como no Mac: arrasta por qualquer ponto do painel que não seja botão
if (liquid::Golden() && !g_full && !g_hoverClose && !g_hoverOpen && !g_hoverShare && !g_hoverFull && !g_hoverRot && !g_hoverMark) {
GetCursorPos(&g_dragFrom);
@@ -875,8 +1168,15 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
g_dragging = true; SetCapture(h);
}
return 0;
- case WM_CAPTURECHANGED: g_dragging = false; return 0;
+ case WM_CAPTURECHANGED: g_dragging = g_panning = false; return 0;
case WM_MOUSEMOVE: {
+ if (g_panning) {
+ POINT p; GetCursorPos(&p);
+ float sc = Sc();
+ g_panX = g_panX0 + (p.x - g_panFrom.x) / sc; g_panY = g_panY0 + (p.y - g_panFrom.y) / sc;
+ Paint();
+ return 0;
+ }
if (g_dragging) {
POINT p; GetCursorPos(&p);
SetWindowPos(h, nullptr, g_dragOrg.x + p.x - g_dragFrom.x, g_dragOrg.y + p.y - g_dragFrom.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
@@ -890,18 +1190,24 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
if (hc != g_hoverClose || ho != g_hoverOpen || hs != g_hoverShare || hf != g_hoverFull || hr != g_hoverRot || hm != g_hoverMark) {
g_hoverClose = hc; g_hoverOpen = ho; g_hoverShare = hs; g_hoverFull = hf; g_hoverRot = hr; g_hoverMark = hm; Paint();
}
+ // dica do botão parado sob o mouse, como no Mac
+ std::wstring tip = hc ? Tr(L"Fechar") : hf ? (g_full ? Tr(L"Sair da Tela Cheia") : Tr(L"Tela Cheia")) : hs ? Tr(L"Compartilhar")
+ : hr ? Tr(L"Girar para a Esquerda") : hm ? Tr(L"Marcação") : ho ? (g_app.empty() ? std::wstring(Tr(L"Abrir")) : std::wstring(Tr(L"Abrir com ")) + g_app) : L"";
+ dica::Quer(h, tip, ui::Dark());
TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 }; TrackMouseEvent(&t);
return 0;
}
case WM_MOUSELEAVE:
+ dica::Esconde();
if (g_hoverClose || g_hoverOpen || g_hoverShare || g_hoverFull || g_hoverRot || g_hoverMark) {
g_hoverClose = g_hoverOpen = g_hoverShare = g_hoverFull = g_hoverRot = g_hoverMark = false; Paint();
}
return 0;
case WM_LBUTTONUP:
+ if (g_panning) { g_panning = false; ReleaseCapture(); return 0; }
if (g_dragging) { g_dragging = false; ReleaseCapture(); return 0; }
if (g_hoverClose) { quicklook::Close(); return 0; }
- if (g_hoverFull) { g_full = !g_full; Place(); Paint(); SyncBack(); return 0; }
+ if (g_hoverFull) { g_full = !g_full; ZoomReset(); Place(); Paint(); SyncBack(); return 0; }
if (g_hoverRot && g_iw && g_ih && g_px.size() >= (size_t)g_iw * g_ih * 4) { // gira 90° para a esquerda, como o Mac
std::vector<BYTE> o(g_px.size());
for (UINT y = 0; y < g_ih; y++)
@@ -909,6 +1215,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
memcpy(&o[((size_t)(g_iw - 1 - x) * g_ih + y) * 4], &g_px[((size_t)y * g_iw + x) * 4], 4);
g_px.swap(o); std::swap(g_iw, g_ih);
if (g_bmp) { g_bmp->Release(); g_bmp = nullptr; }
+ ZoomReset();
Place(); Paint(); SyncBack();
return 0;
}
@@ -926,7 +1233,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {
}
return 0;
case WM_KEYDOWN:
- if (w == VK_ESCAPE && g_full) { g_full = false; Place(); Paint(); SyncBack(); return 0; }
+ if (w == VK_ESCAPE && g_full) { g_full = false; ZoomReset(); Place(); Paint(); SyncBack(); return 0; }
if (w == VK_ESCAPE || w == VK_SPACE) { quicklook::Close(); return 0; }
if (w == VK_RETURN) { std::wstring p = g_path; quicklook::Close(); OpenPath(p); return 0; }
return 0;
@@ -981,6 +1288,9 @@ void CloseNow() {
if (!g_wnd) return;
KillTimer(g_wnd, T_QLANIM); g_qlAnimT0 = -1; g_qlAnimOut = false; g_qlOp = g_qlSc = 1;
MediaStop();
+ HandlerStop();
+ ZoomReset();
+ dica::Esconde();
KillTimer(g_wnd, 8);
SetWindowPos(g_wnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
ShowWindow(g_wnd, SW_HIDE);
@@ -997,6 +1307,8 @@ void quicklook::Close() {
if (g_qlAnimOut) return; // já fechando
if (IsWindowVisible(g_wnd) && g_glass && liquid::Golden()) { // some animado; o vídeo para já
MediaStop();
+ HandlerStop();
+ dica::Esconde();
AnimStart(true);
return;
}
@@ -1020,6 +1332,17 @@ void quicklook::Toggle(const std::wstring& path, bool activate) {
if (activate) SetForegroundWindow(g_wnd);
Paint();
SyncBack();
+ if (g_handler && g_ph) { // Word/PowerPoint: o handler desenha na folha por cima do corpo (PlaceHandler)
+ RECT rc{}; GetClientRect(g_phWnd, &rc);
+ HRESULT hr = g_ph->SetWindow(g_phWnd, &rc);
+ if (SUCCEEDED(hr)) hr = g_ph->DoPreview();
+ if (FAILED(hr)) { // não desenhou: fica o ícone grande, como antes
+ Log(L"quick look: DoPreview 0x%08X", (unsigned)hr);
+ std::wstring p = g_path;
+ g_skipHandler = true; Load(p); g_skipHandler = false;
+ Place(); Paint(); SyncBack();
+ }
+ }
if (opening && g_glass && liquid::Golden()) AnimStart(false);
Log(L"quick look: %ls", path.c_str());
}