Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spotifyamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,6 @@ PlaylistWindow::PlaylistWindow(MainWindow *main_window) {
id_ = 1;
main_window_ = main_window;
hover_button_ = -1;
Resize(WND_MAIN_W, WND_MAIN_H * 3);
}

PlaylistWindow::~PlaylistWindow() {
Expand All @@ -1531,6 +1530,7 @@ PlaylistWindow::~PlaylistWindow() {

void PlaylistWindow::Load() {
LoadPosition(main_window.screen_rect()->left, main_window.screen_rect()->bottom);
LoadSize(WND_MAIN_W, WND_MAIN_H * 3);
SetCompact(PrefReadBool(false, "pl.compact"));
font_size_ = PrefReadInt(10, "pl.font_size");
row_height_ = 13;
Expand Down
31 changes: 23 additions & 8 deletions window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,43 @@ void PlatformWindowBase<PlatformWindow>::Create(PlatformWindow *owner_window) {


template<>
const char *PlatformWindowBase<PlatformWindow>::GetPositionKey(const char *side) {
static char leftKey[12];
snprintf(leftKey, sizeof(leftKey), "window_%d_%s", id_, side);
return leftKey;
const char *PlatformWindowBase<PlatformWindow>::GetWindowKey(const char *key) {
static char windowKey[12];
snprintf(windowKey, sizeof(windowKey), "window_%d_%s", id_, key);
return windowKey;
}


template<>
void PlatformWindowBase<PlatformWindow>::SavePosition() {
PrefWriteInt(screen_rect_.left, GetPositionKey("l"));
PrefWriteInt(screen_rect_.top, GetPositionKey("t"));
PrefWriteInt(screen_rect_.left, GetWindowKey("l"));
PrefWriteInt(screen_rect_.top, GetWindowKey("t"));
}


template<>
void PlatformWindowBase<PlatformWindow>::LoadPosition(int def_left, int def_top) {
int left(PrefReadInt(def_left, GetPositionKey("l")));
int top(PrefReadInt(def_top, GetPositionKey("t")));
int left(PrefReadInt(def_left, GetWindowKey("l")));
int top(PrefReadInt(def_top, GetWindowKey("t")));
Move(left, top);
}


template<>
void PlatformWindowBase<PlatformWindow>::SaveSize() {
PrefWriteInt(width_, GetWindowKey("w"));
PrefWriteInt(height_, GetWindowKey("h"));
}


template<>
void PlatformWindowBase<PlatformWindow>::LoadSize(int def_width, int def_height) {
int width(PrefReadInt(def_width, GetWindowKey("w")));
int height(PrefReadInt(def_height, GetWindowKey("h")));
Resize(width, height);
}


template<>
void PlatformWindowBase<PlatformWindow>::SetDoubleSize(bool v) {
if (v != double_size_) {
Expand Down
5 changes: 4 additions & 1 deletion window.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class PlatformWindowBase {
void SavePosition();
void LoadPosition(int def_left, int def_top);

void SaveSize();
void LoadSize(int def_width, int def_height);

// Double all pixels
void SetDoubleSize(bool v);
bool double_size() const { return double_size_; }
Expand Down Expand Up @@ -64,7 +67,7 @@ class PlatformWindowBase {
Rect screen_rect_;
T *next_, *owner_;
private:
const char *GetPositionKey(const char *side);
const char *GetWindowKey(const char *key);
};

#if defined(WITH_SDL)
Expand Down
2 changes: 2 additions & 0 deletions window_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ void PlatformWindow::MoveAllWindows() {
SDL_SetWindowPosition(w->window_, r->left, r->top);
SDL_SetWindowSize(w->window_, r->right - r->left, r->bottom - r->top);
w->need_move_ = false;
w->SavePosition();
w->SaveSize();
}
}
}
Expand Down
1 change: 1 addition & 0 deletions window_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ void PlatformWindow::MoveAllWindows() {
r->right - r->left, r->bottom - r->top, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
w->need_move_ = false;
w->SavePosition();
w->SaveSize();
}
}
EndDeferWindowPos(dp);
Expand Down