hrev45342 adds 1 changeset to branch 'master' old head: a95895186d31c350fb8a67b030e062c946e852ca new head: fa392c2a24c12e160de5d29fadf8a4a52deb5804 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=fa392c2+%5Ea958951 ---------------------------------------------------------------------------- fa392c2: Remove unused ShowImage Undo code. [ Ryan Leavengood <leavengood@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev45342 Commit: fa392c2a24c12e160de5d29fadf8a4a52deb5804 URL: http://cgit.haiku-os.org/haiku/commit/?id=fa392c2 Author: Ryan Leavengood <leavengood@xxxxxxxxx> Date: Tue Mar 5 13:59:54 2013 UTC ---------------------------------------------------------------------------- 6 files changed, 219 deletions(-) src/apps/showimage/Jamfile | 1 - src/apps/showimage/ShowImageUndo.cpp | 93 ------------------------------ src/apps/showimage/ShowImageUndo.h | 63 -------------------- src/apps/showimage/ShowImageView.cpp | 45 --------------- src/apps/showimage/ShowImageView.h | 3 - src/apps/showimage/ShowImageWindow.cpp | 14 ----- ---------------------------------------------------------------------------- diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index 87aa25b..3ff8552 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -17,7 +17,6 @@ Application ShowImage : ShowImageApp.cpp ShowImageSettings.cpp ShowImageStatusView.cpp - ShowImageUndo.cpp ShowImageView.cpp ShowImageWindow.cpp ToolBarIcons.cpp diff --git a/src/apps/showimage/ShowImageUndo.cpp b/src/apps/showimage/ShowImageUndo.cpp deleted file mode 100644 index d4c2ad7..0000000 --- a/src/apps/showimage/ShowImageUndo.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2003-2009 Haiku Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Michael Wilber - */ - -#include "ShowImageUndo.h" - -#include <stdio.h> -#include <stdlib.h> - - -ShowImageUndo::ShowImageUndo() - : - fWindow(NULL), - fUndoType(0), - fRestore(NULL), - fSelection(NULL) -{ -} - - -ShowImageUndo::~ShowImageUndo() -{ - InternalClear(); -} - - -void -ShowImageUndo::InternalClear() -{ - fUndoType = 0; - delete fRestore; - fRestore = NULL; - delete fSelection; - fSelection = NULL; -} - - -void -ShowImageUndo::Clear() -{ - InternalClear(); - SendUndoStateMessage(false); -} - - -void -ShowImageUndo::SendUndoStateMessage(bool bCanUndo) -{ - if (fWindow) { - if (!fWindow->IsLocked()) { - fprintf(stderr, - "ShowImageUndo::SendUndoStateMessage: window must be locked!"); - exit(-1); - } - BMessage msg(MSG_UNDO_STATE); - msg.AddBool("can_undo", bCanUndo); - fWindow->PostMessage(&msg); - } -} - - -void -ShowImageUndo::SetTo(BRect rect, BBitmap* restore, BBitmap* selection) -{ - // NOTE: THIS FUNCTION DOES NOT MAKE COPIES OF THE BITMAPS PASSED TO IT - InternalClear(); - - fUndoType = UNDO_UNDO; - fRect = rect; - fRestore = restore; - fSelection = selection; - - SendUndoStateMessage(true); -} - - -void -ShowImageUndo::Undo(BRect rect, BBitmap* restore, BBitmap* selection) -{ - // NOTE: THIS FUNCTION DOES NOT MAKE COPIES OF THE BITMAPS PASSED TO IT - fUndoType = UNDO_REDO; - fRect = rect; - delete fRestore; - fRestore = restore; - fSelection = selection; - // NOTE: fSelection isn't deleted here because ShowImageView - // takes ownership of it during an Undo -} - diff --git a/src/apps/showimage/ShowImageUndo.h b/src/apps/showimage/ShowImageUndo.h deleted file mode 100644 index 7cfc8d8..0000000 --- a/src/apps/showimage/ShowImageUndo.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2003-2009 Haiku Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Michael Wilber - */ -#ifndef SHOW_IMAGE_UNDO_H -#define SHOW_IMAGE_UNDO_H - - -#include <Bitmap.h> -#include <Message.h> -#include <Messenger.h> -#include <Rect.h> -#include <Window.h> - -#include "ShowImageConstants.h" - - -// for Undo -#define UNDO_UNDO 1 -#define UNDO_REDO 2 - - -class ShowImageUndo { -public: - ShowImageUndo(); - ~ShowImageUndo(); - - void SetWindow(BWindow* win) { fWindow = win; } - - void Clear(); - - // NOTE: THESE TWO FUNCTIONS DO NOT MAKE COPIES OF THE - // BITMAPS PASSED TO THEM - void SetTo(BRect rect, BBitmap* restore, BBitmap* selection); - void Undo(BRect rect, BBitmap* restore, BBitmap* selection); - - int32 GetType() { return fUndoType; } - BRect GetRect() { return fRect; } - BBitmap* GetRestoreBitmap() { return fRestore; } - BBitmap* GetSelectionBitmap() { return fSelection; } - -private: - void InternalClear(); - void SendUndoStateMessage(bool bCanUndo); - - BWindow* fWindow; - // Window to which notification messages are sent - int32 fUndoType; - // Nothing, Undo or Redo - BRect fRect; - // Area of background bitmap where change took place - BBitmap* fRestore; - // Changed portion of background bitmap, before change took place - BBitmap* fSelection; - // Selection present before change took place -}; - - -#endif // SHOW_IMAGE_UNDO_H - diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 695b000..3a39f88 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -368,7 +368,6 @@ ShowImageView::SetImage(const entry_ref* ref, BBitmap* bitmap, BitmapOwner* bitmapOwner) { // Delete the old one, and clear everything - fUndo.Clear(); _SetHasSelection(false); fCreatingSelection = false; _DeleteBitmap(); @@ -534,7 +533,6 @@ void ShowImageView::AttachedToWindow() { FitToBounds(); - fUndo.SetWindow(Window()); FixupScrollBars(); } @@ -1480,47 +1478,6 @@ ShowImageView::SetSelectionMode(bool selectionMode) void -ShowImageView::Undo() -{ - int32 undoType = fUndo.GetType(); - if (undoType != UNDO_UNDO && undoType != UNDO_REDO) - return; - - // backup current selection - BRect undoneSelRect; - BBitmap* undoneSelection; - undoneSelRect = fSelectionBox.Bounds(); - undoneSelection = _CopySelection(); - - if (undoType == UNDO_UNDO) { - BBitmap* undoRestore; - undoRestore = fUndo.GetRestoreBitmap(); - if (undoRestore) - _MergeWithBitmap(undoRestore, fUndo.GetRect()); - } - - // restore previous image/selection - BBitmap* undoSelection; - undoSelection = fUndo.GetSelectionBitmap(); - // NOTE: ShowImageView is responsible for deleting this bitmap - // (Which it will, as it would with a fSelectionBitmap that it - // allocated itself) - if (!undoSelection) - _SetHasSelection(false); - else { - fCopyFromRect = BRect(); - fSelectionBox.SetBounds(this, fUndo.GetRect()); - _SetHasSelection(true); - fSelectionBitmap = undoSelection; - } - - fUndo.Undo(undoneSelRect, NULL, undoneSelection); - - Invalidate(); -} - - -void ShowImageView::SelectAll() { fCopyFromRect.Set(0, 0, fBitmap->Bounds().Width(), @@ -1732,7 +1689,6 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet) void ShowImageView::_UserDoImageOperation(ImageProcessor::operation op, bool quiet) { - fUndo.Clear(); _DoImageOperation(op, quiet); } @@ -1773,7 +1729,6 @@ ShowImageView::ResizeImage(int w, int h) // remove selection _SetHasSelection(false); - fUndo.Clear(); _DeleteBitmap(); fBitmap = scaled; diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index bdf4d10..33f3127 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -24,7 +24,6 @@ #include "Filter.h" #include "SelectionBox.h" -#include "ShowImageUndo.h" class BitmapOwner; @@ -82,7 +81,6 @@ public: void SetSelectionMode(bool selectionMode); bool IsSelectionModeEnabled() const { return fSelectionMode; } - void Undo(); void SelectAll(); void ClearSelection(); @@ -182,7 +180,6 @@ private: void _ShowToolBarIfEnabled(bool show); private: - ShowImageUndo fUndo; entry_ref fCurrentRef; BitmapOwner* fBitmapOwner; diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 8464ed2..fbd6a54 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -418,8 +418,6 @@ ShowImageWindow::_AddMenus(BMenuBar* bar) bar->AddItem(menu); menu = new BMenu(B_TRANSLATE("Edit")); - _AddItemMenu(menu, B_TRANSLATE("Undo"), B_UNDO, 'Z', 0, this, false); - menu->AddSeparatorItem(); _AddItemMenu(menu, B_TRANSLATE("Copy"), B_COPY, 'C', 0, this, false); menu->AddSeparatorItem(); _AddItemMenu(menu, B_TRANSLATE("Selection mode"), MSG_SELECTION_MODE, 0, 0, @@ -767,18 +765,6 @@ ShowImageWindow::MessageReceived(BMessage* message) break; } - case MSG_UNDO_STATE: - { - bool enable; - if (message->FindBool("can_undo", &enable) == B_OK) - _EnableMenuItem(fBar, B_UNDO, enable); - break; - } - - case B_UNDO: - fImageView->Undo(); - break; - case B_COPY: fImageView->CopySelectionToClipboard(); break;