For spectrally negative Lévy risk processes we consider a general version of de Finetti's optimal dividend problem in which the ruin time is replaced with a general drawdown time from the running maximum in its value function. We identify a condition under which a barrier dividend strategy is optimal among all admissible strategies if the underlying process does not belong to a small class of compound Poisson processes with drift, for which the take-the-money-and-run dividend strategy is optimal. It generalizes the previous results on dividend optimization from ruin time based to drawdown time based. The associated drawdown functions are discussed in detail for examples of spectrally negative Lévy processes.