"finalize AlphaTransparentRasterCmd"
[email protected] Fri, 28 Jun 2002 12:50:18 -0700
| Newsgroups | gmane.comp.lib.ivtools.patches |
|---|---|
| Message-ID | <[email protected]> |
Patch: ivtools-020619-johnston-053 For: ivtools-1.0.3 Author: [email protected] Subject: finalize AlphaTransparentRasterCmd Requires: This is an intermediate patch to ivtools-1.0.3. To apply, cd to the top-level directory of the ivtools source tree (the directory with src and config subdirs), and apply like this: patch -p0 <ThisFile Summary of Changes: - finalize AlphaTransparentRasterCmd with undo capability and instantaneous update Index: OverlayUnidraw/rastercmds.c diff -c OverlayUnidraw/rastercmds.c:1.2 OverlayUnidraw/rastercmds.c:1.3 *** OverlayUnidraw/rastercmds.c:1.2 Fri Jun 14 16:07:32 2002 --- src/OverlayUnidraw/rastercmds.c Wed Jun 19 14:48:02 2002 *************** *** 169,180 **** /*-----------------------------------------------------------------*/ AlphaTransparentRasterCmd::AlphaTransparentRasterCmd(ControlInfo* ci) : Command(ci) { } Command* AlphaTransparentRasterCmd::Copy() { ! Command* copy = new AlphaTransparentRasterCmd(GetControlInfo()); InitCopy(copy); ((AlphaTransparentRasterCmd*)copy)->_alpha = _alpha; return copy; } --- 169,183 ---- /*-----------------------------------------------------------------*/ AlphaTransparentRasterCmd::AlphaTransparentRasterCmd(ControlInfo* ci) : Command(ci) { + _alpha_set = false; } Command* AlphaTransparentRasterCmd::Copy() { ! Command* copy = new AlphaTransparentRasterCmd(CopyControlInfo()); InitCopy(copy); ((AlphaTransparentRasterCmd*)copy)->_alpha = _alpha; + ((AlphaTransparentRasterCmd*)copy)->_oldalpha = _oldalpha; + ((AlphaTransparentRasterCmd*)copy)->_alpha_set = _alpha_set; return copy; } *************** *** 189,203 **** } void AlphaTransparentRasterCmd::Execute() { - // find the rasters in the current comp and unhighlight ! char* newalpha = StrEditDialog::post ! (GetEditor()->GetWindow(), ! "Enter alpha value", "0.5"); ! if (newalpha) ! _alpha = atof(newalpha); ! else ! _alpha = 1.0; OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlaySelection* sel = (OverlaySelection*) ed->GetSelection(); --- 192,208 ---- } void AlphaTransparentRasterCmd::Execute() { ! if (!_alpha_set) { ! char* newalpha = StrEditDialog::post ! (GetEditor()->GetWindow(), ! "Enter alpha value", "0.5"); ! if (newalpha) ! _alpha = atof(newalpha); ! else ! _alpha = 1.0; ! _alpha_set = true; ! } OverlayEditor* ed = (OverlayEditor*)GetEditor(); OverlaySelection* sel = (OverlaySelection*) ed->GetSelection(); *************** *** 207,217 **** if (view->IsA(OVRASTER_VIEW)) { RasterOvView* rastview = (RasterOvView*)view; if (rastview) { ! OverlayRasterRect* rr = rastview->GetOverlayRasterRect(); if (rr) { rr->alphaval(_alpha); } } } } } --- 212,249 ---- if (view->IsA(OVRASTER_VIEW)) { RasterOvView* rastview = (RasterOvView*)view; if (rastview) { ! RasterOvComp* rastcomp = (RasterOvComp*)rastview->GetSubject(); ! OverlayRasterRect* rr = rastcomp->GetOverlayRasterRect(); if (rr) { + _oldalpha = rr->alphaval(); rr->alphaval(_alpha); + rastcomp->Notify(); + unidraw->Update(); + } + } + } + } + } + + void AlphaTransparentRasterCmd::Unexecute() { + + OverlayEditor* ed = (OverlayEditor*)GetEditor(); + OverlaySelection* sel = (OverlaySelection*) ed->GetSelection(); + Iterator i; + for (sel->First(i); !sel->Done(i); sel->Next(i)) { + GraphicView* view = sel->GetView(i); + if (view->IsA(OVRASTER_VIEW)) { + RasterOvView* rastview = (RasterOvView*)view; + if (rastview) { + RasterOvComp* rastcomp = (RasterOvComp*)rastview->GetSubject(); + OverlayRasterRect* rr = rastcomp->GetOverlayRasterRect(); + if (rr) { + rr->alphaval(_oldalpha); + rastcomp->Notify(); + unidraw->Update(); } } } } } + Index: OverlayUnidraw/rastercmds.h diff -c OverlayUnidraw/rastercmds.h:1.2 OverlayUnidraw/rastercmds.h:1.3 *** OverlayUnidraw/rastercmds.h:1.2 Fri Jun 14 16:07:32 2002 --- src/OverlayUnidraw/rastercmds.h Wed Jun 19 14:48:02 2002 *************** *** 80,85 **** --- 80,86 ---- AlphaTransparentRasterCmd(ControlInfo* ci); virtual void Execute(); + virtual void Unexecute(); virtual Command* Copy(); virtual ClassId GetClassId(); *************** *** 89,94 **** --- 90,97 ---- protected: float _alpha; + float _oldalpha; + boolean _alpha_set; }; *** /dev/null Wed Jun 19 14:48:10 PDT 2002 --- patches/ivtools-020619-johnston-053 *************** patches/ivtools-020619-johnston-053 *** 0 **** --- 1 ---- + ivtools-020619-johnston-053 ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Caffeinated soap. No kidding. http://thinkgeek.com/sf